Static routes disappear after reboot - Jessie (SOLVED)

Kernels & Hardware, configuring network, installing services

Static routes disappear after reboot - Jessie (SOLVED)

Postby MTHex » 2017-11-28 12:34

Greetings everyone, hope all is fine.

I'm wondering if someone could give me any tips with this problem.

I'm actually running Debian 8 Jessie with the following version:

Code: Select all
migue@Wise:~$ uname -r
3.16.0-4-686-pae

migue@Wise:~$ lsb_release
No LSB modules are available.

migue@Wise:~$ cat /proc/version
Linux version 3.16.0-4-686-pae (debian-kernel@lists.debian.org) (gcc version 4.8.4 (Debian 4.8.4-1) ) #1 SMP Debian 3.16.43-2+deb8u5 (2017-09-19)


This OS is running on a VM-Ware ESXI 5.5.0 as a Virtual Machine, my problem is the same problem the user in this thread has:

http://forums.debian.net/viewtopic.php?f=5&t=132182&p=639304&hilit=static+routes#p639304

I've tried to add static entries on the /etc/network/interfa
ces as follows with no results:

Code: Select all
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

#source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
auto eth0
iface eth0 inet static
        address 192.168.12.101
        netmask 255.255.255.0
        network 192.168.12.0
        broadcast 192.168.12.255
        gateway 192.168.12.230
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 200.30.40.245 200.40.220.245
        post-up ip route add -inet 150.100.1.0/24 gw 192.168.12.254 dev eth0
        post-up ip route add -inet 180.100.1.0/24 gw 192.168.12.254 dev eth0
        post-up ip route add -inet 192.168.15.0/24 gw 192.168.12.254 dev eth0


Also tried to make an script inside /etc/network/if-up.d$ something I read on the Ubuntu forums as a working process when the interface comes up.

Something like:

Code: Select all

../etc/network/if-up.d$ sudo nano script.sh

#!/bin/bash
# Adding static rules at the beginning

ip route add -inet 150.100.1.0/24 gw 192.168.12.254 dev eth0
ip route add -inet 180.100.1.0/24 gw 192.168.12.254 dev eth0
ip route add -inet 192.168.15.0/24 gw 192.168.12.254 dev eth0



If I add the static rules manually they are forgotten after reboot.

Is there another way to make static rules persistent?

Thank you all in advance.

Regards;

M.
Last edited by MTHex on 2017-12-01 12:37, edited 1 time in total.
MTHex
 
Posts: 3
Joined: 2017-11-28 11:46

Re: Static routes disappear after reboot - Jessie

Postby Head_on_a_Stick » 2017-11-28 17:54

"Only the mediocre are always at their best." — Jean Giraudoux
User avatar
Head_on_a_Stick
 
Posts: 6803
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Static routes disappear after reboot - Jessie

Postby MTHex » 2017-11-30 18:54

Thank you Head_on_a_Stick for your assistance.

You know, It worked but not at 100%.

I've created a
Code: Select all
10-static.network
->
Code: Select all
/etc/systemctl/network


And the routes are added after ->
Code: Select all
sudo systemctl restart systemd-networkd


But when I reboot, I have to run
Code: Select all
sudo systemctl restart systemd-networkd
everytime.

Is there any chance to put this "restart command" at the beginning of the system as a script or something?

Thanks in advance.
MTHex
 
Posts: 3
Joined: 2017-11-28 11:46

Re: Static routes disappear after reboot - Jessie

Postby Head_on_a_Stick » 2017-11-30 19:31

Did you try
Code: Select all
# systemctl enable systemd-networkd

The systemctl man page is very thorough, as are the rest of the systemd pages.
"Only the mediocre are always at their best." — Jean Giraudoux
User avatar
Head_on_a_Stick
 
Posts: 6803
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Static routes disappear after reboot - Jessie (solved)

Postby MTHex » 2017-12-01 12:21

Works like a charm..

I missed that part somehow on the man pages.

I really appreciate your help and thanks for sharing the documentation.

Have a great day.

M.
MTHex
 
Posts: 3
Joined: 2017-11-28 11:46


Return to System configuration

Who is online

Users browsing this forum: No registered users and 9 guests

fashionable