LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-18-2016, 03:57 PM   #1
LnxNewUser
LQ Newbie
 
Registered: Nov 2016
Posts: 4

Rep: Reputation: Disabled
Linux network architecture - local network vs. LAN network rule


Hello,

I have a question linked to the local delivery of packets for Linux Kernel. My question is linked to network features.

I've two ethernet interfaces (eth0 and eth1), I want to send a packet from eth0 to eth1 and force it to be routed on the LAN network by a router or another computer. (as shown below)
On the computer 2, I've launched wireshark and a simple C program which listen on a UDP port and redirect the UDP message to another Ip address (simple ip redirection)

Code:
     +++++++++++
     +  =====  +               Msg  +++++++++++
     +  Eth0 -------------------->----        +
     +  =====  +                    + |       +
     +         +                    + |       +
     +  =====  +                    + |       +
     +  Eth1 --------------------<----        +
     +  =====  +    LAN Network     +++++++++++
     +++++++++++                     Computer 2
     Computer 1
According to my understanding, when the linux kernel sees that the packet sended by eth0 is destinated to eth1. The packet is routed through the local network and not on the LAN network.

Is it possible to force the Linux Kernel to send it on the "outside" network? If yes, how can I do it?

After reading Linux network architecture articles on google, I've thought to modify the ip_rcv / ip_route_input functions in order to force it to go on the LAN Network.

Thanks for your help.
 
Old 11-19-2016, 01:34 AM   #2
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 509

Rep: Reputation: 203Reputation: 203Reputation: 203
Hi, and welcome!

Yes, you're correct: the kernel normally routes such packets internally, without sending them out on the wire.

I believe you can change this with some setting changes and appropriate routing, though.

First, let's look at routing. You have to force the traffic out of the system. Let's assume eth0 has IP address 192.168.1.1, and eth1 has IP 192.168.1.2. Fix the routing with:

Code:
route add -host 192.168.1.2 dev eth0
route add -host 192.168.1.1 dev eth1
You also need to tell the kernel to allow this traffic, and not drop it as "martian source" traffic, with:

Code:
sysctl -w net.ipv4.conf.eth0.accept_local=1
sysctl -w net.ipv4.conf.eth1.accept_local=1
sysctl -w net.ipv4.conf.all.rp_filter=2
I think that should do the trick, although I don't have a system where I can test that right now.

References:

- https://www.kernel.org/doc/Documenta.../ip-sysctl.txt
- https://stackoverflow.com/questions/...al-doesnt-work

Good luck!
 
Old 11-19-2016, 03:49 AM   #3
LnxNewUser
LQ Newbie
 
Registered: Nov 2016
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks a lot for your reply and the references.
I'll check it and let you know if it's work or not.
 
  


Reply



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
LXer: Open Network Foundation to Promote New Network Architecture LXer Syndicated Linux News 0 03-23-2011 07:30 AM
OpenVZ iptables rule not working on local network vzxen Linux - Virtualization and Cloud 1 08-15-2010 03:27 PM
Firewall Rules to add VPN Network into my LAN Network ed182 Linux - Networking 1 06-04-2010 03:17 PM
[SOLVED] Creating simultaneous network connections to a VPN and local area network. Reactor89 Linux - Networking 2 06-03-2010 12:52 AM
two network cards - one for local network, one for http/vsftpd server scottster Linux - Networking 1 01-20-2005 08:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:00 AM.

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