以太网桥接后互联网丢失

以太网桥接后互联网丢失

我在 /etc/network/interfaces 的帮助下创建了一个网桥 br-lan。以下是它的内容。

auto lo
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet manual
address 0.0.0.0

#allow-hotplug wlan0
#iface wlan0 inet dhcp
#wpa-ssid "***"
#wpa-psk "***"

allow-hotplug wlan0
iface wlan0 inet static
address 192.168.1.1


auto br-lan 
iface br-lan inet dhcp
    bridge-ports eth0

这是我的 ifconfig

br-lan    Link encap:Ethernet  HWaddr 00:04:9f:04:10:39  
          inet addr:192.168.1.135  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fd00:aaaa::204:9fff:fe04:1039/64 Scope:Global
          inet6 addr: fd45:6807:17db:0:204:9fff:fe04:1039/64 Scope:Global
          inet6 addr: fe80::204:9fff:fe04:1039/64 Scope:Link
          inet6 addr: fd00:aaaa::b5fc:3125:670d:1246/64 Scope:Global
          inet6 addr: fd45:6807:17db:0:b5fc:3125:670d:1246/64 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:515326 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2582 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:167467087 (167.4 MB)  TX bytes:858438 (858.4 KB)

eth0      Link encap:Ethernet  HWaddr 00:04:9f:04:10:39  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:544593 errors:0 dropped:2318 overruns:0 frame:0
          TX packets:11500 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:180696734 (180.6 MB)  TX bytes:3369565 (3.3 MB)

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:132 errors:0 dropped:0 overruns:0 frame:0
          TX packets:132 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:8552 (8.5 KB)  TX bytes:8552 (8.5 KB)

tap0      Link encap:Ethernet  HWaddr 7e:30:05:94:8e:f2  
          inet6 addr: fe80::7c30:5ff:fe94:8ef2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8904 errors:0 dropped:0 overruns:0 frame:0
          TX packets:508861 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:2508423 (2.5 MB)  TX bytes:173019552 (173.0 MB)

wlan0     Link encap:Ethernet  HWaddr 00:17:7c:22:88:18  
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

tap0 是在其他地方的脚本中创建的,这与我无关。此外,wlan0 被设为静态,以形成无线热点。

现在eth0无法上网,无法 ping google.com 等。即使可以 ping 网络中的其他 IP,也无法上网。但无线连接的同一网络可以上网。所以我不得不假设问题出在 的桥接上eth0。我还需要桥接到eth0才能wlan0创建wifi hotspot互联网。我尝试route add default gw 192.168.1.1从此链接https://ubuntuforums.org/showthread.php?t=1331580 但仍然无法 ping google.com。它显示

ping: unknown host google.com

编辑:我已经解决了互联网问题并回答了。但我的问题仍然是如何从 连接到互联网wlan0eth0通过创建更多桥接?有没有什么route命令?

答案1

我现在明白我的问题了。当我尝试创建相同的 192.168.1.1 网关时,发生了 IP 冲突。我将 wlan0 静态 IP 更改为 192.168.2.1。我觉得很愚蠢。我如何将互联网从 eth0(现在在 br-lan 上)桥接到 wlan0,有什么想法吗?

相关内容