我对此完全陌生,正在为练习实验室设置路由器和客户端。客户端可以ping通路由器,路由器也可以ping通客户端。路由器可以访问互联网,但客户端不能。我不知道为什么会这样,有人可以帮忙吗?
这是我所有的设置。
客户端 /etc/netplan/01-network-manager-all.yaml
network:
version: 3
renderer: networkd
ethernets:
enp0s3:
dhcp4: no
addresses:
- 10.0.20.21/24
gateway4: 10.0.20.1
nameservers:
addresses: [10.0.20.15, 8.8.8.8]
路由器:/etc/network/interfaces
source /etc/nework/interfaces.d/*
auto lo
iface lo inet loopback
#NAT Network
allow-hotplug enp0s3
iface enp0s3 inet static
address 10.0.2.15
netmask 255.255.255.0
gateway 10.0.2.2
dns-nameserver 10.0.0.1
dns-nameserver 8.8.8.8
pre-up iptables-restore < /etc/iptables.rules
#Internal Network
allow-hotplug enp0s8
iface enp0se8 static
address 10.0.20.15
netmask 255.255.255.0
gateway 10.0.20.15
network 10.0.20.0
broadcast 10.0.20.255
iptables 规则
iptables -t nat -A POSTROUTING -o enp0s3 -j MASQUERADE
iptables -A FORWARD -i enp0s3 -o enp0s8 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i enp0s8 -o enp0s3 -j ACCEPT