Networking Forums

Networking Forums > Computer Networking > Linux Networking > routing by destination port

Reply
Thread Tools Display Modes

routing by destination port

 
 
kamilnew@gmail.com
Guest
Posts: n/a

 
      08-29-2007, 05:31 PM
is it possible to route data to the same ip number through different
gates and choose this gates by destination port?

tia
kamil

 
Reply With Quote
 
 
 
 
Pascal Hambourg
Guest
Posts: n/a

 
      08-29-2007, 07:17 PM
Hello,

(E-Mail Removed) a écrit :
> is it possible to route data to the same ip number through different
> gates and choose this gates by destination port?


Yes, with iptables MARK and advanced routing with iproute.
Sample :

iptables -t mangle -A PREROUTING -d <dest> -p tcp --dport <port1> \
-j MARK -set-mark 0x1
ip rule add fwmark 0x1 lookup 1
ip route add default via <gateway1> dev <interface1> table 1

iptables -t mangle -A PREROUTING -d <dest> -p tcp --dport <port2> \
-j MARK -set-mark 0x2
ip rule add fwmark 0x2 lookup 2
ip route add default via <gateway2> dev <interface2> table 2

And so on.
For locally generated traffic instead of forwarded traffic, replace
PREROUTING with OUTPUT.
If you use MASQUERADE with a kernel older that 2.6.10, be aware that it
may fail to select the correct source address ; SNAT is safer.
 
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Source port of 1079 (asprovatalk) to destination port 1025 (blackjack) - required for Microsoft Windows networking? Spin Windows Networking 1 10-07-2008 08:09 PM
changing destination address after routing jois.de.vivre@gmail.com Linux Networking 3 05-30-2008 12:23 AM
multiple ethernet interfaces, routing depending on destination smagister@gmail.com Linux Networking 1 02-04-2007 06:10 PM
Set specific port for ONE trap destination Roger Lindholm Windows Networking 0 05-24-2006 11:04 PM
linux gatewway traffic bandwidth monitoring by source, destination, protocol and port Jesus M. Salvo Jr. Linux Networking 5 01-02-2006 01:47 PM



1 2 3 4 5 6 7 8 9 10 11