问题现象:
安装完操作系统后,插上光模块网口灯是亮的,通过ip a发现网口不能正常的UP,ipconfig无该网卡信息。如下所示:
通过ip a命令可以发现网口状态是down的
6: ens2f0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 0c:42:a1:a9:67:ce brd ff:ff:ff:ff:ff:ff
7: ens2f1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 0c:42:a1:a9:67:cf brd ff:ff:ff:ff:ff:ff
8: ens8f0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 0c:42:a1:a9:76:26 brd ff:ff:ff:ff:ff:ff
9: ens8f1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 0c:42:a1:a9:76:27 brd ff:ff:ff:ff:ff:ff
通过ifconfig,无法发现网口,通过ifconfig -a 可以看到网卡
bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST> mtu 1500
inet 172.10.10.74 netmask 255.255.255.0 broadcast 172.10.10.255
inet6 fe80::8613:9fff:fe46:a1e prefixlen 64 scopeid 0x20<link>
inet6 2409:8c2f:3800::ac2:974a prefixlen 120 scopeid 0x0<global>
ether 84:13:9f:46:0a:1e txqueuelen 1000 (Ethernet)
RX packets 99044 bytes 27111363 (25.8 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3587 bytes 400961 (391.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eno3: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST> mtu 1500
ether 84:13:9f:46:0a:1e txqueuelen 1000 (Ethernet)
RX packets 79393 bytes 22447352 (21.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3542 bytes 398519 (389.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eno4: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST> mtu 1500
ether 84:13:9f:46:0a:1e txqueuelen 1000 (Ethernet)
RX packets 19651 bytes 4664011 (4.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 45 bytes 2442 (2.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 88 bytes 7920 (7.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 88 bytes 7920 (7.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
解决办法:
在linux中通过ifconfig命令将网卡手动开启一下
ifconfig ens2f0 up
ifconfig [网卡名称] up
开启后的网卡,通过ip a、ifconfig命令查看就正常了,很奇怪,难道这个网卡默认是关闭的,但是插线也亮呀。
再通过ip a查看网卡就UP了,ifconfig也可以发现看到了,也能正常转发数据了。
6: ens2f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 0c:42:a1:a9:67:ce brd ff:ff:ff:ff:ff:ff
inet6 fe80::e42:a1ff:fea9:67ce/64 scope link
valid_lft forever preferred_lft forever
7: ens2f1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether 0c:42:a1:a9:67:cf brd ff:ff:ff:ff:ff:ff
8: ens8f0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether 0c:42:a1:a9:76:26 brd ff:ff:ff:ff:ff:ff
9: ens8f1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 0c:42:a1:a9:76:27 brd ff:ff:ff:ff:ff:ff
inet6 fe80::e42:a1ff:fea9:7627/64 scope link
网卡背面图: