I have CentOS 6.7 with two Internet connections
eth0 - dynamic IP address and dynamic gateway via DHCP (controlled by NetworkManager)
ppp0 - dynamic IP address and dynamic gateway (configured with rp_pppoe)
I want write script which will change the default gateway on in some conditions something like this:
ip route replace default scope global via $IP1 dev eth0
# or
ip route replace default scope global via $IP2 dev ppp0
# or
ip route replace default scope global nexthop via $IP1 dev eth0 weight 8 nexthop via $IP2 dev ppp0 weight 10
How to find out dynamic gateway $IP1 and $IP2?
update:
from this answer https://unix.stackexchange.com/a/124341/157086
in file /var/lib/dhclient/dhclient.leases I can find gateway to eth0
option routers 12.34.59.28;
How to find out dynamic gateway $IP2 for ppp0?