In this lesson, you will learn how to temporarily add a secondary IP to A NIC in RHEL / CentOS 7 and 8 for testing purposes using the IP utility.
In the previous lesson, we have learnt how to permanently add a secondary IP to a NIC
However, sometimes as an administrator, you may want to add another IP to a Network interface card (NIC) for testing purposes. A good way to do this is to use the IP utility.
Using the IP utility to add other addresses to a NIC will not make the configuration permanent or persistent as compared to using the nmcli or nmtui utility. As soon as the system is rebooted, the configuration disappears as well.
[root@HQDEV1 ~]# ip addr add dev ens33 192.168.170.11/24
[root@HQDEV1 ~]# ip a .............. 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:70:d9:25 brd ff:ff:ff:ff:ff:ff inet 192.168.170.217/24 brd 192.168.170.255 scope global dynamic noprefixroute ens33 valid_lft 911sec preferred_lft 911sec inet 192.168.170.11/24 scope global secondary ens33 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe70:d925/64 scope link valid_lft forever preferred_lft forever .....
The ip utility has now replaced the ifconfig utility. The ifconfig utility in RHEL 7 and above is now obsolete, however, still works.
There are some information that will be hidden if the ifconfig utility is used instead of its replacement, “ip”. One of such is if secondary IPs are configured on a NIC, the ifconfig utility doesn’t have the ability to display the output of other secondary IPs as compared to the IP utility, The IP utility will display other secondary IPs configured on a NIC
If the man page of the ifconfig utility is opened, it is clear that this utility is obsolete and should not be used anymore in Linux except in few exceptions.
Your feedback is welcomed. If you love others, you will share with others.