釋出DMZ 内部的伺服器,能夠使INTERNET 客戶機通路DMZ 内的郵件服務、網站、FTP,等伺服器,使内部的主機能夠連接配接到INTERNET 發送外網郵件;拒絕不正常的連接配接和黑客的攻擊。
<b>二 </b><b>、主機配置:</b>
<b></b>
具體的配置檔案:
主機名:iptables.bdqn.com
/etc/hosts
/etc/sysconfig/network
内部接口:eth0 IP 192.168.10.2/24
/etc/sysconfig/network-scripts/ifcfg-eth0
公共接口:eth1 IP 202.202.202.100/24
/etc/sysconfig/network-scripts/ifcfg-eth1
<b>三 </b><b>、IPTABLES </b><b>防火牆的具體配置</b>
安裝iptables的軟體包,RedHat系統已經預設安裝
具體的配置規則如下:
首先打開核心的轉發功能:echo “echo 1 > /proc/sys/net/ipv4/ip_forward”> /etc/rc.d/rc/local
iptables -F 清空 此表中的規則
iptables -X 清空 此表中的自定義規則
iptables -Z 清空 此表中的計數器為0
<b>Netfilter </b><b>表的配置</b>:
1. iptables –P INPUT DROP
2. iiptables –P OUTPUT DROP
3. iptables –P FORWARD ACCEPT
4. Iptables –A –p icmp –i eth1 –j DROP
5. iptables -A -INPUT -m limit --limit 3/minute --limit-burst 3
-j LOG --log-level INFO --log-prefix "IP INPUT packr\et died:"
6. iptables -A -FORWARD -m limit --limit 3/minute --limit-burst 3
-j LOG --log-level DEBUG --log-prefix "IP INPUT packr\et died:"
7. iptables -A -OUTPUT -m limit --limit 3/minute --limit-burst 3
<b>Nat </b><b>表的配置</b>:
1. iptables -t nat –P OUTPUT DROP
2. iptables -t nat –P PREROUTING DROP
3. iptables -t nat –P POSTROUTING DROP
4. iptables -t nat –A POSTROUTING –o eth1 –s 192.168.10.0/24 –j SNAT --to 202.202.202.100
#轉換 192.168.10.0 網段的位址到 公網位址接口
5. iptables -t nat –A PREROUTING -i eth1 –p tcp –dport 80 –j DNAT --to 192.168.10.5:80
#轉換外部請求的www服務到 192.168.10.5這台www伺服器上
6. iptables -t nat –A PREROUTING -i eth1 –p tcp –dport 25 –j DNAT --to 192.168.10.4:25
#轉換外部請求的smtp服務到192.168.10.4這個mail伺服器上
7. iptables -t nat –A PREROUTING -i eth1 –p tcp –dport 110 –j DNAT --to 192.168.10.4:110
#轉換外部請求的pop3服務到192.168.10.4這個mail伺服器上
8. iptables -t nat –A PREROUTING -i eth1 –p tcp –dport 20 –j DNAT --to 192.168.10.52:20
#轉換外部請求FTP資料端口20服務到192.168.10.52這個伺服器上
9. iptables -t nat –A PREROUTING -i eth1 –p tcp –dport 21 –j DNAT --to 192.168.10.5:21
#轉換外部請求FTP控制口21服務到192.168.10.52這個伺服器上
10. iptables -t nat –A PREROUTING -i eth1 –p udp –dport 53 –j DNAT --to 192.168.10.3:53
#轉換外部請求DNS udp端口53服務到192.168.10.3這個伺服器上
11. iptables -t nat –A PREROUTING -i eth1 –p tcp –dport 53 –j DNAT --to 192.168.10.3:53
#轉換外部請求DNS tcp端口53服務到192.168.10.3這個伺服器上
<b>Mangle </b><b>表的配置</b>
1. iptables –t mangle –P INPUT DROP
2. iptables –t mangle –P OUTPUT DROP
3. iptables –t mangle –P FORWARD ACCEPT
4. iptables –t mangle –P PREROUTING DROP
5. iptables –t mangle –P POSTROUTING DROP
<b>配置後儲存配置:</b>
iptables-save > /etc/sysconfig/iptables
恢複配置:
iptables-restore < /etc/sysconfig/iptables
防火牆配置完畢
本文轉自andylhz 51CTO部落格,原文連結:http://blog.51cto.com/andylhz2009/189479,如需轉載請自行聯系原作者