我正在运行 Ubuntu 18.04.2 LTS。
运行 ping 发现我一直在丢失数据包
ping google.com -D -O
[1554813201.789920] 64 bytes from lhr35s05-in-f14.1e100.net (216.58.212.78): icmp_seq=1515 ttl=54 time=9.15 ms[1554813202.790238] 64 bytes from lhr35s05-in-f14.1e100.net (216.58.212.78): icmp_seq=1516 ttl=54 time=9.17 ms
[1554813203.792015] 64 bytes from lhr35s05-in-f14.1e100.net (216.58.212.78): icmp_seq=1517 ttl=54 time=9.67 ms
[1554813204.793209] 64 bytes from lhr35s05-in-f14.1e100.net (216.58.212.78): icmp_seq=1518 ttl=54 time=9.10 ms
[1554813205.794539] 64 bytes from lhr35s05-in-f14.1e100.net (216.58.212.78): icmp_seq=1519 ttl=54 time=9.23 ms
[1554813206.795682] 64 bytes from lhr35s05-in-f14.1e100.net (216.58.212.78): icmp_seq=1520 ttl=54 time=9.07 ms
[1554813208.793010] no answer yet for icmp_seq=1521
[1554813208.802225] 64 bytes from lhr35s05-in-f14.1e100.net (216.58.212.78): icmp_seq=1522 ttl=54 time=9.13 ms
[1554813210.809027] no answer yet for icmp_seq=1523
[1554813210.818212] 64 bytes from lhr35s05-in-f14.1e100.net (216.58.212.78): icmp_seq=1524 ttl=54 time=9.12 ms
[1554813212.825006] no answer yet for icmp_seq=1525
[1554813213.849020] no answer yet for icmp_seq=1526
[1554813214.873033] no answer yet for icmp_seq=1527
[1554813215.897025] no answer yet for icmp_seq=1528
[1554813216.921026] no answer yet for icmp_seq=1529
[1554813217.945047] no answer yet for icmp_seq=1530
[1554813218.969034] no answer yet for icmp_seq=1531
[1554813219.993022] no answer yet for icmp_seq=1532
[1554813221.017070] no answer yet for icmp_seq=1533
[1554813222.041048] no answer yet for icmp_seq=1534
[1554813223.065043] no answer yet for icmp_seq=1535
[1554813224.089020] no answer yet for icmp_seq=1536
[1554813225.113039] no answer yet for icmp_seq=1537
[1554813226.137056] no answer yet for icmp_seq=1538
[1554813227.161056] no answer yet for icmp_seq=1539
[1554813228.185024] no answer yet for icmp_seq=1540
[1554813229.209004] no answer yet for icmp_seq=1541
[1554813230.233020] no answer yet for icmp_seq=1542
[1554813231.257036] no answer yet for icmp_seq=1543
[1554813231.266532] 64 bytes from lhr35s05-in-f14.1e100.net (216.58.212.78): icmp_seq=1544 ttl=54 time=9.44 ms
[1554813232.267725] 64 bytes from lhr35s05-in-f14.1e100.net (216.58.212.78): icmp_seq=1545 ttl=54 time=9.12 ms
[1554813233.268997] 64 bytes from lhr35s05-in-f14.1e100.net (216.58.212.78): icmp_seq=1546 ttl=54 time=9.17 ms
[1554813234.270495] 64 bytes from lhr35s05-in-f14.1e100.net (216.58.212.78): icmp_seq=1547 ttl=54 time=9.42 ms
[1554813235.272539] 64 bytes from lhr35s05-in-f14.1e100.net (216.58.212.78): icmp_seq=1548 ttl=54 time=9.97 ms
[1554813236.272766] 64 bytes from lhr35s05-in-f14.1e100.net (216.58.212.78): icmp_seq=1549 ttl=54 time=9.44
ifconfig 结果:
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.50.92 netmask 255.255.255.0 broadcast 192.168.50.255
inet6 fe80::d267:e5ff:fee8:6ae1 prefixlen 64 scopeid 0x20<link>
ether d0:67:e5:e8:6a:e1 txqueuelen 1000 (Ethernet)
RX packets 787572 bytes 65134999 (65.1 MB)
RX errors 65744 dropped 1939 overruns 0 frame 7156
TX packets 1032248 bytes 173826137 (173.8 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 15101
device interrupt 16
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 755199 bytes 91690755 (91.6 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 755199 bytes 91690755 (91.6 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
事实上,eno1 显示 RX 错误并且丢失,我猜这是一件坏事?
我对 Ubuntu 还很陌生,并且一直在尝试研究这个问题一段时间,但感觉这样做有点盲目,所以希望有人能给我一些指导,以调查和纠正这个问题。
编辑1:我被要求在我的问题中提供一些额外的细节:
跑步:
dmesg | grep -i eth0
给我:
[ 3.330821] tg3 0000:02:00.0 eth0: Tigon3 [partno(BCM95722) rev a200] (PCI Express) MAC address d0:67:e5:e8:6a:e1
[ 3.330923] tg3 0000:02:00.0 eth0: attached PHY is 5722/5756 (10/100/1000Base-T Ethernet) (WireSpeed[1], EEE[0])
[ 3.331021] tg3 0000:02:00.0 eth0: RXcsums[1] LinkChgREG[0] MIirq[0] ASF[1] TSOcap[1]
[ 3.331115] tg3 0000:02:00.0 eth0: dma_rwctrl[76180000] dma_mask[64-bit]
[ 3.335489] tg3 0000:02:00.0 eno1: renamed from eth0
跑步:
dmesg | grep -i eno1
给我:
[ 3.335489] tg3 0000:02:00.0 eno1: renamed from eth0
[ 11.431508] IPv6: ADDRCONF(NETDEV_UP): eno1: link is not ready
[ 13.760574] tg3 0000:02:00.0 eno1: Link is up at 1000 Mbps, full duplex
[ 13.760580] tg3 0000:02:00.0 eno1: Flow control is off for TX and off for RX
[ 13.760592] IPv6: ADDRCONF(NETDEV_CHANGE): eno1: link becomes ready
[ 223.288087] tg3 0000:02:00.0 eno1: Link is down
[ 226.700240] tg3 0000:02:00.0 eno1: Link is up at 1000 Mbps, full duplex
[ 226.700255] tg3 0000:02:00.0 eno1: Flow control is on for TX and on for RX
跑步:
nmcli device
给我:
DEVICE TYPE STATE CONNECTION
eno1 ethernet unmanaged --
lo loopback unmanaged --
跑步:
nmcli device show eno1 | grep IP4.DNS
没有给我任何结果。
跑步:
cat /run/systemd/resolve/resolv.conf | tail -3
给我:
nameserver 192.168.50.19
nameserver 192.168.50.20
这些都是我们自己管理的内部 DNS 服务。
跑步:
ls -l /etc/resolv.conf
给我:
lrwxrwxrwx 1 root root 39 Jul 25 2018 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
跑步:
cat /etc/resolv.conf | tail -4
给我:
# operation for /etc/resolv.conf.
nameserver 127.0.0.53
options edns0
我的 yaml 文件:
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
version: 2
renderer: networkd
ethernets:
eno1:
addresses: [ 192.168.50.92/24 ]
dhcp4: false
gateway4: 192.168.50.1
nameservers:
addresses: [ 192.168.50.19, 192.168.50.20]
带路由的 Yaml 文件:
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
version: 2
renderer: networkd
ethernets:
eno1:
addresses: [ 192.168.50.92/24 ]
dhcp4: false
nameservers:
addresses: [ 192.168.50.19, 192.168.50.20 ]
routes:
- to: 0.0.0.0/0
via: 192.168.50.1
on-link: true
答案1
这是一个对某些人有用的解决方案,所以我将其分享给你们。
第一次运行
ifconfig -a
问题始终是 eth0 上的电缆没有分配 IP。使用
sudo dhclient eth0
并且可以再次工作,但是重启后它就会停止工作。
编辑文件
/etc/network/interfaces
并进行更改,使其看起来像这样:# The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet dhcp
顺便说一句:如果你有无线连接,这可能会干扰有线连接,你可以尝试wicd 网络管理器(可在 Ubuntu 软件中心找到)来配置无线连接。