搬瓦工ubuntu network is unreachable 解决

date
May 6, 2022
slug
fix-bandwagon-snapshot-network-unreachable
status
Published
summary
小技巧
tags
tip
type
Post
URL

Problem & Summary

    Solution

    traceroute www.google.com
    traceroute中第一跳地址会是网关,直接提示network is unreachable可能是网关都不可达?
    ip -4 route show
    route
    
    copy 一份 /etc/sysctl.conf
    iptables -F; iptables -t nat -F; iptables-save > /etc/iptables.up.rules
    
    # network config; 改成静态试试
    vi /etc/network/interfaces
    auto lo
    iface lo inet loopback
    auto eth0
    iface eth0 inet dhcp
    auto eth1
    iface eth1 inet dhcp
    =>
    auto lo
    iface lo inet loopback
    auto eth0
    iface eth0 inet static
    address 123.123.123.8 # 需要替换成自己的 IP 地址
    netmask 255.255.255.0
    gateway 123.123.123.1 # 需要替换,把自己的 IP 地址前三位保持不变,最后一位变成 1
    dns-nameservers 8.8.8.8
    
    # dns
    vim /etc/resolv.conf
    nameserver 8.8.8.8
    
    # 增加默认网关
    route add default gw 80.251.216.1
    
    ip addr flush eth0
    
    systemctl restart networking.service
    /etc/init.d/networking restart

    bwh5g5t正常snapshot上面的文件

    bwh5g5t at ~ ❯ ip -4 route show
    default via 80.251.216.1 dev eth0
    80.251.216.0/22 dev eth0 proto kernel scope link src 80.251.216.70
    172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1
    172.18.0.0/16 dev br-b7bc5234bbce proto kernel scope link src 172.18.0.1
    172.19.0.0/16 dev br-134f1a8d02c7 proto kernel scope link src 172.19.0.1 linkdown
    172.20.0.0/16 dev br-363b51b8662c proto kernel scope link src 172.20.0.1 linkdown
    172.21.0.0/16 dev br-d7970f02384e proto kernel scope link src 172.21.0.1
    172.26.0.0/16 dev br-6d397ca820ae proto kernel scope link src 172.26.0.1
    192.168.64.0/20 dev br-08a11445b486 proto kernel scope link src 192.168.64.1
    192.168.80.0/20 dev br-18f0122ea240 proto kernel scope link src 192.168.80.1
    192.168.176.0/20 dev br-17c05cc0cc4a proto kernel scope link src 192.168.176.1
    
    
    bwh5g5t at ~ ❯ route
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    default         80.251.216.1.16 0.0.0.0         UG    0      0        0 eth0
    80.251.216.0    0.0.0.0         255.255.252.0   U     0      0        0 eth0
    172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
    172.18.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-b7bc5234bbce
    172.19.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-134f1a8d02c7
    172.20.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-363b51b8662c
    172.21.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-d7970f02384e
    172.26.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-6d397ca820ae
    192.168.64.0    0.0.0.0         255.255.240.0   U     0      0        0 br-08a11445b486
    192.168.80.0    0.0.0.0         255.255.240.0   U     0      0        0 br-18f0122ea240
    192.168.176.0   0.0.0.0         255.255.240.0   U     0      0        0 br-17c05cc0cc4a
    
    bwh5g5t at ~ ❯ cat  /etc/resolv.conf
    nameserver 1.0.0.1
    nameserver 8.8.8.8
    nameserver 1.1.1.1
    nameserver 8.8.4.4
    nameserver 74.82.42.42
    
    # ifconfig
    eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 80.251.216.70  netmask 255.255.252.0  broadcast 80.251.219.255
            inet6 fe80::a8aa:ff:fe17:a7d3  prefixlen 64  scopeid 0x20<link>
            ether aa:aa:00:17:a7:d3  txqueuelen 1000  (Ethernet)
            RX packets 173117  bytes 404084412 (404.0 MB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 112397  bytes 8125083 (8.1 MB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 169.254.254.254  netmask 255.255.255.255  broadcast 169.254.254.254
            inet6 fe80::b8aa:ff:fe17:a7d3  prefixlen 64  scopeid 0x20<link>
            ether ba:aa:00:17:a7:d3  txqueuelen 1000  (Ethernet)
            RX packets 4  bytes 1368 (1.3 KB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 15  bytes 2234 (2.2 KB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

    bwh2g2t

    bwh2g2t at ~ ❯ route
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    default         80.251.212.1.16 0.0.0.0         UG    0      0        0 eth0
    80.251.212.0    0.0.0.0         255.255.252.0   U     0      0        0 eth0
    172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
    172.18.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-0bd2c5e99592
    172.21.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-d7970f02384e
    172.26.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-6d397ca820ae

    Screenshots

     

    © Ying Bun 2021 - 2024