Difference between revisions of "CentOS 7.x ip command"

From Notes_Wiki
m
m
Line 29: Line 29:


To increase priority of a gateway, add it again using:
To increase priority of a gateway, add it again using:
</pre>
<pre>
   ip route add default via 172.16.1.1 dev wlp3s0 proto static metric 50
   ip route add default via 172.16.1.1 dev wlp3s0 proto static metric 50
</pre>
</pre>

Revision as of 12:32, 14 October 2017

<yambe:breadcrumb>CentOS_7.x_network_management|CentOS 7.x network management</yambe:breadcrumb>

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.



<yambe:breadcrumb>CentOS_7.x_network_management|CentOS 7.x network management</yambe:breadcrumb>