CentOS 7.x ip command

From Notes_Wiki
Revision as of 06:37, 25 August 2022 by Saurabh (talk | contribs)

Home > CentOS > CentOS 7.x > System Administration > Network management > CentOS 7.x ip command

Add static IP to IPv4 interface using ip command

In CentOS 7.x multiple IPv4 addresses can be associated with same interface without needing aliases (eth0:0). The older ifconfig command will show only one of these multiple addresses.

Hence use following command to check interface ip addresses:

   ip addr show

Add IP to interface using:

   ip address add 10.90.144.251/21 dev enp0s25

Similarly existing IP can be removed using

ip add del 10.0.0.0/21 dev enp0s25


Increase priority of preferred default gateway using ip command

If there are multiple connections, eg one wireless and one wired, then we can choose preferred network (default-gateway) using ip command. For this, to check existing priorities use:

   ip route show

To increase priority of a gateway, add it again using:

   ip route add default via 172.16.1.1 dev wlp3s0 proto static metric 50

Note that having two default routes for 172.16.1.1 with two different metrics is not a problem.



Home > CentOS > CentOS 7.x > System Administration > Network management > CentOS 7.x ip command