two interfaces routing issue

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

On Sat, Jan 3, 2015 at 8:41 PM, John D. <jd at> 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
> eth1 has the IP:
> 208.84.0.xx
> the gw for this network is
> Since the system has only one default gw, my question is, how
> to make the incoming packages to eth1 return back via the second gw
> 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 dev eth0 table gw0
# ip route add default via 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