LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-27-2021, 04:43 PM   #1
hamidi2
Member
 
Registered: Aug 2012
Posts: 63

Rep: Reputation: Disabled
000108 - Routing via dummy interfaces


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 dummy
I'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 tun0
This 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?
Thanks
 
Old 03-27-2021, 05:21 PM   #2
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,804

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
Is IP forwarding enabled?
Code:
cat /proc/sys/net/ipv4/ip_forward
Two of many guides...
https://linuxconfig.org/how-to-turn-...rding-in-linux
https://openvpn.net/faq/what-is-and-...ding-on-linux/

Last edited by ferrari; 03-27-2021 at 05:26 PM.
 
Old 03-27-2021, 10:58 PM   #3
hamidi2
Member
 
Registered: Aug 2012
Posts: 63

Original Poster
Rep: Reputation: Disabled
It was disabled, but when I enabled it, it didn't solve the problem either.
I think IP forwarding is for when you have more than one PC, to inform the kernel to ignore the incoming packet or still try to forward it.
 
Old 03-28-2021, 02:25 AM   #4
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,804

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
No, it's to allow routing between interfaces within a given host.
 
Old 03-28-2021, 02:42 AM   #5
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,804

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
What does traceroute output show?
Code:
traceroute 4.2.2.4
Can you at least reach the gateway address successfully?

Show your working interface IP address assignments
Code:
ip address
and complete routing table
Code:
ip route
 
  


Reply

Tags
bridge, tun



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Debian 10.2 Buster Install: UEFI - Unable to install GRUB in dummy. Executing 'GRUB-install dummy' failed. LinDUX Debian 6 01-27-2020 07:17 PM
Using iptables to only permit SSH access to server via dummy IP and obscure port jubolt Linux - Networking 5 12-22-2014 03:22 AM
Routing via aliased interfaces in RHEL earthlink Linux - Networking 4 04-15-2011 04:06 PM
Problem with routing via different external interfaces (eth and tun) juliensweiss Linux - Networking 1 09-13-2008 09:49 AM
more than one dummy interfaces? kpachopoulos Linux - Networking 3 03-03-2006 06:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration