After searching a lot, finding no working solution, I hope I can get help here.
Static route set up in yast/network configuration will not give access to the connected network.
Although the entries for the static route can be seen after restart yast/network configuration.
Using “ip route add DESTINATION/24 via GATEWAY dev DEVICE” establishes the connection
and I am able to work on the connected machine.
After network restart, independent of restarting the host machine or using “systemctl restart network.service”, the static route disappears.
Are you using the “Network Manager” or “wicked” to start the network configuration at boot time?
There are some things to be aware of when configuring static routing.
The basic reference is in the openSUSE documentation: “Reference Guide”: <https://doc.opensuse.org/>
<https://doc.opensuse.org/documentation/leap/reference/html/book.opensuse.reference/index.html>
Part II – System – Chapter 13 “Basic Networking” – section 13.6 “Configuring a Network Connection Manually”.
[HR][/HR]Assuming that, you’re using “wicked”, the routing needs to be setup in the ‘/etc/sysconfig/network/routes’ and ‘/etc/sysconfig/network/ifroute-*’ files. See section 13.6.2.7.
Assuming that, you’re using “wicked”, if you find that YaST is not setting up the static routes properly – you can only setup the static routes by manually editing the files mentioned above – please submit an openSUSE Bug Report – login is the same as the one you use to access this forum: <https://bugzilla.opensuse.org/>.
When using YaST,
You do not set up an ordinary static route for your Default Gateway.
Instead, the top 2 lines configure your Default Gateways, and you use the dropdowns to configure your DG IP address and device (actually the interface, not the device). Once set, they should be persistent across reboots (I’ve done this so know this should be the expected behavior).
I haven’t configured a route down below but it’s likely that you’d need to specify a flag in the “Options” to make the route persistent.
Which leads to the next concept…
By default and particularly in the command you used to set your Default Gateway, manually added routes are only effective during your current session (as you’ve discovered).
In the “old days” you had to add a flag to the “addroute” command to make the setting persistent across reboots.
Looks like nowadays the “ip add route” command has a “save” option which likely does the same.
I’m using wicked, otherwise you can not configure a routing table entry in yast, as I know.
After closing YaST-network configuration the static route was not established. Looking again into YaST, the entries for the route were there.
Then I modified the files you have mentioned by hand according to the syntax in section 13.6 and restarted the network with “systemctl restart network.service”. But with no luck.
So also the manual set up doesn´t work, although the “ip route add …” command works to establish the connection temporarily.
I do not want to configure a Default Gateway but an additional static route to a sum of other machines. On a computer with OpenSuSE Leap 42.1 I have configured this static route using YaST exactly the same way and it works.
I will try your tip with the “save” option for the “ip route add …” command.
It would be nice if yiu gave people something to chew on. Thus show commands like
ip route
and their output and not only tell stories about what you think you see.
BTW when you do an
ip route add ....
that is indeed only added to the routing table in the kernel. And that will be deleted when you stop the network (mostly at shutdown).
When you want a route added at network startup (mostly at boot) using wicked, it should be in /etc/sysconfig/network/routes. The easiest and least error prone way to put it there is IMHO by using YaST > Network Devices > Network Settings and then the tab Routing.
After all one of the more important reasons for choosing openSUSE is its nice system management tool YaST. Thus when running openSUSE, why not use it?
First,
It seems that what I stated earlier about enabling persistence in the “route add” command is what you would do on a Solaris or Windows machine, not Linux. In Linux, the routing table isn’t edited directly. For persistence, your routing rule is re-loaded and added to the routing table on each boot using sysconfig.
Did some testing. I verified the problem you are experiencing. I tested rules which defined remote networks as follows…
I used both the YaST tool and edited the files directly with same results…
Using the YaST module, if you leave the Device set to the dash (which means not defined), then the route is written to
/etc/sysconfig/network/routes
Using the YaST moule, if you specify a Device(eg eth0) then the route is written to
/etc/sysconfig/network/ifroutes-*devicename *
Although I don’t think should be necessary, for good measure I restarted the network service.
For both of the above, I created rules by both using YaST and then creating rules by editing the files directly, then ran the typical “display routing table command” as follows, but in both cases the static routes were not listed
route -n
ip route show
Then, to further test the routes, I executed traceroutes to Host addresses in the remote networks.
traceroute *ip_address*
Looks to me that static routes is broken completely.
Do you want to create the bug at https://bugzilla.opensuse.org ?
Looks to me that it is the documentation that is lacking actually. Based on the comments in this bug report every route which contains a gateway also needs a direct route (without gateway specified) first or it will be rejected by the kernel. For example, suppose I have eth1 assigned as 192.168.100.100/24. If I want to add the following routes
192.168.6.21 via 192.168.100.1 dev eth1
172.18.156.60 via 192.168.100.5 dev eth1
dean@linux-54cw:~> ip route
default via 192.168.1.1 dev wlan0 proto dhcp
172.18.156.60 via 192.168.100.5 dev eth1
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.8
192.168.6.21 via 192.168.100.1 dev eth1
192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.100
I’ll take a look at this more closely and set up a test network to verify…
But,
My initial impression is that for the typical scenario,
The system starts off with a routing table that is created automatically based on an existing NIC and its networking configuration including a DG.
That means that unless you assign an entirely new IP address in a different network range which is entirely unnecessary, defining a special route to the gateway address for a new static route should be entirely unnecessary because the new gateway would already be easily found within the supported address range in the existing routing table.
For now,
I did a quick search for relevant documentation in other distros and OS, and in no other case is there ever a requirement to define a route to the new static route gateway.
In all cases, all that is required is the <single> new static route rule, that’s all.
So, IMO this is not a documentation problem, it’s a real bug (based on your bugzilla reference).
Agreed. I must admit I find it strange that I needed to add the direct route first (in my above example), but I just tried this on another system (openSUSE 42.3 with a single NIC available), and found that it did indeed respect a static route added like this
ifroute-eth0
172.18.156.60 192.168.90.13 - eth0
# ip route
172.18.156.60 via 192.168.90.13 dev eth0
192.168.90.0/24 dev eth0 proto kernel scope link src 192.168.90.156
Working as expected. I’m not sure why that wasn’t the case with my other system though.
The only difference with testing on my first machine was that it has two interfaces (wireless and wired), and the wlan0 was configured to use DHCP, while I’d statically assigned eth1. I haven’t had time to experiment further, but I did wonder if perhaps there is a bug which manifested with this particular scenario. Maybe if both interfaces were statically configured, this would have behaved as expected?
Maybe I’ll update my test machine and try again… perhaps something will get pushed down that addresses this.
Strange, it’s working on the first machine now. I deleted my entire existing network configuration on my first laptop (with wired and wireless interfaces). Using my normal DHCP configuration on the wireless network interface, and a static configuration on the wired NIC. I added a single static route to ifroute-eth1
172.18.156.70 192.168.100.10
and then
ifdown eth1;ifup eth1
The static route was active without issue.
# ip route
default via 192.168.1.1 dev wlan0 proto dhcp
172.18.156.70 via 192.168.100.10 dev eth1
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.8
192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.100
tanks for your interest so far. But because I’m not really familiar with network set up, what do I have to do? What files of network configuration should I delete to set up a new working static route via YaST or by hand in the files routes or/and ifroute-eth0?
If you like, post your desired route and I’ll show you how to add it ifroute-eth0 directly. All that should be needed after that is to ifdown/ifup the device.
Using YaST->Network Configuration for wicked and set up a new static route.
YaST generates the file ifroute-eth0 with correct static route and an empty file routes.
ip route show
doesn´t show the defined static route
then
ifdown eth0; ifup eth0
results in
wicked: discarding route not matching any interface:
ipv4 192.XXX.XXX.XXX/24 via 172.XXX.XXX.XXX dev eth0
type unicast table main scope universe protocol boot eth0
setup-in-progress
adding the same static route by hand
ip route add 192.XXX.XXX.XXX/24 via 172.XXX.XXX.XXX dev eth0
ip route show
shows the defined static route and I can reach a machine in this network.
When you post computer actions in the terminal, you should copy/paste those complete: prompt, command, output, next prompt.
Story telling like
ip route show
doesn´t show the defined static route
is wrong because it has no prompts, no output and only your interpretation of facts we do not see.
And example of how it should be:
boven:~ # ip route show
default via 10.0.0.138 dev enp1s8
10.0.0.0/24 dev enp1s8 proto kernel scope link src 10.0.0.154
127.0.0.0/8 dev lo scope link
boven:~ #
Same for all the others.
YaST generates the file ifroute-eth0 with correct static route and an empty file routes.
That is only your conclusion, not the facts. There should be a
cat ifroute-eth0
Everything you do and see, but do not show to us creates confusion and misunderstanding. I also doubt al those XXX were really there.
We are not clairvoyant and we depend on what you show.