static routes on CentOS 7 with udev inferface renames
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
static routes on CentOS 7 with udev inferface renames
Hi all,
I am currently studying for my LFCS, and I have a question about static routes.
I've currently been trying to set these up via the 'new file in /etc/sysconfig/network-scripts/route-interface ' method, but the routes don't seem to be taking.
More specifically:
- my udev seems to be pretty overreative, and almost always renames my interfaces (and external disks etc) on reboots - ie. /dev/sdb becomes /dev/sdc, and wlo0 becomes wlo1. I could create a route file called route-wlo0 , but what happens when udev drops this after a reboot because the interface has a new name?
is there another way of specifying the device name?
---
Also, will the route files be read and listed with $ip route ?
I've currently been trying to set these up via the 'new file in /etc/sysconfig/network-scripts/route-interface ' method, but the routes don't seem to be taking.
So you add a static route in the file and it doesn't show up in 'ip route show' or 'route -nee' outputs ? Does it remain same for a on-the-fly added dynamic route ? Please show examples of what you are doing and what is expected.
Quote:
- my udev seems to be pretty overreative, and almost always renames my interfaces (and external disks etc) on reboots - ie. /dev/sdb becomes /dev/sdc, and wlo0 becomes wlo1. I could create a route file called route-wlo0 , but what happens when udev drops this after a reboot because the interface has a new name?
Please post the udev rules for the following [Applicable for CentOS 7]
contents of /etc/sysconfig/network-scripts/route-wlo1 (which I created):
Code:
192.168.123.0/24 via 10.4.22.1 dev wlo1
output of #ip route:
Code:
default via 10.4.22.1 dev wlo1 proto static metric 600
10.4.22.0/19 dev wlo1 proto kernel scope link src 10.4.22.76 metric 600
I can add additional non-persistent routes when using ip route add:
Quote:
#ip route add 192.168.122.0/24 via 10.4.22.1
#ip route
default via 10.4.22.1 dev wlo1 proto static metric 600
10.4.22.0/19 dev wlo1 proto kernel scope link src 10.4.22.76 metric 600
192.168.122.0/24 via 10.4.22.1 dev wlo1
there's just no reporting of the (at least not in $ip route ). I have disabled/re-enabled my network adapter (
Code:
ifdown wlo1 ; ifup *
), and rebooted, but neither have made any difference.
---
output of /usr/lib/udev/rules.d/80-net-name-slot.rules:
Code:
# do not edit this file, it will be overwritten on update
ACTION!="add", GOTO="net_name_slot_end"
SUBSYSTEM!="net", GOTO="net_name_slot_end"
NAME!="", GOTO="net_name_slot_end"
IMPORT{cmdline}="net.ifnames"
ENV{net.ifnames}=="0", GOTO="net_name_slot_end"
NAME=="", ENV{ID_NET_NAME_ONBOARD}!="", NAME="$env{ID_NET_NAME_ONBOARD}"
NAME=="", ENV{ID_NET_NAME_SLOT}!="", NAME="$env{ID_NET_NAME_SLOT}"
NAME=="", ENV{ID_NET_NAME_PATH}!="", NAME="$env{ID_NET_NAME_PATH}"
LABEL="net_name_slot_end"
output of /usr/lib/udev/rules.d/71-biosdevname.rules:
Code:
# do not edit this file, it will be overwritten on update
ACTION!="add", GOTO="net_name_slot_end"
SUBSYSTEM!="net", GOTO="net_name_slot_end"
NAME!="", GOTO="net_name_slot_end"
IMPORT{cmdline}="net.ifnames"
ENV{net.ifnames}=="0", GOTO="net_name_slot_end"
NAME=="", ENV{ID_NET_NAME_ONBOARD}!="", NAME="$env{ID_NET_NAME_ONBOARD}"
NAME=="", ENV{ID_NET_NAME_SLOT}!="", NAME="$env{ID_NET_NAME_SLOT}"
NAME=="", ENV{ID_NET_NAME_PATH}!="", NAME="$env{ID_NET_NAME_PATH}"
LABEL="net_name_slot_end"
[root@centosia network-scripts]# cat /usr/lib/udev/rules.d/71-biosdevname.rules
SUBSYSTEM!="net", GOTO="netdevicename_end"
ACTION!="add", GOTO="netdevicename_end"
NAME=="?*", GOTO="netdevicename_end"
ATTR{type}!="1", GOTO="netdevicename_end"
ENV{DEVTYPE}=="?*", GOTO="netdevicename_end"
# whitelist all Dell systems
ATTR{[dmi/id]sys_vendor}=="Dell*", ENV{UDEV_BIOSDEVNAME}="1"
# kernel command line "biosdevname={0|1}" can turn off/on biosdevname
IMPORT{cmdline}="biosdevname"
ENV{biosdevname}=="?*", ENV{UDEV_BIOSDEVNAME}="$env{biosdevname}"
# ENV{UDEV_BIOSDEVNAME} can be used for blacklist/whitelist
# but will be overwritten by the kernel command line argument
ENV{UDEV_BIOSDEVNAME}=="0", GOTO="netdevicename_end"
ENV{UDEV_BIOSDEVNAME}=="1", GOTO="netdevicename_start"
# off by default
GOTO="netdevicename_end"
LABEL="netdevicename_start"
# using NAME= instead of setting INTERFACE_NAME, so that persistent
# names aren't generated for these devices, they are "named" on each boot.
SUBSYSTEMS=="pci", PROGRAM="/sbin/biosdevname --smbios 2.6 --nopirq --policy physical -i %k", NAME="%c" OPTIONS+="string_escape=replace"
LABEL="netdevicename_end"
[root@centosia network-scripts]#
[root@centosia network-scripts]# cat /usr/lib/udev/rules.d/71-biosdevname.rules
SUBSYSTEM!="net", GOTO="netdevicename_end"
ACTION!="add", GOTO="netdevicename_end"
NAME=="?*", GOTO="netdevicename_end"
ATTR{type}!="1", GOTO="netdevicename_end"
ENV{DEVTYPE}=="?*", GOTO="netdevicename_end"
# whitelist all Dell systems
ATTR{[dmi/id]sys_vendor}=="Dell*", ENV{UDEV_BIOSDEVNAME}="1"
# kernel command line "biosdevname={0|1}" can turn off/on biosdevname
IMPORT{cmdline}="biosdevname"
ENV{biosdevname}=="?*", ENV{UDEV_BIOSDEVNAME}="$env{biosdevname}"
# ENV{UDEV_BIOSDEVNAME} can be used for blacklist/whitelist
# but will be overwritten by the kernel command line argument
ENV{UDEV_BIOSDEVNAME}=="0", GOTO="netdevicename_end"
ENV{UDEV_BIOSDEVNAME}=="1", GOTO="netdevicename_start"
# off by default
GOTO="netdevicename_end"
LABEL="netdevicename_start"
# using NAME= instead of setting INTERFACE_NAME, so that persistent
# names aren't generated for these devices, they are "named" on each boot.
SUBSYSTEMS=="pci", PROGRAM="/sbin/biosdevname --smbios 2.6 --nopirq --policy physical -i %k", NAME="%c" OPTIONS+="string_escape=replace"
LABEL="netdevicename_end"
# using NAME= instead of setting INTERFACE_NAME, so that persistent
# names aren't generated for these devices, they are "named" on each boot.
SUBSYSTEMS=="pci", PROGRAM="/sbin/biosdevname --smbios 2.6 --nopirq --policy physical -i %k", NAME="%c" OPTIONS+="string_escape=replace"
Once the device rename stops, static route should work with route-NIC files.
Also, the steps you are taking (create file -> add route -> ifdown/ifup NICs) are what we used to do with network services. CentOS7 uses NetworkManager, so please try nmcli con down /nmcli con up for your connection too.
I'll admit that I still use ifdown-ifup and never saw this, but just ticking all boxes.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.