I’m in the planning of migration from Centos7 to Rocky, and I have encountered a problem regarding to loopback interfaces.
We are using OSPF/quagga to anycast IPv4, but in Rocky my setup from Centos7 is not working, here is my ifcfg-file and the error message generated in messages:
[root@rocky /]# cat /etc/sysconfig/network-scripts/ifcfg-lo:0
DEVICE=lo:0
BOOTPROTO=none
BROADCAST=192.168.10.10
IPADDR=192.168.10.10
NETMASK=255.255.255.255
NETWORK=192.168.10.10
ONBOOT=yes
[root@rocky /]#
[root@rocky /]# cat /var/log/messages | grep lo:0
Sep 6 15:38:34 rocky NetworkManager[936]: [1630935514.8332] ifcfg-rh: invalid DEVICE name ‘lo:0’: interface name contains an invalid character
Sep 6 15:45:40 rocky NetworkManager[949]: [1630935940.8859] ifcfg-rh: invalid DEVICE name ‘lo:0’: interface name contains an invalid character
Sep 6 15:47:14 rocky NetworkManager[940]: [1630936034.8836] ifcfg-rh: invalid DEVICE name ‘lo:0’: interface name contains an invalid character
Sep 6 15:56:36 rocky NetworkManager[943]: [1630936596.7909] ifcfg-rh: invalid DEVICE name ‘lo:0’: interface name contains an invalid character
[root@rocky /]#
Same person notes that ifconfig is out of favor and one should use tools from iproute2 (if not using NetworkManager’s UIs).
One should note that the base loopback (lo) is special. I have a feeling that it is configured and enabled on boot even if no service manages (NIC) interfaces. If NM does not touch anythin lo*, then that explains why you need the more blunt network.service.
Furthermore, firewalld.service is not suitable for a router.
In CentOS 7 you had better control with iptables.service, which is deprecated in 8.
CentOS 8 has nftables.service, because the kernel has nftables. Use that.
There should be a script that translates (most) iptables rulesets into nft’s syntax.
Yep agreed, was just searching to help provide info and a solution for them. They wanted a sub-interface so lo:0, similar when creating extra interfaces like enp1s0:0 or enp1s0:1 with different ip addresses. Although as noted, recommended is IPADDR2, IPADDR3 in the config files and not use the alias type interfaces anymore. ifconfig has been legacy for quite a while now, similar like netstat, route add default gw instead of ip addr add dev enp1s0 and ip route add.
Incidently, as I found out, just by installing network-scripts doesn’t actually revert to the old legacy type functionality until the old network service isn’t enabled and started. Also, prior to installing it, ifcfg-lo didn’t exist, and yet after install, ifcfg-lo then appeared, so seems to put a load of files in place to help allow using the legacy alias type interfaces like the original poster was wanting. I also realise that in the future the network-scripts package might disappear altogether so then that won’t be an option anymore to resolve such an issue.
I expect a lot of it could be done with nmcli as well.
So there are a couple of options to do it really:
Use the preferred method adding IPADDR1, IPADDR2, IPADDR3, etc to the /etc/sysconfig/network-scripts/ifcfg-xxx file.
Create a systemd script to use net-tools and the ifconfig command which would create the lo:0 or enp1s0:0 interfaces like the old school/legacy way.
Install network-scripts, and just create the interface file with the respective details that I found later, which then returned the functionality to how he was expecting prior to upgrade.
Anyway just helping as there’s a number of ways to do a lot of things in Linux, some more preferred than others
That creates a question:
How to handle the task with NetworkManager, or is the additional loopback address even the “new normal” way to “anycast IPv4” for OSPF/quagga, etc?