Re: routing_based_on_port/services

Martin Benda <[email protected]>
Newsgroups gmane.comp.security.linux
Message-ID <[email protected]>
Hi!

1) Use iptables to mark the outgoing traffic in the mangle PREROUTING chain:

iptables -t mangle -A PREROUTING -i eth0 -p tcp --dport 80 -j MARK --set-mark 1

2) Create routing table for the marked traffic, we will call the new table "http".
This table will contain default route to the ADSL provider.

echo 200 http >> /etc/iproute2/rt_tables
ip route add default via <adsl_ip> dev <adsl_dev> table http

3) Standard default route will point to the P2P provider.

ip route add default via <p2p_ip> dev <p2p_dev>

4) Add routing policy rule to use table "http" for marked traffic:

ip rule add fwmark 1 table http

This configuration is not perfect (e.g. port 80 on the router is not accessible)
but I hope it will help. More on multiple routing tables can be found at

http://lartc.org/howto/lartc.rpdb.html

Of course, you have to turn on appropriate options (e.g. "use fwmark as
a routing key") in your kernel config.

Regards,
Bendis

Dne po 3. října 2005 11:41 [email protected] napsal(a):
> Dear List!
>
> I just want to ask you a question.I have a linux(Secure platform) gateway
> server with 2 external ip address to the internet (one S/0 ADSl, second S/1
> Point to Point) and one internal ip eth0 for my LAN. I need to split up the
> outgoing traffic.HTTP/HTTPS want to route through the ADSL and the rest of
> traffic (SMTP,POP3,FTP) through the Point to Point.Can i solve this with
> Linux iptables or whatever else. Any suggestion help..
>
> regards,
>
> Chris
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQBDQqnxfFqG7qTXBo4RAoUYAKCTOOF6NHIJVEpVcpWJjA+RwH49mQCgjSam
L5ErgmoD1dJqy+AG7tdRxC0=
=9zXv
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.