分类: BSD
2008-05-05 08:23:28
According to RFC 1918, you can use the following IP networks for private nets which will never be connected to the Internet:Class A 10.0.0.0 - 10.255.255.255 255.0.0.0 Class B 172.16.0.0 - 172.31.255.255 255.255.0.0 Class C 192.168.0.0 - 192.168.255.255 255.255.255.0 |
options IPFIREWALL options IPFIREWALL_DEFAULT_TO_ACCEPT options IPFIREWALL_VERBOSE options IPFIREWALL_VERBOSE_LIMIT=10 options IPDIVERT |
config GENERIC cd ../../compile/GENERIC make depend all install |
# 第一片網卡固有的設定: ifconfig_vr0="inet 211.75.215.107 media 100baseTX netmask 255.255.255.0" # 只用一片網卡時,將第一片網卡虛擬出另一個IP(如果使用兩片網卡,就不要設這一行,或者註解起來也可)。 # 如果你有第二片網卡時,將此網卡設定如下(當然啦,這一行的註解就應該取消,第二塊網卡才會有作用)。 # 宣告本主機可做為gateway(通訊閘) # 宣告防火牆(IP-FIREWALL) # 定義 NATD 的網路卡介面,應定義在設定 public IP 的網卡代號上。 |
開機後,若要更改NAT的設定:
kill -KILL `cat /var/run/natd.pid`
natd -redirect_port tcp 192.168.1.220:80 211.75.215.107:80 -interface vr0
natd 8668/divert |
#!/bin/sh # ================ # 清除所有防火牆過濾的規則(歸零),ipfw詳細語法請:man ipfw /sbin/ipfw -f flush # ================ # 先定義 deny,由此處開始定義防火牆過濾的規則 # 我是比較狠一點,要擋就全部都擋住,滴水不漏。 # ================ # 這裡的 all ,是指 /etc/services 檔案中所記載的各項服務名稱。 # 如此設定防火牆規則後,他連 ping 我的主機都別想了。 # 以下的 IP 或 Class C ,不是有入侵動作、就是亂寄廣告信,我不歡迎這種人,所以拒絕提供任何服務。 # ----- spam ----- # /sbin/ipfw add deny all from 211.22.166.45 to any /sbin/ipfw add deny all from 216.153.141.44 to any /sbin/ipfw add deny all from 192.72.80.7 to any /sbin/ipfw add deny all from 61.220.214.251 to any /sbin/ipfw add deny all from 61.154.244.0/24 to any /sbin/ipfw add deny all from 140.113.75.248 to any /sbin/ipfw add deny all from 61.16.11.0/24 to any /sbin/ipfw add deny all from 61.217.135.209 to any /sbin/ipfw add deny all from 61.225.169.0/24 to any /sbin/ipfw add deny all from 61.227.50.0/24 to any /sbin/ipfw add deny all from 61.228.0.0/24 to any /sbin/ipfw add deny all from 63.119.26.216 to any /sbin/ipfw add deny all from 64.94.217.0/24 to any /sbin/ipfw add deny all from 64.114.31.2 to any /sbin/ipfw add deny all from 65.30.9.44 to any /sbin/ipfw add deny all from 65.32.169.173 to any /sbin/ipfw add deny all from 139.175.252.20 to any /sbin/ipfw add deny all from 163.29.255.0/24 to any /sbin/ipfw add deny all from 192.72.81.0/24 to any /sbin/ipfw add deny all from 193.126.14.83 to any /sbin/ipfw add deny all from 195.190.94.200 to any /sbin/ipfw add deny all from 203.79.166.137 to any /sbin/ipfw add deny all from 203.198.160.118 to any /sbin/ipfw add deny all from 203.146.235.0/24 to any /sbin/ipfw add deny all from 203.204.139.129 to any /sbin/ipfw add deny all from 206.154.48.203 to any /sbin/ipfw add deny all from 207.254.20.124 to any /sbin/ipfw add deny all from 210.85.75.0/24 to any /sbin/ipfw add deny all from 210.208.48.108 to any /sbin/ipfw add deny all from 211.20.175.110 to any /sbin/ipfw add deny all from 211.21.140.133 to any /sbin/ipfw add deny all from 211.21.191.123 to any /sbin/ipfw add deny all from 211.75.204.163 to any /sbin/ipfw add deny all from 211.75.220.228 to any /sbin/ipfw add deny all from 211.78.1.3 to any /sbin/ipfw add deny all from 211.114.30.1 to any /sbin/ipfw add deny all from 212.67.193.231 to any /sbin/ipfw add deny all from 216.4.172.254 to any /sbin/ipfw add deny all from 217.11.131.182 to any /sbin/ipfw add deny all from 217.115.144.0/24 to any # ================ # 這一行是定義NAT的通行,如果只是設定 firewall 的話,不需要設定這一行。 /sbin/ipfw add divert natd all from any to any via vr0 # ================ # 其餘的(all)都放行了,NAT 和 FireWall 都需要設定這一行。 /sbin/ipfw add pass all from any to any |
Flushed all rules. 00100 deny ip from 140.113.75.248 to any 00200 deny ip from 211.78.1.3 to any 00300 deny ip from 211.21.191.123 to any 00400 deny ip from 64.114.31.2 to any 00500 divert 8668 ip from any to any via vr0 00600 allow ip from any to any |
Jul 9 23:54:18 www sendmail[4378]: f69FsHY04378: from= |