使用 dmesg 可以找出内核最新消息中的错误和警告。例如,这是 dmesg | more 命令的输出:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# dmesg | more .... [ 1539.027419] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready [ 1539.042726] IPv6: ADDRCONF(NETDEV_UP): veth61f37018: link is not ready [ 1539.048706] IPv6: ADDRCONF(NETDEV_CHANGE): veth61f37018: link becomes ready [ 1539.055034] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready [ 1539.098550] device veth61f37018 entered promiscuous mode [ 1541.450207] device veth61f37018 left promiscuous mode [ 1542.493266] SELinux: mount invalid. Same superblock, different security settings for (dev mqueue, type mqueue) [ 9965.292788] SELinux: mount invalid. Same superblock, different security settings for (dev mqueue, type mqueue) [ 9965.449401] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready [ 9965.462738] IPv6: ADDRCONF(NETDEV_UP): vetheacc333c: link is not ready [ 9965.468942] IPv6: ADDRCONF(NETDEV_CHANGE): vetheacc333c: link becomes ready ....
# tail -f /var/log/messages Dec 1 13:20:33 bastion dnsmasq[30201]: using nameserver 127.0.0.1#53 for domain in-addr.arpa Dec 1 13:20:33 bastion dnsmasq[30201]: using nameserver 127.0.0.1#53 for domain cluster.local Dec 1 13:21:03 bastion dnsmasq[30201]: setting upstream servers from DBus Dec 1 13:21:03 bastion dnsmasq[30201]: using nameserver 192.199.0.2#53 Dec 1 13:21:03 bastion dnsmasq[30201]: using nameserver 127.0.0.1#53 for domain in-addr.arpa Dec 1 13:21:03 bastion dnsmasq[30201]: using nameserver 127.0.0.1#53 for domain cluster.local Dec 1 13:21:33 bastion dnsmasq[30201]: setting upstream servers from DBus Dec 1 13:21:33 bastion dnsmasq[30201]: using nameserver 192.199.0.2#53 Dec 1 13:21:33 bastion dnsmasq[30201]: using nameserver 127.0.0.1#53 for domain in-addr.arpa Dec 1 13:21:33 bastion dnsmasq[30201]: using nameserver 127.0.0.1#53 for domain cluster.local
分析网络功能
你可能有成千上万的云原生应用程序在一个复杂的网络环境中为业务提供服务,其中可能包括虚拟化、多云和混合云。这意味着,作为故障排除的一部分,你应该分析网络连接是否正常工作。弄清 Linux 服务器中网络功能的有用命令包括:ip addr、traceroute、nslookup、dig 和 ping 等。例如,这是 ip addr show 命令的输出: