LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-10-2021, 08:50 PM   #1
ballsystemlord
Member
 
Registered: Aug 2014
Distribution: Devuan
Posts: 214

Rep: Reputation: Disabled
Smile How to route to home network and global network


Hello,
This problem has probably been asked and answered 1,000 times already, I just can't find the right search terms. So please just point me in the right direction. I will RTFM.

I wanted to create an intranet (home net), and have a second connection go to the internet (global net). I can setup routing for the local router to assign addresses on the intranet just fine.
What I have trouble with is telling Linux to send packets for other addresses than 192.168.1.XXX to the global network interface, and vice versa. It seems Linux just chooses one or the other interface and puts every packet onto it assuming they will reach their destination -- when they will not.
I also need to know how, if one link goes down, to make Linux NOT send all the packets for that interface out the other one. Linux appears to assume that the links are a redundancy measure by default, not 2 different networks.

Thanks!
 
Old 11-10-2021, 09:20 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,592

Rep: Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880
From your post it appears you want to build a router. A quick search here and the Internet will find many guides.

Basically to route traffic from one interface to another you need to enable ip_forward which is a kernel parameter i.e. echo 1 > /proc/sys/net/ipv4/ip_forward and can be set permanently in your sysctl.conf. There is a similar configuration for IPV6 if needed. Using masquerade firewall rules you can setup a NAT router.
 
Old 11-10-2021, 09:41 PM   #3
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,272
Blog Entries: 28

Rep: Reputation: 6124Reputation: 6124Reputation: 6124Reputation: 6124Reputation: 6124Reputation: 6124Reputation: 6124Reputation: 6124Reputation: 6124Reputation: 6124Reputation: 6124
You might be able to do this with iptables. A web search for "iptables route network packets" turns up a number of articles that might be helpful.

This one might be a good place to start: https://serverfault.com/questions/34...ific-interface

Full Disclosure: I've never done anything like this myself.
 
Old 11-10-2021, 09:46 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,592

Rep: Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880
I forgot to mention for DHCP clients your DHCP server also needs to set gateway IP address which is the LAN IP address and DNS name server options.
 
Old 11-11-2021, 07:17 PM   #5
ballsystemlord
Member
 
Registered: Aug 2014
Distribution: Devuan
Posts: 214

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by frankbell View Post
You might be able to do this with iptables. A web search for "iptables route network packets" turns up a number of articles that might be helpful.

This one might be a good place to start: https://serverfault.com/questions/34...ific-interface

Full Disclosure: I've never done anything like this myself.
That looks like a great place to start. Thanks! I'll try to work from that and repost my success/failure.

To be clear, I'm not trying to create a nat router -- I intend to in the future, but I can find docs on that pretty easily.
 
Old 11-11-2021, 10:26 PM   #6
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,258
Blog Entries: 3

Rep: Reputation: 3713Reputation: 3713Reputation: 3713Reputation: 3713Reputation: 3713Reputation: 3713Reputation: 3713Reputation: 3713Reputation: 3713Reputation: 3713Reputation: 3713
Quote:
Originally Posted by ballsystemlord View Post
That looks like a great place to start.
If you are just starting out then it might be a better idea to begin with NFTables instead. First that's where all the development is currently happening. Second, NFTables is planned to replace IPTables sometime, though the latter has a tragicomically long tail due to all the easily found but outdated material out there on the web.

For NFTables, look at their Wiki:

https://wiki.nftables.org/

https://wiki.nftables.org/wiki-nftab..._in_10_minutes
 
Old 11-12-2021, 06:34 PM   #7
ballsystemlord
Member
 
Registered: Aug 2014
Distribution: Devuan
Posts: 214

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Turbocapitalist View Post
If you are just starting out then it might be a better idea to begin with NFTables instead.
<snip>
Now that I do some searching, if I'm going to try and leverage NFTables, why not eBPF?

https://ebpf.io/what-is-ebpf/
https://www.kernel.org/doc/html/latest/bpf/index.html
 
Old 11-12-2021, 06:35 PM   #8
ballsystemlord
Member
 
Registered: Aug 2014
Distribution: Devuan
Posts: 214

Original Poster
Rep: Reputation: Disabled
Granted, there's not going to be any examples of how to get eBPF to do what I want, but then NFTables isn't much better according to the above.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Packet going out of wrong interface due to OS adding cache route - OS trying to route through default route msr1981 Linux - Networking 2 10-11-2017 02:58 PM
Packet going out of wrong interface due to OS adding cache route - OS trying to route through default route msr1981 Red Hat 1 10-09-2017 05:45 AM
How to share a ZFS file system between a global zone and a non global zone? crisostomo_enrico Solaris / OpenSolaris 7 11-28-2007 08:20 AM
I am not able to add a new route to my route table using route command prashanth s j Linux - Networking 2 09-03-2005 04:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:46 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