As a result we will receive the following error trying to define gateway outside of configured network:
- Code: Select all
# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:16:3E:29:5A:82
inet addr:10.10.10.10 Bcast:10.10.10.15 Mask:255.255.255.248
inet6 addr: fe80::216:3eff:fe29:5a82/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2522216 errors:0 dropped:0 overruns:0 frame:0
TX packets:61813 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:185056341 (176.4 MiB) TX bytes:122461673 (116.7 MiB)
Interrupt:77
# route add default gw 11.11.11.11
SIOCADDRT: No such process
****
To resolve it we can use the following way:
- Code: Select all
route add 11.11.11.11/32 dev eth0
route add default gw 11.11.11.11
If we want to make above routes persistent we should define them in network init script:
Debian/Ubuntu case:
Add the following rules in /etc/network/interfaces :
- Code: Select all
post-up route add 11.11.11.11/32 dev eth0
post-up route add default gw 11.11.11.11
RedHat/Centos case:
Add the following rule in /etc/sysconfig/network-scripts/ifcfg-eth0
- Code: Select all
SCOPE="peer 11.11.11.11"