two interfaces routing issue

Tom H tomh0665 at gmail.com
Mon Jan 5 17:00:43 UTC 2015


On Sat, Jan 3, 2015 at 8:41 PM, John D. <jd at soft.geocast.net> wrote:
>
> My server has two interfaces, it has two public IPs bound.
> For example, eth0 has the IP:
>
> 216.239.32.xx
> the gw for this network is 216.239.32.1
>
> eth1 has the IP:
> 208.84.0.xx
>
> the gw for this network is 208.84.0.1
>
> Since the system has only one default gw 216.239.32.1, my question is, how
> to make the incoming packages to eth1 return back via the second gw
> 208.84.0.1? thanks.

I haven't done this in at least 4/5 years so this might be incomplete
(or even incorrect!) but the basics are:

- Create routing tables
# printf "100\tgw0\n" >> /etc/iproute2/rt_tables
# printf "101\tgw1\n" >> /etc/iproute2/rt_tables

- Create routes
# ip route add default via 216.239.32.1 dev eth0 table gw0
# ip route add default via 208.84.0.1 dev eth1 table gw1

- Create rules
# ip rule add from 216.239.32.xx table gw0
# ip rule add from 208.84.0.xx table gw1

Google "policy routing" and you should get hits with good info.



More information about the ubuntu-users mailing list