Network Setup Tips: Difference between revisions
(92 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
== NST Script: nstnetcfg == | == NST Script: nstnetcfg == | ||
See page: '''[[HowTo_Setup_A_Server_With_Multiple_Network_Interface_Adapters_Using:_"nstnetcfg" | HowTo Setup a Server With Multiple Network Interface Adapters Using: "nstnetcfg"]]''' for a simplified means of setting up networking on an NST system. | See page: '''[[HowTo_Setup_A_Server_With_Multiple_Network_Interface_Adapters_Using:_"nstnetcfg" | HowTo Setup a Server With Multiple Network Interface Adapters Using: "nstnetcfg"]]''' for a simplified and automatic means of setting up networking on an NST system. | ||
== Setting Up Dynamic DNS And DHCP == | |||
See this article will on how to setup '''DNS''' with dynamic updates as well as configuring your '''DHCP''' server: '''[http://www.semicomplete.com/articles/dynamic-dns-with-dhcp/ Dynamic DNS and DHCP]'''. | |||
<div class="centerBlock"><div class="noteMessage">Article correction on testing dynamic '''DNS''' updates with '''[https://en.wikipedia.org/wiki/Nsupdate nsupdate]''': | |||
% nsupdate | |||
> server dns.home | |||
> key dhcpupdate N8Hk2RUFO84bEVl3uGTD2A== | |||
> zone 0.168.192.in-addr.arpa | |||
> update add 50.0.168.192.in-addr.arpa 600 IN PTR happynode.home. | |||
> send | |||
> zone home | |||
> update add happynode.home. 600 IN A 192.168.0.50 | |||
> send | |||
</div></div> | |||
One can use the '''[https://www.nagios.com Nagios]''' plugin: "'''/usr/lib64/nagios/plugins/check_dhcp'''" to test your '''DHCP''' server. Below is the usage short help for '''check_dhcp''': | |||
<div class="screen"> | |||
<div class="userInput"><span class="prompt">[root@probe ~]# </span>/usr/lib64/nagios/plugins/check_dhcp -h;</div> | |||
<pre class="computerOutput"> | |||
check_dhcp v2.1.1 (nagios-plugins 2.1.1) | |||
Copyright (c) 2001-2004 Ethan Galstad (nagios@nagios.org) | |||
Copyright (c) 2001-2007 Nagios Plugin Development Team | |||
<devel@nagios-plugins.org> | |||
This plugin tests the availability of DHCP servers on a network. | |||
Usage: | |||
check_dhcp [-v] [-u] [-s serverip] [-r requestedip] [-t timeout] | |||
[-i interface] [-m mac] | |||
Options: | |||
-h, --help | |||
Print detailed help screen | |||
-V, --version | |||
Print version information | |||
--extra-opts=[section][@file] | |||
Read options from an ini file. See | |||
https://www.nagios-plugins.org/doc/extra-opts.html | |||
for usage and examples. | |||
-v, --verbose | |||
Show details for command-line debugging (Nagios may truncate output) | |||
-s, --serverip=IPADDRESS | |||
IP address of DHCP server that we must hear from | |||
-r, --requestedip=IPADDRESS | |||
IP address that should be offered by at least one DHCP server | |||
-t, --timeout=INTEGER | |||
Seconds to wait for DHCPOFFER before timeout occurs | |||
-i, --interface=STRING | |||
Interface to to use for listening (i.e. eth0) | |||
-m, --mac=STRING | |||
MAC address to use in the DHCP request | |||
-u, --unicast | |||
Unicast testing: mimic a DHCP relay, requires -s | |||
Send email to help@nagios-plugins.org if you have questions regarding use | |||
of this software. To submit patches or suggest improvements, send email to | |||
devel@nagios-plugins.org | |||
</pre> | |||
</div> | |||
| |||
== Accessing Network Configuration Files == | == Accessing Network Configuration Files == | ||
Line 89: | Line 153: | ||
<pre class="programListing"> | <pre class="programListing"> | ||
NAME=eth0 | |||
HWADDR=30:85:a9:44:24:44 | |||
TYPE=Ethernet | |||
BOOTPROTO=static | BOOTPROTO=static | ||
IPADDR=192.168.12.100 | IPADDR=192.168.12.100 | ||
Line 97: | Line 163: | ||
GATEWAY=192.168.12.1 | GATEWAY=192.168.12.1 | ||
ONBOOT=yes | ONBOOT=yes | ||
NM_CONTROLLED=no | |||
</pre> | </pre> | ||
<div class="centerBlock"><div class="noteMessage">'''Note 1:''' The above assumes that the gateway machine for the network has an '''IP''' address of: "'''192.168.12.1'''" on network: "'''192.168.12.0/24'''".<br/><br />'''Note 2:''' Make sure the '''NetworkManager'''" service is disabled: '''systemctl disable NetworkManager.service;'''<br /><br />'''Note 3:''' Make sure the "'''network'''" service is enabled: '''systemctl enable network.service;''' | <div class="centerBlock"><div class="noteMessage">'''Note 1:''' The above assumes that the gateway machine for the network has an '''IP''' address of: "'''192.168.12.1'''" on network: "'''192.168.12.0/24'''".<br/><br />'''Note 2:''' Make sure the '''NetworkManager'''" service is disabled: '''systemctl disable NetworkManager.service;'''<br /><br />'''Note 3:''' Make sure the "'''network'''" service is enabled: '''systemctl enable network.service;'''<br /><br />'''Note 3:''' Make sure the '''MAC Address (HWADDR)''' is correct for the Network Interface you are configuring. | ||
</div></div> | </div></div> | ||
Line 109: | Line 176: | ||
<pre class="programListing"> | <pre class="programListing"> | ||
NAME=eth1 | |||
HWADDR=30:85:a9:43:25:22 | |||
TYPE=Ethernet | |||
BOOTPROTO=none | BOOTPROTO=none | ||
ONBOOT=yes | ONBOOT=yes | ||
NM_CONTROLLED=no | |||
</pre> | </pre> | ||
Line 161: | Line 231: | ||
| | ||
== | == IPv4 Aliasing (IP Alias or Multi-Net) == | ||
=== Overview === | === Overview === | ||
An '''[http://www.faqs.org/docs/Linux-mini/IP-Alias.html IP Alias]''' allows you to configure multiple ''' | An '''[http://www.faqs.org/docs/Linux-mini/IP-Alias.html IP Alias]''' allows you to configure multiple '''IPv4 Addresses''' onto a physical device ('''NIC'''). '''IPv4 Aliasing''' is known as network layer virtual hosting. It is common to use an '''IPv4 Aliases''' with '''[http://httpd.apache.org/docs/2.0/vhosts/ Apache Virtual Hosting]'''. | ||
=== HowTo Add An | See this page: "'''[http://pic.dhe.ibm.com/infocenter/rpthelp/v8r0m0/index.jsp?topic=%2Fcom.ibm.rational.test.lt.doc%2Ftopics%2Ftconfigip_linux.html Configuring IP aliases for a remote Linux location]'''" when using the '''[http://en.wikipedia.org/wiki/Iproute2 ip]''' utility to configure an '''IPv4 Alias Address'''. | ||
<div class="centerBlock"><div class="noteMessage">'''Note:''' One can also use the '''NST''' script: "'''[http://nst.sourceforge.net/nst/docs/scripts/nstnetcfg.html nstnetcfg]'''" to [[HowTo_Setup_A_Server_With_Multiple_Network_Interface_Adapters_Using:_%22nstnetcfg%22#Managing_IPv4_Alias_Addresses | Manage IPv4 Alias Addresses]]. | |||
</div></div> | |||
=== HowTo Manually Add An IPv4 Alias === | |||
<div class="screen"> | <div class="screen"> | ||
<div class="screenTitle"> | <div class="screenTitle">IPv4 Alias Add Example: (NIC: p5p1, Alias: p5p1:0)</div> | ||
<div class="userInput"><span class="prompt">[root@shopper2 ~]# </span>ifconfig</div> | <div class="userInput"><span class="prompt">[root@shopper2 ~]# </span>ifconfig</div> | ||
<pre class="computerOutput"> | <pre class="computerOutput"> | ||
Line 219: | Line 294: | ||
</div> | </div> | ||
The ''' | The '''IPv4 Alias''' command above produced a virtual host address for the '''p5p1''' network interface using IPv4 Address: "'''10.222.222.83'''". '''IPv4 Aliases''' are referred to by appending "''':n'''" to the actual network interface device, in which "'''n'''" is an integer. In our example, we created the '''IPv4 Alias''' on NIC: "'''p5p1'''" , with alias number "'''Zero (0)'''". | ||
All network statistics associated with each ''' | All network statistics associated with each '''IPv4 Alias''' interface are combined with the physical network interface. To get individual statistics for an '''IPv4 Aliased Interface''' then accounting rules would need to be used through the [http://en.wikipedia.org/wiki/Iptables iptables] command. | ||
=== HowTo Remove An | === HowTo Remove An IPv4 Alias === | ||
To remove an ''' | To remove an '''IPv4 Alias''' use the '''ifconfig''' command "'''down'''" option: | ||
<div class="screen"> | <div class="screen"> | ||
Line 234: | Line 309: | ||
| | ||
=== HowTo Permanently Add An | === HowTo Permanently Add An IPv4 Alias === | ||
This procedure uses the "'''network'''" service. The following shows the contents of file: "'''/etc/sysconfig/network-scripts/ifcfg-p5p1:0'''" which is used to assign a static ''' | This procedure uses the "'''network'''" service. The following shows the contents of file: "'''/etc/sysconfig/network-scripts/ifcfg-p5p1:0'''" which is used to assign a static '''IPv4 Alias''' address of: "'''10.222.222.83'''" to network interface: "'''p5p1:0'''" | ||
<pre class="programListing"> | <pre class="programListing"> | ||
NAME=p5p1:0 | |||
HWADDR=E0:69:95:B1:6E:BF | |||
TYPE=Ethernet | |||
DEFROUTE=yes | |||
PEERDNS=yes | |||
PEERROUTES=yes | |||
IPV4_FAILURE_FATAL=no | |||
BOOTPROTO=static | BOOTPROTO=static | ||
IPADDR=10.222.222.83 | IPADDR=10.222.222.83 | ||
Line 246: | Line 327: | ||
GATEWAY=10.222.222.1 | GATEWAY=10.222.222.1 | ||
ONBOOT=yes | ONBOOT=yes | ||
NM_CONTROLLED=no | |||
</pre> | </pre> | ||
<div class="centerBlock"><div class="noteMessage">'''Note 1:''' The above assumes that the gateway machine for the network has an ''' | <div class="centerBlock"><div class="noteMessage">'''Note 1:''' The above assumes that the gateway machine for the network has an '''IPv4''' address of: "'''10.222.222.1'''" on network: "'''10.222.222.0/24'''".<br/><br />'''Note 2:''' Make sure the '''NetworkManager'''" service is disabled: '''systemctl disable NetworkManager.service;'''<br /><br />'''Note 3:''' Make sure the "'''network'''" service is enabled: '''systemctl enable network.service;''' | ||
</div></div> | </div></div> | ||
== '''Create Predictable Network Interface Names''' == | |||
Some information in this section was derived from the sites: '''[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/ freedesktop.org]''' and '''[http://www.linuxfromscratch.org/blfs/view/development/chapter07/network.html Creating stable names for network interfaces on Linux]''' | |||
== ''' | <div class="centerBlock"><div class="noteMessage">'''Note:''' One can also use the '''NST''' script: "'''[http://nst.sourceforge.net/nst/docs/scripts/nstnetcfg.html nstnetcfg]'''" to [[HowTo_Setup_A_Server_With_Multiple_Network_Interface_Adapters_Using:_%22nstnetcfg%22#Renaming_A_Network_Interface_Device | Rename A Network Interface Device]]. | ||
</div></div> | |||
=== Overview === | === Overview === | ||
Starting with v197 systemd/udev will automatically assign predictable, stable network interface names for all local Ethernet, WLAN and WWAN interfaces. This is a departure from the traditional interface naming scheme ("eth0", "eth1", "wlan0", ...), but should fix real problems. | Starting with v197 systemd/udev will automatically assign predictable, stable network interface names for all local Ethernet, WLAN and WWAN interfaces. This is a departure from the traditional interface naming scheme ("eth0", "eth1", "wlan0", ...), but should fix real problems. The classic naming scheme for network interfaces applied by the kernel is to simply assign names beginning with "eth0", "eth1", ... to all interfaces as they are probed by the drivers. As the driver probing is generally not predictable for modern technology this means that as soon as multiple network interfaces are available the assignment of the names "eth0", "eth1" and so on is generally not fixed anymore and it might very well happen that "eth0" on one boot ends up being "eth1" on the next. This can have serious security implications, for example in firewall rules which are coded for certain naming schemes, and which are hence very sensitive to unpredictable changing names. | ||
With systemd 197 we have added native support for a number of different naming policies into systemd/udevd proper and made a scheme similar to biosdevname's (but generally more powerful, and closer to kernel-internal device identification schemes) the default. The following different naming schemes for network interfaces are now supported by udev natively: | With systemd 197 we have added native support for a number of different naming policies into systemd/udevd proper and made a scheme similar to biosdevname's (but generally more powerful, and closer to kernel-internal device identification schemes) the default. The following different naming schemes for network interfaces are now supported by udev natively: | ||
# Names incorporating Firmware/BIOS provided index numbers for on-board devices (example: eno1) | |||
# Names incorporating Firmware/BIOS provided PCI Express hotplug slot index numbers (example: ens1) | |||
# Names incorporating physical/geographical location of the connector of the hardware (example: enp2s0) | |||
# Names incorporating the interfaces's MAC address (example: enx78e7d1ea46da) | |||
# Classic, unpredictable kernel-native ethX naming (example: eth0) | |||
By default, systemd v197 will now name interfaces following policy 1) if that information from the firmware is applicable and available, falling back to 2) if that information from the firmware is applicable and available, falling back to 3) if applicable, falling back to 5) in all other cases. Policy 4) is not used by default, but is available if the user chooses so. | By default, systemd v197 will now name interfaces following policy 1) if that information from the firmware is applicable and available, falling back to 2) if that information from the firmware is applicable and available, falling back to 3) if applicable, falling back to 5) in all other cases. Policy 4) is not used by default, but is available if the user chooses so. | ||
This combined policy is only applied as last resort. That means, if the system has biosdevname installed, it will take precedence. If the user has added udev rules which change the name of the kernel devices these will take precedence too. Also, any distribution specific naming schemes generally take precedence. | This combined policy is only applied as last resort. That means, if the system has biosdevname installed, it will take precedence. If the user has added udev rules which change the name of the kernel devices these will take precedence too. Also, any distribution specific naming schemes generally take precedence. | ||
The naming convention is documented in detail in a comment block for source code file: "'''[http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20 udev-builtin-net_id.c]'''". Please refer to document in case you are wondering how to decode the new interface names. | |||
<div class="centerBlock"><div class="noteMessage">'''Note:''' If you see network names like '''p1p1''', '''p5p1''', '''p5p2''', etc... these are "'''biosdevnames'''". The udev rules file: "'''/usr/lib/udev/rules.d/71-biosdevname.rules'''" will process them. One can turn off "'''biosdevnames'''" network interface name renaming using the following Kernel command line parameter: | |||
biosdevname=0 | |||
If you do this the naming convention described above will be used. | |||
To disable both the "'''biosdevnames'''" renaming and the "'''udev'''" renaming so that the original Kernel "'''ethx'''" (e.g., eth0) networking interface naming is used, which may be unpredictable, the use the following Kernel command line parameters: | |||
biosdevname=0 net.ifnames=0 | |||
</div></div> | |||
=== Ways To Alter The Network Interface Names === | |||
You basically have four options: | |||
# You disable the assignment of fixed names, so that the unpredictable kernel names are used again. For this, simply mask udev's rule file for the default policy: ''ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules'' | |||
# You create your own manual naming scheme, for example by naming your interfaces "internet0", "dmz0" or "lan0". For that create your own udev rules file and set the NAME property for the devices. Make sure to order it before the default policy file, for example by naming it ''/etc/udev/rules.d/70-my-net-names.rules'' | |||
# You alter the default policy file, for picking a different naming scheme, for example for naming all interface names after their MAC address by default: ''cp /usr/lib/udev/rules.d/80-net-name-slot.rules /etc/udev/rules.d/80-net-name-slot.rules'', then edit the file there and change the lines as necessary. | |||
# You pass the ''net.ifnames=0'' on the kernel command line (since v199) | |||
==== Example: Want to Shorten the Network Interface Name: eno16777736 To eno1 ==== | |||
Here is an example on how to change the network interface name: "'''eno16777736'''" to "'''eno1'''". | |||
Before Interface Name Change: | |||
[root@localhost network-scripts]# ip addr show | |||
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default | |||
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | |||
inet 127.0.0.1/8 scope host lo | |||
valid_lft forever preferred_lft forever | |||
inet6 ::1/128 scope host | |||
valid_lft forever preferred_lft forever | |||
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 | |||
link/ether 00:0c:29:d2:af:fc brd ff:ff:ff:ff:ff:ff | |||
inet 10.222.222.116/24 brd 10.222.222.255 scope global dynamic eno1 | |||
valid_lft 54243sec preferred_lft 54243sec | |||
inet6 fe80::20c:29ff:fed2:affc/64 scope link | |||
valid_lft forever preferred_lft forever | |||
We will use the '''Bus''' position as the key to identify the network interface name to change for the udev rule. Here is a way to find the '''Bus''' position: | |||
for dir in /sys/class/net/* ; do | |||
[ -e $dir/device ] && { | |||
basename $dir ; readlink -f $dir/device | |||
} | |||
done | |||
Results: | |||
eno16777736 | |||
/sys/devices/pci0000:00/0000:00:15.0/0000:03:00.0 | |||
Use the '''udevadm''' utility to list all udev environment variables for this network device (eno16777736): | |||
udevadm info /sys/class/net/eno16777736 | |||
P: /devices/pci0000:00/0000:00:15.0/0000:03:00.0/net/eno16777736 | |||
E: DEVPATH=/devices/pci0000:00/0000:00:15.0/0000:03:00.0/net/eno16777736 | |||
E: ID_BUS=pci | |||
E: ID_MM_CANDIDATE=1 | |||
E: ID_MODEL_FROM_DATABASE=VMXNET3 Ethernet Controller | |||
E: ID_MODEL_ID=0x07b0 | |||
E: ID_NET_LABEL_ONBOARD=enEthernet0 | |||
E: ID_NET_NAME_MAC=enx000c29d2affc | |||
E: ID_NET_NAME_ONBOARD=eno16777736 | |||
E: ID_NET_NAME_PATH=enp3s0 | |||
E: ID_NET_NAME_SLOT=ens160 | |||
E: ID_OUI_FROM_DATABASE=VMware, Inc. | |||
E: ID_PCI_CLASS_FROM_DATABASE=Network controller | |||
E: ID_PCI_SUBCLASS_FROM_DATABASE=Ethernet controller | |||
E: ID_VENDOR_FROM_DATABASE=VMware | |||
E: ID_VENDOR_ID=0x15ad | |||
E: IFINDEX=2 | |||
E: INTERFACE=eno16777736 | |||
E: SUBSYSTEM=net | |||
E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/eno16777736 | |||
E: TAGS=:systemd: | |||
E: USEC_INITIALIZED=30960 | |||
From the results we will now create a custom udev rules file: "'''/etc/udev/rules.d/79-my-net-name-slot.rules'''" to shorten the long network interface name to: "'''eno1'''": | |||
cat /etc/udev/rules.d/79-my-net-name-slot.rules; | |||
ACTION=="add", SUBSYSTEM=="net", ENV{ID_BUS}=="pci", KERNELS=="0000:03:00.0", NAME="eno1" | |||
<div class="centerBlock"><div class="noteMessage">This is the udev rules file: "'''/etc/udev/rules.d/79-my-net-name-slot.rules'''" to shorten the long network interface name to: "'''eno1'''" using the '''MAC Address''': | |||
cat /etc/udev/rules.d/79-my-net-name-slot.rules; | |||
ACTION=="add", SUBSYSTEM=="net", ENV{ID_NET_NAME_MAC}=="enx000c29d2affc", NAME="eno1" | |||
- OR - | |||
cat /etc/udev/rules.d/79-my-net-name-slot.rules; | |||
ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="00:0c:29:d2:af:fc", NAME="eno1" | |||
</div></div> | |||
Files in "'''/etc/udev/rules.d/'''" are parsed in lexical order, and in some circumstances, the order in which rules are parsed is important. In general, you want your own rules to be parsed before the defaults. Therefore the udev rules file: "'''/etc/udev/rules.d/79-my-net-name-slot.rules'''" will be parsed before the default network udev rules file: "'''/usr/lib/udev/rules.d/80-net-name-slot.rules'''". | |||
One can learn about writing udev rules files at the site: "'''[http://www.reactivated.net/writing_udev_rules.html reactivated.net - Writing udev Rules]'''". | |||
One can now reboot the NST system for the interface name change to take effect: | |||
After Interface Name Change: | |||
[root@localhost network-scripts]# ip addr show | |||
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default | |||
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | |||
inet 127.0.0.1/8 scope host lo | |||
valid_lft forever preferred_lft forever | |||
inet6 ::1/128 scope host | |||
valid_lft forever preferred_lft forever | |||
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 | |||
link/ether 00:0c:29:d2:af:fc brd ff:ff:ff:ff:ff:ff | |||
inet 10.222.222.116/24 brd 10.222.222.255 scope global dynamic eno1 | |||
valid_lft 54243sec preferred_lft 54243sec | |||
inet6 fe80::20c:29ff:fed2:affc/64 scope link | |||
valid_lft forever preferred_lft forever | |||
''' | |||
The '''udevadm''' utility now reveals the following for network device: "'''eno1'''" | |||
udevadm info /sys/class/net/eno1 | |||
P: /devices/pci0000:00/0000:00:15.0/0000:03:00.0/net/eno1 | |||
E: DEVPATH=/devices/pci0000:00/0000:00:15.0/0000:03:00.0/net/eno1 | |||
E: ID_BUS=pci | |||
E: ID_MM_CANDIDATE=1 | |||
E: ID_MODEL_FROM_DATABASE=VMXNET3 Ethernet Controller | |||
E: ID_MODEL_ID=0x07b0 | |||
E: ID_NET_LABEL_ONBOARD=enEthernet0 | |||
E: ID_NET_NAME_MAC=enx000c29d2affc | |||
E: ID_NET_NAME_ONBOARD=eno16777736 | |||
E: ID_NET_NAME_PATH=enp3s0 | |||
E: ID_NET_NAME_SLOT=ens160 | |||
E: ID_OUI_FROM_DATABASE=VMware, Inc. | |||
E: ID_PCI_CLASS_FROM_DATABASE=Network controller | |||
E: ID_PCI_SUBCLASS_FROM_DATABASE=Ethernet controller | |||
E: ID_VENDOR_FROM_DATABASE=VMware | |||
E: ID_VENDOR_ID=0x15ad | |||
E: IFINDEX=2 | |||
E: INTERFACE=eno1 | |||
E: SUBSYSTEM=net | |||
E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/eno1 | |||
E: TAGS=:systemd: | |||
E: USEC_INITIALIZED=30960 | |||
==== HowTo Debug A udev Rules File ==== | |||
One can use the "''udevadm test <devpath>''" command to verify, detect any errors and debug your udev rules file. The "''<devpath>''" is the "'''/sys'''" path of the device to query. Below is an example for our network interface device: "'''eno1'''" | |||
udevadm test /sys/class/net/eno1 | |||
calling: test | |||
version 208 | |||
This program is for debugging only, it does not run any program | |||
specified by a RUN key. It may show incorrect results, because | |||
some values may be different, or not available at a simulation run. | |||
=== trie on-disk === | |||
tool version: 208 | |||
file size: 5913667 bytes | |||
header size 80 bytes | |||
strings 1299963 bytes | |||
nodes 4613624 bytes | |||
load module index | |||
read rules file: /usr/lib/udev/rules.d/10-dm.rules | |||
read rules file: /usr/lib/udev/rules.d/11-dm-lvm.rules | |||
read rules file: /usr/lib/udev/rules.d/13-dm-disk.rules | |||
read rules file: /usr/lib/udev/rules.d/40-libgphoto2.rules | |||
IMPORT found builtin 'usb_id --export %%p', replacing /usr/lib/udev/rules.d/40-libgphoto2.rules:11 | |||
read rules file: /usr/lib/udev/rules.d/40-usb-media-players.rules | |||
read rules file: /usr/lib/udev/rules.d/40-usb_modeswitch.rules | |||
read rules file: /usr/lib/udev/rules.d/42-usb-hid-pm.rules | |||
read rules file: /usr/lib/udev/rules.d/50-udev-default.rules | |||
read rules file: /usr/lib/udev/rules.d/56-hpmud.rules | |||
read rules file: /usr/lib/udev/rules.d/60-cdrom_id.rules | |||
read rules file: /usr/lib/udev/rules.d/60-drm.rules | |||
read rules file: /usr/lib/udev/rules.d/60-fprint-autosuspend.rules | |||
read rules file: /usr/lib/udev/rules.d/60-keyboard.rules | |||
read rules file: /usr/lib/udev/rules.d/60-net.rules | |||
read rules file: /usr/lib/udev/rules.d/60-pcmcia.rules | |||
read rules file: /usr/lib/udev/rules.d/60-persistent-alsa.rules | |||
read rules file: /usr/lib/udev/rules.d/60-persistent-input.rules | |||
read rules file: /usr/lib/udev/rules.d/60-persistent-serial.rules | |||
read rules file: /usr/lib/udev/rules.d/60-persistent-storage-tape.rules | |||
read rules file: /usr/lib/udev/rules.d/60-persistent-storage.rules | |||
read rules file: /usr/lib/udev/rules.d/60-persistent-v4l.rules | |||
read rules file: /usr/lib/udev/rules.d/60-raw.rules | |||
read rules file: /usr/lib/udev/rules.d/61-accelerometer.rules | |||
read rules file: /usr/lib/udev/rules.d/61-gnome-bluetooth-rfkill.rules | |||
read rules file: /usr/lib/udev/rules.d/62-multipath.rules | |||
read rules file: /usr/lib/udev/rules.d/63-md-raid-arrays.rules | |||
read rules file: /usr/lib/udev/rules.d/64-btrfs.rules | |||
read rules file: /usr/lib/udev/rules.d/64-md-raid-assembly.rules | |||
read rules file: /usr/lib/udev/rules.d/65-libwacom.rules | |||
read rules file: /usr/lib/udev/rules.d/65-md-incremental.rules | |||
read rules file: /usr/lib/udev/rules.d/65-sane-backends.rules | |||
read rules file: /usr/lib/udev/rules.d/69-cd-sensors.rules | |||
read rules file: /usr/lib/udev/rules.d/69-dm-lvm-metad.rules | |||
read rules file: /usr/lib/udev/rules.d/69-libmtp.rules | |||
read rules file: /usr/lib/udev/rules.d/69-xorg-vmmouse.rules | |||
read rules file: /usr/lib/udev/rules.d/70-power-switch.rules | |||
read rules file: /usr/lib/udev/rules.d/70-printers.rules | |||
read rules file: /usr/lib/udev/rules.d/70-spice-vdagentd.rules | |||
read rules file: /usr/lib/udev/rules.d/70-touchpad-quirks.rules | |||
read rules file: /usr/lib/udev/rules.d/70-uaccess.rules | |||
read rules file: /usr/lib/udev/rules.d/70-wacom.rules | |||
read rules file: /usr/lib/udev/rules.d/71-biosdevname.rules | |||
read rules file: /usr/lib/udev/rules.d/71-seat.rules | |||
read rules file: /usr/lib/udev/rules.d/73-seat-late.rules | |||
read rules file: /usr/lib/udev/rules.d/75-net-description.rules | |||
read rules file: /usr/lib/udev/rules.d/75-probe_mtd.rules | |||
read rules file: /usr/lib/udev/rules.d/75-tty-description.rules | |||
read rules file: /usr/lib/udev/rules.d/77-mm-ericsson-mbm.rules | |||
read rules file: /usr/lib/udev/rules.d/77-mm-huawei-net-port-types.rules | |||
read rules file: /usr/lib/udev/rules.d/77-mm-longcheer-port-types.rules | |||
read rules file: /usr/lib/udev/rules.d/77-mm-nokia-port-types.rules | |||
read rules file: /usr/lib/udev/rules.d/77-mm-pcmcia-device-blacklist.rules | |||
read rules file: /usr/lib/udev/rules.d/77-mm-platform-serial-whitelist.rules | |||
read rules file: /usr/lib/udev/rules.d/77-mm-simtech-port-types.rules | |||
read rules file: /usr/lib/udev/rules.d/77-mm-telit-port-types.rules | |||
read rules file: /usr/lib/udev/rules.d/77-mm-usb-device-blacklist.rules | |||
read rules file: /usr/lib/udev/rules.d/77-mm-usb-serial-adapters-greylist.rules | |||
read rules file: /usr/lib/udev/rules.d/77-mm-x22x-port-types.rules | |||
read rules file: /usr/lib/udev/rules.d/77-mm-zte-port-types.rules | |||
read rules file: /usr/lib/udev/rules.d/77-nm-olpc-mesh.rules | |||
read rules file: /usr/lib/udev/rules.d/78-sound-card.rules | |||
'''''read rules file: /etc/udev/rules.d/79-my-net-name-slot.rules''''' | |||
read rules file: /usr/lib/udev/rules.d/80-drivers.rules | |||
read rules file: /usr/lib/udev/rules.d/80-mm-candidate.rules | |||
read rules file: /usr/lib/udev/rules.d/80-net-name-slot.rules | |||
read rules file: /usr/lib/udev/rules.d/80-udisks2.rules | |||
read rules file: /usr/lib/udev/rules.d/85-regulatory.rules | |||
read rules file: /usr/lib/udev/rules.d/85-usbmuxd.rules | |||
read rules file: /usr/lib/udev/rules.d/90-alsa-restore.rules | |||
read rules file: /usr/lib/udev/rules.d/90-alsa-tools-firmware.rules | |||
read rules file: /usr/lib/udev/rules.d/90-libgpod.rules | |||
read rules file: /usr/lib/udev/rules.d/90-pulseaudio.rules | |||
read rules file: /usr/lib/udev/rules.d/91-drm-modeset.rules | |||
read rules file: /usr/lib/udev/rules.d/95-cd-devices.rules | |||
read rules file: /usr/lib/udev/rules.d/95-dm-notify.rules | |||
read rules file: /usr/lib/udev/rules.d/95-udev-late.rules | |||
read rules file: /usr/lib/udev/rules.d/95-upower-battery-recall-dell.rules | |||
read rules file: /usr/lib/udev/rules.d/95-upower-battery-recall-fujitsu.rules | |||
read rules file: /usr/lib/udev/rules.d/95-upower-battery-recall-gateway.rules | |||
read rules file: /usr/lib/udev/rules.d/95-upower-battery-recall-ibm.rules | |||
read rules file: /usr/lib/udev/rules.d/95-upower-battery-recall-lenovo.rules | |||
read rules file: /usr/lib/udev/rules.d/95-upower-battery-recall-toshiba.rules | |||
read rules file: /usr/lib/udev/rules.d/95-upower-csr.rules | |||
read rules file: /usr/lib/udev/rules.d/95-upower-hid.rules | |||
read rules file: /usr/lib/udev/rules.d/95-upower-wup.rules | |||
read rules file: /etc/udev/rules.d/98-kexec.rules | |||
read rules file: /usr/lib/udev/rules.d/99-qemu-guest-agent.rules | |||
read rules file: /usr/lib/udev/rules.d/99-systemd.rules | |||
rules contain 393216 bytes tokens (32768 * 12 bytes), 37195 bytes strings | |||
30305 strings (254465 bytes), 26909 de-duplicated (220667 bytes), 3397 trie nodes used | |||
PROGRAM '/lib/udev/rename_device' /usr/lib/udev/rules.d/60-net.rules:1 | |||
starting '/lib/udev/rename_device' | |||
'/lib/udev/rename_device' [2664] exit with return code 0 | |||
PROGRAM '/sbin/biosdevname --policy physical -i eno1' /usr/lib/udev/rules.d/71-biosdevname.rules:22 | |||
starting '/sbin/biosdevname --policy physical -i eno1' | |||
'/sbin/biosdevname --policy physical -i eno1' [2665] exit with return code 4 | |||
IMPORT builtin 'net_id' /usr/lib/udev/rules.d/75-net-description.rules:6 | |||
IMPORT builtin 'hwdb' /usr/lib/udev/rules.d/75-net-description.rules:12 | |||
'''''NAME 'eno1' /etc/udev/rules.d/79-my-net-name-slot.rules:2''''' | |||
RUN '/usr/lib/systemd/systemd-sysctl --prefix=/proc/sys/net/ipv4/conf/$name --prefix=/proc/sys/net/ipv4/neigh/$name --prefix=/proc/sys/net/ipv6/conf/$name -- prefix=/proc/sys/net/ipv6/neigh/$name' /usr/lib/udev/rules.d/99-systemd.rules:52 | |||
ACTION=add | |||
DEVPATH=/devices/pci0000:00/0000:00:15.0/0000:03:00.0/net/eno1 | |||
ID_BUS=pci | |||
ID_MM_CANDIDATE=1 | |||
ID_MODEL_FROM_DATABASE=VMXNET3 Ethernet Controller | |||
ID_MODEL_ID=0x07b0 | |||
ID_NET_LABEL_ONBOARD=enEthernet0 | |||
ID_NET_NAME_MAC=enx000c29d2affc | |||
ID_NET_NAME_ONBOARD=eno16777984 | |||
ID_NET_NAME_PATH=enp3s0 | |||
ID_NET_NAME_SLOT=ens160 | |||
ID_OUI_FROM_DATABASE=VMware, Inc. | |||
ID_PCI_CLASS_FROM_DATABASE=Network controller | |||
ID_PCI_SUBCLASS_FROM_DATABASE=Ethernet controller | |||
ID_VENDOR_FROM_DATABASE=VMware | |||
ID_VENDOR_ID=0x15ad | |||
IFINDEX=2 | |||
INTERFACE=eno1 | |||
SUBSYSTEM=net | |||
SYSTEMD_ALIAS=/sys/subsystem/net/devices/eno1 | |||
TAGS=:systemd: | |||
USEC_INITIALIZED=30960 | |||
run: '/usr/lib/systemd/systemd-sysctl --prefix=/proc/sys/net/ipv4/conf/eno1 --prefix=/proc/sys/net/ipv4/neigh/eno1 --prefix=/proc/sys/net/ipv6/conf/eno1 --prefix=/proc/sys/net/ipv6/neigh/eno1' | |||
unload module index | |||
This command will verify the correct syntax for each udev rules file and also show the order in which each rules file is processed. If a syntax error had occurred, it would be shown for the offending file. Most likely any errors that occurred would be associated with our custom udev rules file. | |||
The custom udev rules file: "'''/etc/udev/rules.d/79-my-net-name-slot.rules'''" is in '''''Italic Bold''''' text above and is also shown as the udev rules file that was responsible for the network interface rename from '''eth0''' to '''eno1'''. | |||
From '''dmesg''' we see when the actual udev rule was used to rename the network interface during the system boot process: | |||
[ 4.526042] systemd-udevd[419]: renamed network interface eth0 to eno1 |
Latest revision as of 07:06, 1 November 2016
NST Script: nstnetcfg
See page: HowTo Setup a Server With Multiple Network Interface Adapters Using: "nstnetcfg" for a simplified and automatic means of setting up networking on an NST system.
Setting Up Dynamic DNS And DHCP
See this article will on how to setup DNS with dynamic updates as well as configuring your DHCP server: Dynamic DNS and DHCP.
% nsupdate > server dns.home > key dhcpupdate N8Hk2RUFO84bEVl3uGTD2A== > zone 0.168.192.in-addr.arpa > update add 50.0.168.192.in-addr.arpa 600 IN PTR happynode.home. > send > zone home > update add happynode.home. 600 IN A 192.168.0.50 > send
One can use the Nagios plugin: "/usr/lib64/nagios/plugins/check_dhcp" to test your DHCP server. Below is the usage short help for check_dhcp:
check_dhcp v2.1.1 (nagios-plugins 2.1.1) Copyright (c) 2001-2004 Ethan Galstad (nagios@nagios.org) Copyright (c) 2001-2007 Nagios Plugin Development Team <devel@nagios-plugins.org> This plugin tests the availability of DHCP servers on a network. Usage: check_dhcp [-v] [-u] [-s serverip] [-r requestedip] [-t timeout] [-i interface] [-m mac] Options: -h, --help Print detailed help screen -V, --version Print version information --extra-opts=[section][@file] Read options from an ini file. See https://www.nagios-plugins.org/doc/extra-opts.html for usage and examples. -v, --verbose Show details for command-line debugging (Nagios may truncate output) -s, --serverip=IPADDRESS IP address of DHCP server that we must hear from -r, --requestedip=IPADDRESS IP address that should be offered by at least one DHCP server -t, --timeout=INTEGER Seconds to wait for DHCPOFFER before timeout occurs -i, --interface=STRING Interface to to use for listening (i.e. eth0) -m, --mac=STRING MAC address to use in the DHCP request -u, --unicast Unicast testing: mimic a DHCP relay, requires -s Send email to help@nagios-plugins.org if you have questions regarding use of this software. To submit patches or suggest improvements, send email to devel@nagios-plugins.org
Accessing Network Configuration Files
To easily access the network configuration files, simply use the bash alias: "cdnet":
[root@probe network-scripts]#
/etc/sysconfig/network-scripts [root@probe network-scripts]#
NST Script: nstnetcfg
HowTo_Setup_A_Server_With_Multiple_Network_Interface_Adapters_Using:_"nstnetcfg"
How To Specify A Host Name To A DHCP Server
Some times it is desirable to specify a host name at the DHCP Client to be recognized by the DHCP Server. This will allow for local host names to be resolved by their respective name on the local LAN. This works well with a DD-WRT enabled LinkSys router and bind.
To do this, add the following line to your network configuration file (Example for: eth0 - We will use file: "/etc/sysconfig/network-scripts/ifcfg-eth0" and request that the DHCP server set this system's host name to: "emachine".):
DHCP_HOSTNAME=<Your desired host name for this NST DHCP client>
Both the "network" service and the NetworkManager service support this setting for DHCP.
# # DHCP Client Config: eth0 DEVICE=eth0 BOOTPROTO=dhcp ONBOOT=yes # # Disable capabilities security feature when running dhclient so we # can run the NST dhclient exit hook script: "/etc/dhcp/dhclient.d/nst.sh". DHCLIENTARGS="-nc" # # Specify the 'dhclient' host-name option (-H) to send to the DHCP server. DHCP_HOSTNAME=emachine
How To Permanently Set The Host Name Of Your NST System
To do this, add/change the following line to the system configuration file: "/etc/sysconfig/network"
HOSTNAME=<your desired host name for this NST system>
NetworkManager will be notified of this change and automatically set the system "hostname". The example below sets the system host name to: "emachine". Typically, if this system is a DHCP client, both the "DHCP_HOSTNAME" discussed above and the "HOSTNAME" entries are set identically.
NETWORKING=yes HOSTNAME=emachine NOZEROCONF=yes
A system reboot can be done to verify all changes.
Configuring A Static IP Address
If the network your interface is connected to does not have a DHCP server, you will need to configure your system to use a static IP address. The following shows the contents of file: "/etc/sysconfig/network-scripts/ifcfg-eth0" which is used to assign a static IP address of: "192.168.12.100" to eth0 (an Ethernet interface):
NAME=eth0 HWADDR=30:85:a9:44:24:44 TYPE=Ethernet BOOTPROTO=static IPADDR=192.168.12.100 NETMASK=255.255.255.0 NETWORK=192.168.12.0 BROADCAST=192.168.12.255 GATEWAY=192.168.12.1 ONBOOT=yes NM_CONTROLLED=no
Note 2: Make sure the NetworkManager" service is disabled: systemctl disable NetworkManager.service;
Note 3: Make sure the "network" service is enabled: systemctl enable network.service;
Note 3: Make sure the MAC Address (HWADDR) is correct for the Network Interface you are configuring.
Configuring A Stealth Network Interface
In order to configure a stealth (i.e., A network interface with a non-binding IP Address) network interface set the BOOTPROTO setting to: "none". Example: Make network interface: "eth1" at stealth interface using this minimal configuration:
NAME=eth1 HWADDR=30:85:a9:43:25:22 TYPE=Ethernet BOOTPROTO=none ONBOOT=yes NM_CONTROLLED=no
Restarting the Network Service
After editing any network configuration file, you should restart the network service as shown below:
[root@tmobile network-scripts]# service network restart Shutting down interface eth0: [ OK ] Shutting down loopback interface: [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface eth0: [ OK ]
For "NST 15" and above use the systemctl command:
[root@tmobile network-scripts]# systemctl restart network.service
Display Routing Table
The following command can be used to display your network routing table (the -n option was included to prevent the route command from trying to resolve names):
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
IPv4 Aliasing (IP Alias or Multi-Net)
Overview
An IP Alias allows you to configure multiple IPv4 Addresses onto a physical device (NIC). IPv4 Aliasing is known as network layer virtual hosting. It is common to use an IPv4 Aliases with Apache Virtual Hosting.
See this page: "Configuring IP aliases for a remote Linux location" when using the ip utility to configure an IPv4 Alias Address.
HowTo Manually Add An IPv4 Alias
lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:580 errors:0 dropped:0 overruns:0 frame:0 TX packets:580 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:44887 (43.8 KiB) TX bytes:44887 (43.8 KiB) p5p1 Link encap:Ethernet HWaddr E0:69:95:B1:6E:BF inet addr:10.222.222.10 Bcast:10.222.222.255 Mask:255.255.255.0 inet6 addr: fe80::e269:95ff:feb1:6ebf/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:146101 errors:0 dropped:19 overruns:0 frame:0 TX packets:71495 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:80187453 (76.4 MiB) TX bytes:44001889 (41.9 MiB) Interrupt:46 Base address:0x6000
lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:580 errors:0 dropped:0 overruns:0 frame:0 TX packets:580 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:44887 (43.8 KiB) TX bytes:44887 (43.8 KiB) p5p1 Link encap:Ethernet HWaddr E0:69:95:B1:6E:BF inet addr:10.222.222.10 Bcast:10.222.222.255 Mask:255.255.255.0 inet6 addr: fe80::e269:95ff:feb1:6ebf/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:146101 errors:0 dropped:19 overruns:0 frame:0 TX packets:71495 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:80187453 (76.4 MiB) TX bytes:44001889 (41.9 MiB) Interrupt:46 Base address:0x6000 p5p1:0 Link encap:Ethernet HWaddr E0:69:95:B1:6E:BF inet addr:10.222.222.83 Bcast:10.222.222.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:46 Base address:0x6000
The IPv4 Alias command above produced a virtual host address for the p5p1 network interface using IPv4 Address: "10.222.222.83". IPv4 Aliases are referred to by appending ":n" to the actual network interface device, in which "n" is an integer. In our example, we created the IPv4 Alias on NIC: "p5p1" , with alias number "Zero (0)".
All network statistics associated with each IPv4 Alias interface are combined with the physical network interface. To get individual statistics for an IPv4 Aliased Interface then accounting rules would need to be used through the iptables command.
HowTo Remove An IPv4 Alias
To remove an IPv4 Alias use the ifconfig command "down" option:
HowTo Permanently Add An IPv4 Alias
This procedure uses the "network" service. The following shows the contents of file: "/etc/sysconfig/network-scripts/ifcfg-p5p1:0" which is used to assign a static IPv4 Alias address of: "10.222.222.83" to network interface: "p5p1:0"
NAME=p5p1:0 HWADDR=E0:69:95:B1:6E:BF TYPE=Ethernet DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=no BOOTPROTO=static IPADDR=10.222.222.83 NETMASK=255.255.255.0 NETWORK=10.222.222.0 BROADCAST=10.222.222.255 GATEWAY=10.222.222.1 ONBOOT=yes NM_CONTROLLED=no
Note 2: Make sure the NetworkManager" service is disabled: systemctl disable NetworkManager.service;
Note 3: Make sure the "network" service is enabled: systemctl enable network.service;
Create Predictable Network Interface Names
Some information in this section was derived from the sites: freedesktop.org and Creating stable names for network interfaces on Linux
Overview
Starting with v197 systemd/udev will automatically assign predictable, stable network interface names for all local Ethernet, WLAN and WWAN interfaces. This is a departure from the traditional interface naming scheme ("eth0", "eth1", "wlan0", ...), but should fix real problems. The classic naming scheme for network interfaces applied by the kernel is to simply assign names beginning with "eth0", "eth1", ... to all interfaces as they are probed by the drivers. As the driver probing is generally not predictable for modern technology this means that as soon as multiple network interfaces are available the assignment of the names "eth0", "eth1" and so on is generally not fixed anymore and it might very well happen that "eth0" on one boot ends up being "eth1" on the next. This can have serious security implications, for example in firewall rules which are coded for certain naming schemes, and which are hence very sensitive to unpredictable changing names.
With systemd 197 we have added native support for a number of different naming policies into systemd/udevd proper and made a scheme similar to biosdevname's (but generally more powerful, and closer to kernel-internal device identification schemes) the default. The following different naming schemes for network interfaces are now supported by udev natively:
- Names incorporating Firmware/BIOS provided index numbers for on-board devices (example: eno1)
- Names incorporating Firmware/BIOS provided PCI Express hotplug slot index numbers (example: ens1)
- Names incorporating physical/geographical location of the connector of the hardware (example: enp2s0)
- Names incorporating the interfaces's MAC address (example: enx78e7d1ea46da)
- Classic, unpredictable kernel-native ethX naming (example: eth0)
By default, systemd v197 will now name interfaces following policy 1) if that information from the firmware is applicable and available, falling back to 2) if that information from the firmware is applicable and available, falling back to 3) if applicable, falling back to 5) in all other cases. Policy 4) is not used by default, but is available if the user chooses so.
This combined policy is only applied as last resort. That means, if the system has biosdevname installed, it will take precedence. If the user has added udev rules which change the name of the kernel devices these will take precedence too. Also, any distribution specific naming schemes generally take precedence.
The naming convention is documented in detail in a comment block for source code file: "udev-builtin-net_id.c". Please refer to document in case you are wondering how to decode the new interface names.
biosdevname=0
If you do this the naming convention described above will be used.
To disable both the "biosdevnames" renaming and the "udev" renaming so that the original Kernel "ethx" (e.g., eth0) networking interface naming is used, which may be unpredictable, the use the following Kernel command line parameters:
biosdevname=0 net.ifnames=0
Ways To Alter The Network Interface Names
You basically have four options:
- You disable the assignment of fixed names, so that the unpredictable kernel names are used again. For this, simply mask udev's rule file for the default policy: ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules
- You create your own manual naming scheme, for example by naming your interfaces "internet0", "dmz0" or "lan0". For that create your own udev rules file and set the NAME property for the devices. Make sure to order it before the default policy file, for example by naming it /etc/udev/rules.d/70-my-net-names.rules
- You alter the default policy file, for picking a different naming scheme, for example for naming all interface names after their MAC address by default: cp /usr/lib/udev/rules.d/80-net-name-slot.rules /etc/udev/rules.d/80-net-name-slot.rules, then edit the file there and change the lines as necessary.
- You pass the net.ifnames=0 on the kernel command line (since v199)
Example: Want to Shorten the Network Interface Name: eno16777736 To eno1
Here is an example on how to change the network interface name: "eno16777736" to "eno1".
Before Interface Name Change:
[root@localhost network-scripts]# ip addr show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:0c:29:d2:af:fc brd ff:ff:ff:ff:ff:ff inet 10.222.222.116/24 brd 10.222.222.255 scope global dynamic eno1 valid_lft 54243sec preferred_lft 54243sec inet6 fe80::20c:29ff:fed2:affc/64 scope link valid_lft forever preferred_lft forever
We will use the Bus position as the key to identify the network interface name to change for the udev rule. Here is a way to find the Bus position:
for dir in /sys/class/net/* ; do [ -e $dir/device ] && { basename $dir ; readlink -f $dir/device } done
Results:
eno16777736 /sys/devices/pci0000:00/0000:00:15.0/0000:03:00.0
Use the udevadm utility to list all udev environment variables for this network device (eno16777736):
udevadm info /sys/class/net/eno16777736 P: /devices/pci0000:00/0000:00:15.0/0000:03:00.0/net/eno16777736 E: DEVPATH=/devices/pci0000:00/0000:00:15.0/0000:03:00.0/net/eno16777736 E: ID_BUS=pci E: ID_MM_CANDIDATE=1 E: ID_MODEL_FROM_DATABASE=VMXNET3 Ethernet Controller E: ID_MODEL_ID=0x07b0 E: ID_NET_LABEL_ONBOARD=enEthernet0 E: ID_NET_NAME_MAC=enx000c29d2affc E: ID_NET_NAME_ONBOARD=eno16777736 E: ID_NET_NAME_PATH=enp3s0 E: ID_NET_NAME_SLOT=ens160 E: ID_OUI_FROM_DATABASE=VMware, Inc. E: ID_PCI_CLASS_FROM_DATABASE=Network controller E: ID_PCI_SUBCLASS_FROM_DATABASE=Ethernet controller E: ID_VENDOR_FROM_DATABASE=VMware E: ID_VENDOR_ID=0x15ad E: IFINDEX=2 E: INTERFACE=eno16777736 E: SUBSYSTEM=net E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/eno16777736 E: TAGS=:systemd: E: USEC_INITIALIZED=30960
From the results we will now create a custom udev rules file: "/etc/udev/rules.d/79-my-net-name-slot.rules" to shorten the long network interface name to: "eno1":
cat /etc/udev/rules.d/79-my-net-name-slot.rules; ACTION=="add", SUBSYSTEM=="net", ENV{ID_BUS}=="pci", KERNELS=="0000:03:00.0", NAME="eno1"
cat /etc/udev/rules.d/79-my-net-name-slot.rules; ACTION=="add", SUBSYSTEM=="net", ENV{ID_NET_NAME_MAC}=="enx000c29d2affc", NAME="eno1"
- OR -
cat /etc/udev/rules.d/79-my-net-name-slot.rules; ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="00:0c:29:d2:af:fc", NAME="eno1"
Files in "/etc/udev/rules.d/" are parsed in lexical order, and in some circumstances, the order in which rules are parsed is important. In general, you want your own rules to be parsed before the defaults. Therefore the udev rules file: "/etc/udev/rules.d/79-my-net-name-slot.rules" will be parsed before the default network udev rules file: "/usr/lib/udev/rules.d/80-net-name-slot.rules".
One can learn about writing udev rules files at the site: "reactivated.net - Writing udev Rules".
One can now reboot the NST system for the interface name change to take effect:
After Interface Name Change:
[root@localhost network-scripts]# ip addr show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:0c:29:d2:af:fc brd ff:ff:ff:ff:ff:ff inet 10.222.222.116/24 brd 10.222.222.255 scope global dynamic eno1 valid_lft 54243sec preferred_lft 54243sec inet6 fe80::20c:29ff:fed2:affc/64 scope link valid_lft forever preferred_lft forever
The udevadm utility now reveals the following for network device: "eno1"
udevadm info /sys/class/net/eno1 P: /devices/pci0000:00/0000:00:15.0/0000:03:00.0/net/eno1 E: DEVPATH=/devices/pci0000:00/0000:00:15.0/0000:03:00.0/net/eno1 E: ID_BUS=pci E: ID_MM_CANDIDATE=1 E: ID_MODEL_FROM_DATABASE=VMXNET3 Ethernet Controller E: ID_MODEL_ID=0x07b0 E: ID_NET_LABEL_ONBOARD=enEthernet0 E: ID_NET_NAME_MAC=enx000c29d2affc E: ID_NET_NAME_ONBOARD=eno16777736 E: ID_NET_NAME_PATH=enp3s0 E: ID_NET_NAME_SLOT=ens160 E: ID_OUI_FROM_DATABASE=VMware, Inc. E: ID_PCI_CLASS_FROM_DATABASE=Network controller E: ID_PCI_SUBCLASS_FROM_DATABASE=Ethernet controller E: ID_VENDOR_FROM_DATABASE=VMware E: ID_VENDOR_ID=0x15ad E: IFINDEX=2 E: INTERFACE=eno1 E: SUBSYSTEM=net E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/eno1 E: TAGS=:systemd: E: USEC_INITIALIZED=30960
HowTo Debug A udev Rules File
One can use the "udevadm test <devpath>" command to verify, detect any errors and debug your udev rules file. The "<devpath>" is the "/sys" path of the device to query. Below is an example for our network interface device: "eno1"
udevadm test /sys/class/net/eno1 calling: test version 208 This program is for debugging only, it does not run any program specified by a RUN key. It may show incorrect results, because some values may be different, or not available at a simulation run. === trie on-disk === tool version: 208 file size: 5913667 bytes header size 80 bytes strings 1299963 bytes nodes 4613624 bytes load module index read rules file: /usr/lib/udev/rules.d/10-dm.rules read rules file: /usr/lib/udev/rules.d/11-dm-lvm.rules read rules file: /usr/lib/udev/rules.d/13-dm-disk.rules read rules file: /usr/lib/udev/rules.d/40-libgphoto2.rules IMPORT found builtin 'usb_id --export %%p', replacing /usr/lib/udev/rules.d/40-libgphoto2.rules:11 read rules file: /usr/lib/udev/rules.d/40-usb-media-players.rules read rules file: /usr/lib/udev/rules.d/40-usb_modeswitch.rules read rules file: /usr/lib/udev/rules.d/42-usb-hid-pm.rules read rules file: /usr/lib/udev/rules.d/50-udev-default.rules read rules file: /usr/lib/udev/rules.d/56-hpmud.rules read rules file: /usr/lib/udev/rules.d/60-cdrom_id.rules read rules file: /usr/lib/udev/rules.d/60-drm.rules read rules file: /usr/lib/udev/rules.d/60-fprint-autosuspend.rules read rules file: /usr/lib/udev/rules.d/60-keyboard.rules read rules file: /usr/lib/udev/rules.d/60-net.rules read rules file: /usr/lib/udev/rules.d/60-pcmcia.rules read rules file: /usr/lib/udev/rules.d/60-persistent-alsa.rules read rules file: /usr/lib/udev/rules.d/60-persistent-input.rules read rules file: /usr/lib/udev/rules.d/60-persistent-serial.rules read rules file: /usr/lib/udev/rules.d/60-persistent-storage-tape.rules read rules file: /usr/lib/udev/rules.d/60-persistent-storage.rules read rules file: /usr/lib/udev/rules.d/60-persistent-v4l.rules read rules file: /usr/lib/udev/rules.d/60-raw.rules read rules file: /usr/lib/udev/rules.d/61-accelerometer.rules read rules file: /usr/lib/udev/rules.d/61-gnome-bluetooth-rfkill.rules read rules file: /usr/lib/udev/rules.d/62-multipath.rules read rules file: /usr/lib/udev/rules.d/63-md-raid-arrays.rules read rules file: /usr/lib/udev/rules.d/64-btrfs.rules read rules file: /usr/lib/udev/rules.d/64-md-raid-assembly.rules read rules file: /usr/lib/udev/rules.d/65-libwacom.rules read rules file: /usr/lib/udev/rules.d/65-md-incremental.rules read rules file: /usr/lib/udev/rules.d/65-sane-backends.rules read rules file: /usr/lib/udev/rules.d/69-cd-sensors.rules read rules file: /usr/lib/udev/rules.d/69-dm-lvm-metad.rules read rules file: /usr/lib/udev/rules.d/69-libmtp.rules read rules file: /usr/lib/udev/rules.d/69-xorg-vmmouse.rules read rules file: /usr/lib/udev/rules.d/70-power-switch.rules read rules file: /usr/lib/udev/rules.d/70-printers.rules read rules file: /usr/lib/udev/rules.d/70-spice-vdagentd.rules read rules file: /usr/lib/udev/rules.d/70-touchpad-quirks.rules read rules file: /usr/lib/udev/rules.d/70-uaccess.rules read rules file: /usr/lib/udev/rules.d/70-wacom.rules read rules file: /usr/lib/udev/rules.d/71-biosdevname.rules read rules file: /usr/lib/udev/rules.d/71-seat.rules read rules file: /usr/lib/udev/rules.d/73-seat-late.rules read rules file: /usr/lib/udev/rules.d/75-net-description.rules read rules file: /usr/lib/udev/rules.d/75-probe_mtd.rules read rules file: /usr/lib/udev/rules.d/75-tty-description.rules read rules file: /usr/lib/udev/rules.d/77-mm-ericsson-mbm.rules read rules file: /usr/lib/udev/rules.d/77-mm-huawei-net-port-types.rules read rules file: /usr/lib/udev/rules.d/77-mm-longcheer-port-types.rules read rules file: /usr/lib/udev/rules.d/77-mm-nokia-port-types.rules read rules file: /usr/lib/udev/rules.d/77-mm-pcmcia-device-blacklist.rules read rules file: /usr/lib/udev/rules.d/77-mm-platform-serial-whitelist.rules read rules file: /usr/lib/udev/rules.d/77-mm-simtech-port-types.rules read rules file: /usr/lib/udev/rules.d/77-mm-telit-port-types.rules read rules file: /usr/lib/udev/rules.d/77-mm-usb-device-blacklist.rules read rules file: /usr/lib/udev/rules.d/77-mm-usb-serial-adapters-greylist.rules read rules file: /usr/lib/udev/rules.d/77-mm-x22x-port-types.rules read rules file: /usr/lib/udev/rules.d/77-mm-zte-port-types.rules read rules file: /usr/lib/udev/rules.d/77-nm-olpc-mesh.rules read rules file: /usr/lib/udev/rules.d/78-sound-card.rules read rules file: /etc/udev/rules.d/79-my-net-name-slot.rules read rules file: /usr/lib/udev/rules.d/80-drivers.rules read rules file: /usr/lib/udev/rules.d/80-mm-candidate.rules read rules file: /usr/lib/udev/rules.d/80-net-name-slot.rules read rules file: /usr/lib/udev/rules.d/80-udisks2.rules read rules file: /usr/lib/udev/rules.d/85-regulatory.rules read rules file: /usr/lib/udev/rules.d/85-usbmuxd.rules read rules file: /usr/lib/udev/rules.d/90-alsa-restore.rules read rules file: /usr/lib/udev/rules.d/90-alsa-tools-firmware.rules read rules file: /usr/lib/udev/rules.d/90-libgpod.rules read rules file: /usr/lib/udev/rules.d/90-pulseaudio.rules read rules file: /usr/lib/udev/rules.d/91-drm-modeset.rules read rules file: /usr/lib/udev/rules.d/95-cd-devices.rules read rules file: /usr/lib/udev/rules.d/95-dm-notify.rules read rules file: /usr/lib/udev/rules.d/95-udev-late.rules read rules file: /usr/lib/udev/rules.d/95-upower-battery-recall-dell.rules read rules file: /usr/lib/udev/rules.d/95-upower-battery-recall-fujitsu.rules read rules file: /usr/lib/udev/rules.d/95-upower-battery-recall-gateway.rules read rules file: /usr/lib/udev/rules.d/95-upower-battery-recall-ibm.rules read rules file: /usr/lib/udev/rules.d/95-upower-battery-recall-lenovo.rules read rules file: /usr/lib/udev/rules.d/95-upower-battery-recall-toshiba.rules read rules file: /usr/lib/udev/rules.d/95-upower-csr.rules read rules file: /usr/lib/udev/rules.d/95-upower-hid.rules read rules file: /usr/lib/udev/rules.d/95-upower-wup.rules read rules file: /etc/udev/rules.d/98-kexec.rules read rules file: /usr/lib/udev/rules.d/99-qemu-guest-agent.rules read rules file: /usr/lib/udev/rules.d/99-systemd.rules rules contain 393216 bytes tokens (32768 * 12 bytes), 37195 bytes strings 30305 strings (254465 bytes), 26909 de-duplicated (220667 bytes), 3397 trie nodes used PROGRAM '/lib/udev/rename_device' /usr/lib/udev/rules.d/60-net.rules:1 starting '/lib/udev/rename_device' '/lib/udev/rename_device' [2664] exit with return code 0 PROGRAM '/sbin/biosdevname --policy physical -i eno1' /usr/lib/udev/rules.d/71-biosdevname.rules:22 starting '/sbin/biosdevname --policy physical -i eno1' '/sbin/biosdevname --policy physical -i eno1' [2665] exit with return code 4 IMPORT builtin 'net_id' /usr/lib/udev/rules.d/75-net-description.rules:6 IMPORT builtin 'hwdb' /usr/lib/udev/rules.d/75-net-description.rules:12 NAME 'eno1' /etc/udev/rules.d/79-my-net-name-slot.rules:2 RUN '/usr/lib/systemd/systemd-sysctl --prefix=/proc/sys/net/ipv4/conf/$name --prefix=/proc/sys/net/ipv4/neigh/$name --prefix=/proc/sys/net/ipv6/conf/$name -- prefix=/proc/sys/net/ipv6/neigh/$name' /usr/lib/udev/rules.d/99-systemd.rules:52 ACTION=add DEVPATH=/devices/pci0000:00/0000:00:15.0/0000:03:00.0/net/eno1 ID_BUS=pci ID_MM_CANDIDATE=1 ID_MODEL_FROM_DATABASE=VMXNET3 Ethernet Controller ID_MODEL_ID=0x07b0 ID_NET_LABEL_ONBOARD=enEthernet0 ID_NET_NAME_MAC=enx000c29d2affc ID_NET_NAME_ONBOARD=eno16777984 ID_NET_NAME_PATH=enp3s0 ID_NET_NAME_SLOT=ens160 ID_OUI_FROM_DATABASE=VMware, Inc. ID_PCI_CLASS_FROM_DATABASE=Network controller ID_PCI_SUBCLASS_FROM_DATABASE=Ethernet controller ID_VENDOR_FROM_DATABASE=VMware ID_VENDOR_ID=0x15ad IFINDEX=2 INTERFACE=eno1 SUBSYSTEM=net SYSTEMD_ALIAS=/sys/subsystem/net/devices/eno1 TAGS=:systemd: USEC_INITIALIZED=30960 run: '/usr/lib/systemd/systemd-sysctl --prefix=/proc/sys/net/ipv4/conf/eno1 --prefix=/proc/sys/net/ipv4/neigh/eno1 --prefix=/proc/sys/net/ipv6/conf/eno1 --prefix=/proc/sys/net/ipv6/neigh/eno1' unload module index
This command will verify the correct syntax for each udev rules file and also show the order in which each rules file is processed. If a syntax error had occurred, it would be shown for the offending file. Most likely any errors that occurred would be associated with our custom udev rules file.
The custom udev rules file: "/etc/udev/rules.d/79-my-net-name-slot.rules" is in Italic Bold text above and is also shown as the udev rules file that was responsible for the network interface rename from eth0 to eno1.
From dmesg we see when the actual udev rule was used to rename the network interface during the system boot process:
[ 4.526042] systemd-udevd[419]: renamed network interface eth0 to eno1