网络问题。Ifup 显示未知接口

网络问题。Ifup 显示未知接口

这是 ifconfig 的输出

# ifconfig
enp0s3    Link encap:Ethernet  HWaddr 08:00:27:ef:b6:e6
          inet addr:192.168.2.3  Bcast:192.168.2.255  Mask:255.255.255.0
          inet6 addr: fe80::cf19:776a:4d5c:36e0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:713069 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6767 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:45869812 (45.8 MB)  TX bytes:667164 (667.1 KB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:1108 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1108 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:86846 (86.8 KB)  TX bytes:86846 (86.8 KB)

当我做

# ifdown enp0s3

它说未知接口 enp0s3

网络很好,没有任何问题。只是命令不起作用。

Ubuntu 16.04(Xenial)

以下是输出ip a s

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
   valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:ef:b6:e6 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.7/24 brd 192.168.2.255 scope global enp0s3
       valid_lft forever preferred_lft forever
    inet6 fe80::cf19:776a:4d5c:36e0/64 scope link
       valid_lft forever preferred_lft forever

以下是我的 /etc/network/interfaces

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

nmcli conn sh 的输出

Wired connection 1  42d740b1-21c3-3b7c-8b9e-5922fe8a6380  802-3-ethernet  enp0s3

答案1

ifupifdown用于设置在 中列出的接口/etc/network/interfacesenp0s3此文件中未描述,因此绝对可以预料到ifup和 ifdown 不知道如何处理它。添加一些行,例如

iface enp0s3 inet dhcp

您会发现它的效果会更好。

答案2

我使用了以下命令:

cat /proc/net/dev
ls /sys/class/net
ip link show
ifconfig

sudo ifconfig [interface-name] down / up

相关内容