我有以下设置:
--> router X provided by my ISP - no admin access to it (LAN IP 192.168.5.1)
--> network N1 with devices and PCs (DHCP clients of X - IPs 192.168.5.x)
--> ubuntu server Y acting as a gateway (static IP 192.168.5.110)
--> network N2 of PCs and devices (DHCP clients of Y - 10.0.0.x)
服务器 Y 被设置为 N2 的网关并且工作正常,但是我的要求是网络 N2 上的所有设备都不能访问网络 N1 上的设备(插入路由器 X 和服务器 Y 之间的任何设备) - 换句话说,Y 的配置方式是桥接 X 和它自己之间的连接。
能实现吗?
/etc/dhcp/dhcpd.conf的内容:
subnet 10.0.0.0 netmask 255.255.255.0 {
range 10.0.0.100 10.0.0.150;
default-lease-time 3600;
max-lease-time 3600;
option subnet-mask 255.255.255.0;
option broadcast-address 10.0.0.255;
option routers 10.0.0.1;
option domain-name-servers 192.168.5.1;
option domain-name "N2";
}
/etc/network/interfaces的内容:
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.5.110
netmask 255.255.255.0
gateway 192.168.5.1
dns-nameservers 192.168.5.1
broadcast 192.168.5.255
auto eth1
iface eth1 inet static
address 10.0.0.1
netmask 255.255.255.0
gateway 10.0.0.1
感谢您提供的任何帮助。
答案1
我设法设置了似乎可以解决问题的 iptables 规则:
sudo iptables -I FORWARD 1 -i eth1 -o eth0 -s 10.0.0.0/24 -d 192.168.5.1 -j ACCEPT
sudo iptables -I FORWARD 2 -i eth1 -o eth0 -s 10.0.0.0/24 -d 192.168.5.0/24 -j DROP