LinuxQuestions.org
Visit Jeremy's Blog.
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 10-19-2013, 02:16 AM   #1
psycroptic
Member
 
Registered: Aug 2011
Location: USA
Distribution: ArchLinux - 3.0 kernel
Posts: 349

Rep: Reputation: Disabled
linux nat router - 2 internal interfaces out on 2 external ones


so i am getting 5 static ips in the near future. What i have now is 2 different internal LANs (on different interfaces) masqueraded out on 1 external interface with the default gateway of the router being my ISPs. What I would like to do is have all internet traffic from these 2 internal LANs go out on 2 external interfaces, such that traffic from 1 LAN will appear to have 1 static IP, and traffic from the 2nd will appear to have the 2nd. Is this kind of thing possible at all? I should add that all 5 of the statics have the same gateway address to the isp.

I have tried this with no results:

Code:
ip route add default via ISPGATEWAY dev 1-external table 100
ip rule add from 172.16.0.0/24 dev 1-internal table 100

ip route add default via ISPGATEWAY dev 2-external table 200
ip rule add from 192.168.192.0/24 dev 2-internal table 200
and then adding relevant iptables masquerading:

Code:
-A POSTROUTING -s 172.16.0.0/16 -o 1-external -j MASQUERADE
-A POSTROUTING -s 192.168.192.0/24 -o 2-external -j MASQUERADE
pings from all internal subnets out to externals result in destination net unreachable, and tcpdump shows traffic input from the internal, nothing out on any other interfaces. i feel like it's a gateway-related issue...
 
Old 10-20-2013, 01:28 PM   #2
psycroptic
Member
 
Registered: Aug 2011
Location: USA
Distribution: ArchLinux - 3.0 kernel
Posts: 349

Original Poster
Rep: Reputation: Disabled
actually, it was on the right track. i found that including the entire /16 and /24 subnets killed the routing on the gateway, presumably because the gateway's own internal addresses are in both of them. doing this:

Code:
ip route add default via ISPGATEWAY dev 2-external src STATIC2 table 110
for i in {2..254..1}; do ip rule add from 192.168.192.$i table 110; done
ip route add default via ISPGATEWAY dev 1-external src STATIC1

iptables -t nat -A POSTROUTING -s 172.16.0.0/16 -o 1-external -j MASQUERADE
iptables -t nat -A POSTROUTING -m iprange --src-range 192.168.192.2-192.168.192.254 -o 2-external -j MASQUERADE
produces expected results; the /16 appears on the net as the first static and /24 on the second.

still feels a bit kludgy
 
  


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
[SOLVED] Moved offices. External websites/internal ssh both work, but internal http doesn't. jasonws Linux - Networking 3 08-04-2011 04:26 PM
Linux router MTU between 2 interfaces dot_txt Linux - Networking 1 03-25-2011 06:51 AM
problem with linux router with 2 interfaces arty Linux - Networking 6 07-01-2009 06:49 AM
2 External Nic, 1 Internal Nic Router Problem trevanda Linux - Networking 0 10-13-2004 02:20 AM

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

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