LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-09-2018, 10:01 PM   #1
scottmusician
Member
 
Registered: Jul 2011
Location: Melbourne, AU
Distribution: CentOS
Posts: 58

Rep: Reputation: Disabled
Question 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 ?
 
Old 09-10-2018, 01:04 AM   #2
Honest Abe
Member
 
Registered: May 2018
Distribution: CentOS 7, OpenSUSE 15
Posts: 420
Blog Entries: 1

Rep: Reputation: 202Reputation: 202Reputation: 202
Hi scottmusician,

Quote:
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]
Code:
/usr/lib/udev/rules.d/80-net-name-slot.rules 
/usr/lib/udev/rules.d/71-biosdevname.rules
/usr/lib/udev/rules.d/60-net.rules
And any udev rule you might have created or identified.

To understand the NIC interface naming convention & related troubleshooting - here
 
Old 09-10-2018, 01:54 AM   #3
scottmusician
Member
 
Registered: Jul 2011
Location: Melbourne, AU
Distribution: CentOS
Posts: 58

Original Poster
Rep: Reputation: Disabled
thanks for the reply!

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"
output of /usr/lib/udev/rules.d/60-net.rules:

Code:
ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="1", PROGRAM="/lib/udev/rename_device", RESULT=="?*", NAME="$result"
Hope that makes sense!

Last edited by scottmusician; 09-10-2018 at 02:50 AM.
 
Old 09-10-2018, 03:03 AM   #4
Honest Abe
Member
 
Registered: May 2018
Distribution: CentOS 7, OpenSUSE 15
Posts: 420
Blog Entries: 1

Rep: Reputation: 202Reputation: 202Reputation: 202
Code:
# 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"
Looks suspicious..

So please follow this to resolve.


A simpler example is here, if you are unsure on how to pass arguments at boot time.
 
Old 09-10-2018, 07:31 AM   #5
scottmusician
Member
 
Registered: Jul 2011
Location: Melbourne, AU
Distribution: CentOS
Posts: 58

Original Poster
Rep: Reputation: Disabled
so that might solve the device rename issue
but shouldn't I be able to see the route-wlo1 file's contents in the output listed from $ip route?

Last edited by scottmusician; 09-10-2018 at 05:16 PM.
 
Old 09-11-2018, 04:35 AM   #6
Honest Abe
Member
 
Registered: May 2018
Distribution: CentOS 7, OpenSUSE 15
Posts: 420
Blog Entries: 1

Rep: Reputation: 202Reputation: 202Reputation: 202
yes, baby steps

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.
 
  


Reply

Tags
ip, network, route, static, udev



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Centos 6 Kernel static Routes and OpenVPN blindrain Linux - Networking 0 07-29-2018 04:45 AM
Static Routes win_the_day_go_ducks Linux - Networking 3 09-25-2014 02:14 PM
problem in adding static routes in centos 6.5 adisoftronics Linux - Networking 2 04-05-2014 09:50 PM
permanent static routes on CentOS/Red Hat Enterprise Linux whistl Linux - Networking 4 03-24-2009 12:30 PM
Static routes using routes/ifroutes-eth-id.. files and default gateway disabled TimtheEagle Linux - Networking 0 05-31-2008 07:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration