Re: routing by destination port



Hello,

kamilnew@xxxxxxxxx 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.
.



Relevant Pages

  • Re: combox update other table
    ... Sorry, Mark. ... >>> Form1 for table1 has a combobox with a table lookup. ... Would I use AFTERUPDATE? ...
    (microsoft.public.access.formscoding)
  • 2.6.31 and connmark restore are not really working for fwmarking and policy routing
    ... ip rule from all fwmark 0x10 lookup table 1 ... I already used the TRACE target for a testing address and what I see is, ... Konstantin Agouros aka Elwood Blues. ...
    (comp.os.linux.networking)
  • Re: iptables + multiple gateways not firewalling
    ... from all fwmark 0x10 lookup mail ... I added the route to the server I am trying to connect to, ...
    (Ubuntu)
  • Re: site critique - email user
    ... start degrading enough to be noticed after you reach the couple of ... hundred mark or so if you are just searching initially for 'does ... sites the technique avoids a lookup in a directory of 65536 files using ...
    (uk.net.web.authoring)
  • Re: Allocating Dates
    ... Mark, you may be able to do this without a table, just using: ... If you want to use a lookup table of dates, you are best to store only the first date in the period, and then use this kind of logic to figure out the ending date and consequently the period that any particular date belongs to: ... Perth, Western Australia ... In my mind it would be taking the remaning days from starting date to the end of the first week, then allocating the dates for the remaining weeks based on the number of days remaining. ...
    (microsoft.public.access.forms)