Linux, FreeBSD, Juniper, Cisco / Network security articles and troubleshooting guides
https://forum.ivorde.com/

Debian persistent static route - how to make a static route persistent across reboots
https://forum.ivorde.com/debian-persistent-static-route-how-to-make-a-static-route-persistent-across-reboots-t19727.html
Page 1 of 1

Author:  mandrei99 [ Sat Jan 17, 2015 7:55 pm ]
Post subject:  Debian persistent static route - how to make a static route persistent across reboots

Debian linux "man interfaces" explains some callbacks used before or after an interface is brought up/down. One of them is "post-up". Quote "man interfaces":
Quote:
post-up command
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.


Interface configuration file in Debian is under "/etc/network/interfaces" so that's where we can add the persistent static route.

Code:
# Network interface for debian
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
auto eth0
iface eth0 inet static
        address 10.1.22.181
        netmask 255.255.255.0
        network 10.1.22.0
        broadcast 10.1.22.255
        gateway 10.1.22.1
        dns-nameservers 8.8.8.8
        post-up ip ro add 1.1.1.1 via 10.1.22.10


A static route in Linux, as in any other net system, has 3 main components: host, netmask and gateway.

The above "ip ro add 1.1.1.1 via 10.1.22.10" command can also be added to "/etc/rc.local".

Debian list routing table:
Code:
# ip route
default via 10.1.22.3 dev eth0  proto static  initcwnd 10 initrwnd 10
1.1.1.1 via 10.1.22.10 dev eth0

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/