技术改变生活

博客园 首页 新随笔 联系 订阅 管理

 ifconfig添加删除ip地址

[root@x101 conf.d]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.101 netmask 255.255.255.0 broadcast 192.168.0.255

[root@x101 conf.d]# ifconfig eth0:1 192.168.0.102/24
[root@x101 conf.d]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.101 netmask 255.255.255.0 broadcast 192.168.0.255

eth0:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500

inet 192.168.0.102 netmask 255.255.255.0 broadcast 192.168.0.255

[root@x101 conf.d]# ifconfig eth0:1 down

[root@x101 conf.d]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.101 netmask 255.255.255.0 broadcast 192.168.0.255

 

ip address 添加删除ip地址

[root@x101 ~]# ip addr add 192.168.0.102/24 dev eth0 label eth0:1
[root@x101 ~]# ip addr show
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:bc:12:d3 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.101/24 brd 192.168.0.255 scope global dynamic eth0
valid_lft 5323sec preferred_lft 5323sec
inet 192.168.0.102/24 scope global secondary eth0:1
[root@x101 ~]#

 

[root@x101 ~]# ip addr del 192.168.0.102/24 dev eth0:1
[root@x101 ~]# ip addr show
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:bc:12:d3 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.101/24 brd 192.168.0.255 scope global dynamic eth0
valid_lft 5152sec preferred_lft 5152sec

posted on 2020-08-19 18:11  小阿峰  阅读(6295)  评论(0编辑  收藏  举报