D
D
Dmitry2014-10-20 16:22:10
linux
Dmitry, 2014-10-20 16:22:10

Router on linux with two interfaces from the same subnet - which interface will the system choose?

Hello!
For some purposes, I had to raise the router on linux (CentOS 6.5) with two interfaces, eth0 192.168.0.1 and eth1 192.168.0.2. The interface configurations are the same, except for the addresses.
The question is - through which interface will outgoing traffic go, for example, to the default gateway?
default gateway is written in the same way on both (in ifcfg-eth*).
And is it possible to influence the choice of route in this case?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
S
Sergey Petrikov, 2014-10-20
@RicoX

Will walk through the gateway that went up first. You can configure it to work through both interfaces, make several default gateways and manage traffic between them based on different tables (for example, always respond from the network to which the request came), nothing complicated.

V
Valentine, 2014-10-20
@vvpoloskin

Most likely, with a normal configuration, eth1 will not rise at all or will work crookedly - you cannot put addresses from the same network on two interfaces in a normal configuration.
And you can influence the route by specifying the outgoing interface in ip route add 0.0.0.0/0 dev ethX

S
Sergey, 2014-10-20
@bk0011m

Strange need. Isn't it easier to raise one interface, and make the second IP an alias for it??

V
Vladimir, 2014-10-20
@rostel

you can influence using advanced routing
you need to outline the scheme using three commands ip route..., ip rule..., iptables -t mangle...
google will tell you in more detail

S
sultanov, 2014-10-21
@sultanov

In general... there is such a thing... in the management of any network interface on Linux... The metric is called, in addition, the interfaces are clearly called differently... but it's best to separate them into different subnets... just think about what you need from this solution ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question