|
|
我们学校机房上网使用linux作路由器,路由表显示如下:
[root@localhost ~]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.100.0 * 255.255.255.0 U 0 0 0 eth0
192.168.150.0 * 255.255.255.0 U 0 0 0 eth2
192.168.140.0 * 255.255.255.0 U 0 0 0 eth1
169.254.0.0 * 255.255.0.0 U 0 0 0 eth2
default 192.168.100.254 0.0.0.0 UG 0 0 0 eth0
[root@localhost ~]#
其中eth0连接校园网、 eth1连接四机房 、eth2连接五机房,当启动ipforward后,四五机房的机器都能通过校园网访问因特网。
现在要实现在上课时只允许两个机房的教师机(ip地址分别是:192.168.140.100、192.168.150.100)可以访问因特网的功能,使用了iptables过滤数据包,配置如下:
[root@localhost ~]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy DROP)
target prot opt source destination
ACCEPT all -- 192.168.140.100 anywhere
ACCEPT all -- 192.168.150.100 anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
[root@localhost ~]#
不知道为什么教师机还不可以上网,我是新手,请各位指点。谢谢! |
|