ip 命令 和ifconfig 命令 删除IP

来源:互联网 发布:数据部门团建出行标语 编辑:程序博客网 时间:2024/06/07 00:08


使用ifconfig命令添加一个VIP后,如果需要将这个VIP删除,可以使用ifconfig VIP down命令。

但是,如果操作顺序不当,VIP会仍然留在系统缓存中,这时,使用ifconfig是看不到这个VIP的,但是,使用IP命令能够看到。

查看ip

ip -o -f inet addr show

删除ip 
ip -f inet addr delete 10.0.64.102/32  dev tunl0

 

ip 与ifconfig 具体比较如下:

1 ifconfig tunl0 10.0.64.102 netmask 255.255.255.255 up
2 此时会有再运行 ifconfig 会看到如下
tunl0     Link encap:IPIP Tunnel  HWaddr   
          inet addr:10.0.64.102  Mask:255.255.255.255
          UP RUNNING NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
3 ifconfig tunl0 down
4 此时会有再运行 ifconfig 会看到如下
    没有tunl0设备了
5 但是使用ip -o -f inet addr show
  tunl0    inet 10.0.64.102/32 scope global tunl0
  依然还有这个ip,说明在tunl0配置ip的时候使用ifconfig tunl0 down 是不能删除这个ip的,但是使用ifconfig确查看不到

--------------------如下步骤----------------------------------------
1 ifconfig tunl0 up
2 ifconfig tunl0:0 10.0.64.102 netmask 255.255.255.255 up
3 ifconfig tunl0:0 down
4 ifconfig tunl0 down
此时使用ip -o -f inet addr show 或者 ifconfig 都看不到ip 10.0.64.102


----------------------如下步骤---------------------------------------------------
1 ifconfig tunl0 up
2 ifconfig tunl0:0 10.0.64.102 netmask 255.255.255.255 up
3 ifconfig tunl0:1 10.0.64.103 netmask 255.255.255.255 up
4 ifconfig tunl0 down
此时使用ifconfig看不到任何ip
但是使用ip -o -f inet addr show,如下:
  5: tunl0    inet 10.0.64.102/32 scope global tunl0:0
  5: tunl0    inet 10.0.64.103/32 scope global tunl0:1
 说明ip并没有删除

----------------------如下步骤---------------------------------------------------
1 ifconfig tunl0 up
2 ifconfig tunl0:0 10.0.64.102 netmask 255.255.255.255 up
3 ifconfig tunl0:1 10.0.64.103 netmask 255.255.255.255 up
4 ifconfig tunl0:0 down
5 ifconfig tunl0:1 down
6 ifconfig tunl0 down

此时使用ip -o -f inet addr show或者ifconfig看不到任何ip
说明 ip被删除了


from: http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=20696973&id=3174034
原创粉丝点击