linux清除ip地址命令,ip 命令 和ifconfig 命令 删除IP

作者:zhangrenfang

使用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被删除了

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值