I am having trouble getting a static routing ip
command to become permanent by way of the post-up
hook in /etc/network/interfaces
. Here are the relevant details:
/etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback
# Network A
allow-hotplug eth0
iface eth0 inet static
address 10.1.10.100
netmask 255.255.255.0
gateway 10.1.10.1
# Network B
allow-hotplug eth1
iface eth1 inet static
address 192.168.100.1
netmask 255.255.0.0
gateway 127.0.0.1
The relevant ip
command and routing table
ip route add 192.168.50.0/24 via 10.1.10.100 dev eth0
# This command makes things happy...
$ ip route show
default via 10.40.16.1 dev eth0
10.1.10.0/24 dev eth0 proto kernel scope link src 10.1.10.100
192.168.0.0/16 dev eth1 proto kernel scope link src 192.168.100.1
192.168.50.0/24 via 10.1.10.100 dev eth0
The (not working) post-up
/ post-down
hooks
#/etc/network/interfaces
# Network A
allow-hotplug eth0
iface eth0 inet static
address 10.1.10.100
netmask 255.255.255.0
gateway 10.1.10.1
post-up route add -net 192.168.50.0 netmask 255.255.255.0 eth0
post-down route del -net 192.168.50.0 netmask 255.255.255.0 eth0
# Network B
allow-hotplug eth1
iface eth1 inet static
address 192.168.100.1
netmask 255.255.0.0
gateway 127.0.0.1
Disclaimers
The ip route add...
command does the trick, but I need this to be a permanent static route so hence the post-up
stuff. I just can't seem to get the syntax right. When I run try the version of the /etc/network/interfaces
on a local test network the route does not show up in the routing table after a reboot, so I think it is failing to run the post-up
hook due to bad syntax.
Update
The manage for /etc/network/interfaces
isn't much help on giving me a clue on the syntax for the post-up
commands either here is all I found:
post-up
Run command after bringing the interface up. If this command fails then ifup aborts, refraining from marking the interface as configured (even though it has really been configured), prints an error message, and exits with status 0. This behavior may change in the future.