0

I have 3 interfaces on my server,

  • first is used for the local network,
  • second and third are internet connections (each has its own ip routing table).

How can i force server daemons and command line tools use first interface to create outgoing connections. I want use same iptables nat and filter rules for my server that i use for other machines of my network.

eth0 192.168.0.1
eth1 9.9.9.9
eth2 9.9.9.10

I don't know why it uses eth1 for outgoing connections now.

1 Answer 1

1

If you run

ip route

It will give you results similar to the following:

default via 192.168.0.10 dev eth0  metric 2
127.0.0.0/8 via 127.0.0.1 dev lo
192.168.0.0/24 dev eth0  proto kernel  scope link  src 192.168.0.106  metric 2

As you can see from the above output, any traffic which goes via the default route will go via eth0

So it sounds like you need to do something like this:

ip route delete default via <ip> dev eth1 

then

ip route add default via <ip> dev eth0

How you make this change permanent will depend on your distro.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .