我正在配置自己的服务器作为路由器。它有三个接口,两个网线和一个 wifi。
下列的本文配置接入点。设置网桥后,我遇到了默认网关问题。系统总是选择网桥作为网关,这是错的。
接口是:eth0->链接我的ISP(DHCP - 动态地址),eth1->内部网络,wlan0->wifi。
eth1 和 wlan0 是桥接的。
一些数据:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.22.11 0.0.0.0 UG 0 0 0 zbr0
192.168.11.64 0.0.0.0 255.255.255.192 U 0 0 0 eth0
192.168.22.0 0.0.0.0 255.255.255.128 U 0 0 0 zbr0
eth0 Link encap:Ethernet HWaddr 54:be:f7:09:67:7a
inet addr:192.168.11.77 Bcast:192.168.11.127 Mask:255.255.255.192
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:245 errors:0 dropped:0 overruns:0 frame:0
TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:18860 (18.4 KiB) TX bytes:1559 (1.5 KiB)
Interrupt:20 Memory:f7e00000-f7e20000
eth1 Link encap:Ethernet HWaddr 54:be:f7:09:67:7b
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:367 errors:0 dropped:0 overruns:0 frame:0
TX packets:254 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:62760 (61.2 KiB) TX bytes:37744 (36.8 KiB)
Interrupt:18 Memory:f7c00000-f7c20000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:2 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:190 (190.0 B) TX bytes:190 (190.0 B)
zbr0 Link encap:Ethernet HWaddr 54:be:f7:09:67:7b
inet addr:192.168.22.11 Bcast:192.168.22.127 Mask:255.255.255.128
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:285 errors:0 dropped:0 overruns:0 frame:0
TX packets:245 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:32960 (32.1 KiB) TX bytes:35426 (34.5 KiB)
如何通过接口而不是 IP 地址设置网关?
接口配置:
auto lo
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet dhcp
allow-hotplug eth1
iface eth1 inet manual
allow-hotplug wlan0
iface wlan0 inet manual
auto zbr0
iface zbr0 inet static
bridge_ports eth1
address 192.168.22.11
netmask 255.255.255.128
network 192.168.22.0
broadcast 192.168.22.127
gateway 192.168.22.11
答案1
删除路由表中的默认路由,并将其替换为类似route add default gw 192.168.11.1 eth0