#
# 屏蔽 来自 microsoft 的站点:
[0:0] -A INPUT -s 207.46.0.0/255.255.0.0 -j DROP
[0:0] -A INPUT -d 207.46.0.0/255.255.0.0 -j DROP
#
# 防止IP欺骗:
# 所谓的IP欺骗就是指在IP包中存在着不可能的IP源地址或目标地址。
# eth1是一个与外部Internet相连,而192.168.20.0则是内部网的网络号,
# 也就是说,如果有一个包从eth1进入主机,而说自己的源地址是属于
# 192.168.20.0网络,或者说它的目标地址是属于这个网络的,那么这显
# 然是一种IP欺骗,所以我们使用DROP将这个包丢弃。
[0:0] -A INPUT -d 192.168.1.0/255.255.255.0 -i eth1 -j DROP
[0:0] -A INPUT -s 192.168.1.0/255.255.255.0 -i eth1 -j DROP
#
# 同样的,如果有包要通过eth1向Internet,而且它的源地址或目标地址是属于
# 网络192.168.20.0,那么显然也是不可能的。我们仍然使用DROP将它丢弃。
[0:0] -A OUTPUT -d 192.168.1.0/255.255.255.0 -o eth1 -j DROP
[0:0] -A OUTPUT -s 192.168.1.0/255.255.255.0 -o eth1 -j DROP
#
# 防止广播包从IP代理服务器进入局域网:
[0:0] -A INPUT -s 255.255.255.255 -i eth0 -j DROP
[0:0] -A INPUT -s 224.0.0.0/224.0.0.0 -i eth0 -j DROP
[0:0] -A INPUT -d 0.0.0.0 -i eth0 -j DROP
# 当包的源地址是255.255.255.255或目标地址是0.0.0.0,则说明它是一个
# 广播包,当广播包想进入eth0时,我们就应该DENY,丢弃它。而240.0.0.0/3
# 则是国际标准的多目广播地址,当有一个源地址是属于多目广播地址的包,
# 我们将用DROP策略,丢弃它。
#
# 屏蔽 windows xp 的 5000 端口(这个端口是莫名其妙的 !)
[0:0] -A INPUT -p tcp -m tcp --sport 5000 -j DROP
[0:0] -A INPUT -p udp -m udp --sport 5000 -j DROP
[0:0] -A OUTPUT -p tcp -m tcp --dport 5000 -j DROP
[0:0] -A OUTPUT -p udp -m udp --dport 5000 -j DROP
# 原来是用来跑 vpn 的,呵呵,我误解了。
#
#
# 防止 Internet 网的用户访问 SAMBA 服务器:
[0:0] -A INPUT -s 61.185.218.x -i eth1 -p tcp -m tcp --dport 137:139 -j DROP
[0:0] -A INPUT -s 61.185.218.x -i eth1 -p udp -m udp --dport 137:139 -j DROP
[0:0] -A INPUT -s 192.168.1.0/255.255.255.0 -i eth0 -p tcp -m tcp --dport 137:139 -j ACCEPT
[0:0] -A INPUT -s 192.168.1.0/255.255.255.0 -i eth0 -p udp -m udp --dport 137:139 -j ACCEPT
[0:0] -A INPUT -s 61.185.218.x/255.255.255.252 -i eth1 -p tcp -m tcp --dport 137:139 -j ACCEPT
[0:0] -A INPUT -s 61.185.218.x/255.255.255.252 -i eth1 -p udp -m udp --dport 137:139 -j ACCEPT
[0:0] -A INPUT -p tcp -m tcp --dport 137:139 -j DROP
[0:0] -A INPUT -p udp -m udp --dport 137:139 -j DROP
#
其中echo "1" > /proc/sys/net/ipv4/ip_forward 用来打开LINUX的IP转发功能。最后一句是定义网段
另外,留意一下你的eth0和eth1有没有被激活,有时候不小心就忘了激活~~
另外,我的sysctl.conf内容:
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl( and
# sysctl.conf(5) for more details.
# Controls IP packet forwarding
#这里也需要打开~~
net.ipv4.ip_forward = 1
# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0
# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0
# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1
# Controls the use of TCP syncookies
net.ipv4.tcp_syncookies = 1
# This value can be between 0 and 100. Close to 0 will mean that the kernel should empty some ram, and a higher value close to 100 will tell the kernel to use the swap memory more often.The default value is 60.
vm.swappiness = 40
# Enable normal users to use the hardware RTC timer
dev.rtc.max-user-freq = 1024