Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

setting a static route

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
morgon
Posts: 189
Joined: 2010-08-28 03:04

setting a static route

#1 Post by morgon »

Hi,

I am running testing and would like to configure a static route that should always be available.

Currrently I have this in my /etc/network/interfaces:

Code: Select all

iface enp2s0 inet dhcp
      dns-nameserver 8.8.8.8
      up ip route add 10.10.10.0/24 via 192.168.0.10
      down ip route del 10.10.10.0/24 via 192.168.0.10
And this sets the route when I bring the interface up, however (for reasons that are beyond me) the routing table does not seem to survive a hibernation...

So do I need an extra script that is triggered when I resume from hibernation or how to do properly set such a route that should not be destroyed by hibernation?

Many thanks!

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: setting a static route

#2 Post by Head_on_a_Stick »

Try this script at /lib/systemd/system-sleep/fix-routes:

Code: Select all

#!/bin/sh
case "$1" in
   post) /sbin/ifup enp2s0;;
esac
For more on this see systemd-sleep(8).

But this is _very_ hacky and I don't really understand what you are trying to achieve with your routing.

How are you suspending the system? I would try systemd-networkd instead of ifupdown to see if that behaves any better.
deadbang

morgon
Posts: 189
Joined: 2010-08-28 03:04

Re: setting a static route

#3 Post by morgon »

I suspend with "systemctl hibernate" and I am baffled that the routing tables are gone when I resume.

However the interface is up when I resume so I guess in a systemd-script I simply have to set the route again - it's easy enough to do but I was just wondering if you really need this...

As to what I am trying to achieve:

I used to have a router at 10.10.10.10 (handing out 10.10.10.x ips via dhcp). This little box is my own I run some services on it, all my mobile devices connect to it.

Then I got internet via cable and my provider handed me a cable-modem that is not my own. I cannot change the network it uses - it's 192.168.0.x.

My PC is connected via an ethernet-cable to the cable-modem because this way I get the fastest speed - but I also what to access all the devices that connect to my box from my pc.

So I connected the my own box to the cable-modem with an ethernet-cable (it's 192.168.0.10).

So if I want to access one of my mobile devices (connecting to my box) from my pc I need to set this route.

shep
Posts: 423
Joined: 2011-03-15 15:22

Re: setting a static route

#4 Post by shep »

The Debian Network Configuration wiki uses different syntax:

https://wiki.debian.org/NetworkConfigur ... e_manually

It also uses /etc/resolv.conf for nameserver setup

https://wiki.debian.org/NetworkConfigur ... ameservers

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: setting a static route

#5 Post by Head_on_a_Stick »

@OP: can you provide an ASCII diagram of your network layout? It might just be me being a bit thick but I can't quite grasp what you're describing.
deadbang

Post Reply