LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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-18-2012, 12:55 PM   #1
BodaZsombor
LQ Newbie
 
Registered: Oct 2012
Posts: 1

Rep: Reputation: Disabled
Question Linux as multi-WAN gateway/router. Problem routing traffic through the right NICs.


Hello,

this is a rather simple question, I'm afraid. If English was my native language, I'd have done some more searching on the internet, but I even lack the keywords to look for in first place. Please bear with me this one time.

How do I tell my (Debian 6) Linux gateway (eth0: LAN, eth1: WAN1, eth2: WAN2) to route/redirect traffic on port 1000 from eth0 to eth1 (and vice versa) and traffic on port 2000 from eth0 to eth2 (and vice versa)?

Thank you.
 
Old 10-20-2012, 08:42 AM   #2
hamlindsza
Member
 
Registered: Aug 2012
Distribution: Debian, CentOS
Posts: 74

Rep: Reputation: Disabled
Hi,

Quote:
Originally Posted by BodaZsombor View Post
How do I tell my (Debian 6) Linux gateway (eth0: LAN, eth1: WAN1, eth2: WAN2) to route/redirect traffic on port 1000 from eth0 to eth1 (and vice versa) and traffic on port 2000 from eth0 to eth2 (and vice versa)?
You can do this with the help of iproute2. You can get detailed information on iproute2 from here: http://lartc.org/howto/lartc.iproute2.html

First make sure you have iproute2 installed, if not install:
Code:
apt-get install iproute2
Then create routing tables for each WAN Link.
Code:
echo "1 WAN1" >> /etc/iproute2/rt_tables
echo "2 WAN2" >> /etc/iproute2/rt_tables
Specify the default route for each table, with the actual gateway of WAN1 & WAN2
Code:
ip route add default via <WAN1's GATEWAY> dev eth1 table WAN1
ip route add default via <WAN2's GATEWAY> dev eth2 table WAN2
Mark the packets you want to route. You've not mentioned if 1000 & 2000 is the source or destination port. In the below example ive mentioned as the destination port.
Code:
iptables -A PREROUTING -t mangle -i eth0 -p tcp --dport 1000 -j MARK --set-mark 1
iptables -A PREROUTING -t mangle -i eth0 -p tcp --dport 2000 -j MARK --set-mark 2
Code:
ip rule add from all fwmark 1 table WAN1
ip rule add from all fwmark 2 table WAN2
Happy Routing
 
  


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
Routing issue (same subnet, 2 wan gateway, 1 webserver) leosophy Linux - Networking 3 09-03-2010 02:15 PM
multi gateway routing problem hi100nu Linux - Networking 2 06-17-2006 01:24 PM
Multi Homed Gateway Router Problem conradg Linux - Networking 2 03-30-2006 11:51 PM
open source multi-WAN router lothario Linux - Networking 3 11-24-2005 05:31 AM
Linux Gateway+Two NICS+Router+HOWTO pin_bk Linux - Networking 11 09-07-2004 12:29 PM

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

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