ip、ifconfig命令与IP(转)

Q:问题的要求就是在linux下不重新情况下,如何临时增加一个IP及临时删除一个IP ?

A:该问题除了可以通过ifconfig命令完成外,也可以通过ip命令完成,不过两者是有区别的。ifconfig 要加子接口,ip 不用

我常用的命令:

ip addr add 1.1.1.1/24 dev eth0 

keepalived 我猜 也是引用了这个命令:

(inet 192.168.1.6/24 scope global secondary eth0
inet 192.168.1.7/24 scope global secondary eth0)


virtual_ipaddress {
192.168.1.6/24
192.168.1.7/24

 

也可以是这样:

ifconfig  

ifconfig eth0:1 192.168.10.198 netmask 255.255.255.0 up

2、ip命令删除一个IP
[root@localhost ~]# ip addr del 192.168.10.199/24 dev eth0 


三、路由配置

增加路由

 

 

route add -net 192.168.6.0/24 gw 192.168.101.254
route add default gw 192.168.101.254

http://www.361way.com/ifconfig-ip-ip/1835.html
posted @ 2018-01-29 11:38  littlevigra  阅读(608)  评论(0编辑  收藏  举报