[CentOS] Gateway question

Anthony K akcentos at anroet.com
Wed Aug 10 13:54:16 UTC 2016


On 10/08/16 16:29, Levente Birta wrote:
> And as I said this problem is resolved too ... I asked for another way 
> to achieve this
When you add a default gateway with:

route add default gw 192.168.1.1 dev enp3s0

you'll note that you now have 2 routes with the same metric of 0 (use 
route -n to see the metric field - couldn't get ip route to show me the 
metric).

When using ip route command, you need to specify a different metric 
otherwise it won't take.  To me, ip route is doing the right thing as 
having 2 gateways with the same metric will confuse the routing process.

If you need to use ip route to add another default gateway, make sure to 
use a different metric:

ip route add 0/0 via 192.168.1.1 dev enp3s0 metric 
<different_from_other_one>

ak.

------------------------------------

PS: In my virtual environment *[0]*, the routing tables for tables t2 
and t3 appeared incomplete.  The route specified in the route files for 
network 192.168.1.0/24 was missing - most likely cause it was already in 
the main routing table.  Only the default route appeared in the tables

$ cat /etc/sysconfig/network-scripts/route-enp0s3
192.168.1.0/24 dev enp0s3 src 192.168.1.12 table t2
default via 192.168.1.1 dev enp0s3 table t2

$ cat /etc/sysconfig/network-scripts/route-enp0s8
192.168.1.0/24 dev enp0s8 src 192.168.1.13 table t3
default via 192.168.1.1 dev enp0s8 table t3

$ ip r l t t2
default via 192.168.1.1 dev enp0s3

$ ip r l t t3
default via 192.168.1.1 dev enp0s8

*[0]* - https://imagebin.ca/v/2r5NJgNEqSgQ




More information about the CentOS mailing list