Article 5FW7B 000108 - Routing via dummy interfaces

000108 - Routing via dummy interfaces

by
hamidi2
from LinuxQuestions.org on (#5FW7B)
Hi
I'm just doing some practices with Linux (Ubuntu 20.04) to learn more about networking and how does it really work. Consider the following practice:
I create a dummy interface with the following command:
Code:sudo ip link add tun0 type dummyI'm going to change the default route from usb0 interface to this dummy interface, tun0. usb0 is the name of the real interface which connects me to the internet. Because my PC is connected by my cell phone to the internet via USB tethering, it's named usb0. My aim is to write a C program to open RAW sockets on usb0 and tun0 and send whatever it receives from tun0 to usb0 and vice versa. This is the beginning step of the project I'm going to do later. Let's get closer step by step and concentrate on the first step. Let's see what the result is and what I expect it to be. Now the C program is ready and does the job. Before running the program, I change the default route from usb0 to tun0 by the following command:
Code:ip route add default dev tun0This causes all packets to be routed via tun0. My program is sitting on this interface and forwards all the traffic to usb0. This should be enough for the packets to be sent over the internet and for the responses to be received by the application that requested them. But this doesn't happen. I've tested the program in another experiment and am sure that it really works. Exactly the same as a bridge which may be made by brctl, it connects the two interfaces. But when I ping some IP's, like 4.2.2.4, I see that the response is not received. I can't get it work even with brctl.
What may be the problem?
Thankslatest?d=yIl2AUoC8zA latest?i=kMMQLwD4iNs:ar04hKP-1-s:F7zBnMy latest?i=kMMQLwD4iNs:ar04hKP-1-s:V_sGLiP latest?d=qj6IDK7rITs latest?i=kMMQLwD4iNs:ar04hKP-1-s:gIN9vFwkMMQLwD4iNs
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments