linux中如何修改网络命名空间中veth设备端点的名字?

查看原有的设备名称为veth1

 
 
[root@centos7 ~]# ip netns exec ns1 ip link
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
5: veth1@if6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
link/ether 42:54:6d:73:c2:40 brd ff:ff:ff:ff:ff:ff link-netnsid 0

 

关闭网卡,否则修改报设备忙 

 

[root@centos7 ~]# ip netns exec ns1 ip link set dev veth1 down
[root@centos7 ~]#

 

修改设备的名字

 
 [root@centos7 ~]# ip netns exec ns1 ip link set dev veth1 name eth0

 

启动网卡

[root@centos7 ~]# ip netns exec ns1 ip link set dev eth0 up

 


查看最新的网卡的名字,已经修改为eth0了

[root@centos7 ~]# ip netns exec ns1 ip link
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
5: eth0@if6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
link/ether 42:54:6d:73:c2:40 brd ff:ff:ff:ff:ff:ff link-netnsid 0
[root@centos7 ~]#

 

 
posted @ 2023-07-31 11:49  Zhai_David  阅读(73)  评论(0编辑  收藏  举报