使用 ip 命令关闭以太网接口

使用 ip 命令关闭以太网接口

我正在对up设备使用以下命令

# ifconfig p1p1:1 10.250.0.0 netmask 255.255.0.0 up
# ifconfig p1p1:2 10.251.0.0 netmask 255.255.0.0 up
# ifconfig p1p1:3 10.252.0.0 netmask 255.255.0.0 up

我目前没有ifconfig在新设备上安装,但有ip命令

我可以使用ip addr命令查看系统的 IP 地址

ifconfig ... up使用命令的等效命令是什么ip

ip link show输出为:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: p1p1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT qlen 1000
    link/ether 00:ba:e7:ae:ed:3e brd ff:ff:ff:ff:ff:ff
3: p1p2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT qlen 1000
    link/ether 00:ba:e7:ae:ed:3f brd ff:ff:ff:ff:ff:ff
4: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT qlen 1000
    link/ether 60:aa:3e:25:47:1f brd ff:ff:ff:ff:ff:ff
5: em2: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT qlen 1000
    link/ether 60:aa:3e:25:47:2f brd ff:ff:ff:ff:ff:ff

答案1

下面的例子假设你的网卡名称是eth0

要调出界面:ip link set eth0 up

关闭接口:ip link set eth0 down

相关内容