我在相对较新的 Ubuntu Server 17.04 安装中遇到了网络问题。计算机有两个网络端口(在主板上):一个连接到调制解调器,提供 WAN IP,另一个连接到路由器,提供 LAN IP。
问题是两个接口都获得了 IP,但只能通过 LAN 接口的 SSH ping/访问计算机。ping WAN IP 会超时。我希望 WAN 接口能够正常工作,以便最终将计算机用作路由器。
我尝试过的:
- 切换到 systemd-networkd,这似乎暂时解决了问题,但随后它开始为接口提供自分配的 IP。我恢复使用基本的 /etc/network,现在我有 IP,但没有 WAN 连接。我有互联网连接,但这似乎是通过 LAN 接口进行的。
- 禁用防火墙(sudo ufw disable),无效
- 多次重新启动并 ifdown/ifup 接口
- 禁用 IPv6
编辑:
我现在注意到我的系统日志中有很多 DHCPREQUEST 消息,这可能与问题有关:
Aug 31 11:40:22 home dhclient[1450]: DHCPREQUEST of xx.xxx.13.139 on enp3s0 to xxx.xxx.132.120 port 67 (xid=0x1b73764)
Aug 31 11:47:31 home dhclient[1450]: message repeated 29 times: [ DHCPREQUEST of xx.xxx.13.139 on enp3s0 to xxx.xxx.132.120 port 67 (xid=0x1b73764)]
Aug 31 11:47:47 home dhclient[1450]: DHCPREQUEST of xx.xxx.13.139 on enp3s0 to xxx.xxx.132.120 port 67 (xid=0x1b73764)
ifconfig:
enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet xx.xxx.13.139 netmask 255.255.224.0 broadcast xx.xxx.31.255
ether xx:xx:xx:xx:xx:xx txqueuelen 1000 (Ethernet)
RX packets 16438 bytes 988374 (988.3 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 52 bytes 7615 (7.6 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255
ether xx:xx:xx:xx:xx:xx txqueuelen 1000 (Ethernet)
RX packets 518 bytes 50724 (50.7 KB)
RX errors 0 dropped 1 overruns 0 frame 0
TX packets 116 bytes 15468 (15.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1000 (Local Loopback)
RX packets 2 bytes 100 (100.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2 bytes 100 (100.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
路线:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default gateway 0.0.0.0 UG 0 0 0 enp4s0
xx.xxx.0.0 0.0.0.0 255.255.224.0 U 0 0 0 enp3s0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 enp4s0
在 /etc/网络/接口:
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# WAN
auto enp3s0
iface enp3s0 inet dhcp
# LAN
allow-hotplug enp4s0
iface enp4s0 inet static
address 192.168.0.2
netmask 255.255.255.0
gateway 192.168.0.1