配置與管理iptables防火牆
1、實訓目的
能熟練完成利用iptables架設企業nat伺服器。
2、專案背景
假如某公司需要internet接入,由isp分配ip位址202.112.113.112。採用iptables作為nat伺服器接入網路,內部採用192.168.1.0/24位址,外部採用202.112.113.112位址。為確保安全需要配置防火牆功能,要求內部僅能夠訪問web、dns及mail三颱伺服器;內部web伺服器192.168.1.100通過埠映象方式對外提供服務。
該公司網路拓撲圖如下圖所示
3、實訓內容
練習linux系統下nat和iptables防火牆的配置。
一、fuwuqi操作
1、fuwuqi的網路介面卡為v8 kehuji為v1
1、基本網路設定,配置外網(eth0)和內網(eth1)
ifconfig eth0 172.30.1.2
ifconfig eth1 192.168.1.2
1.設定預設閘道器和檢視
[root@huyinglan ~]# route add default gw 172.30.1.1
[root@huyinglan ~]# route -n
2、清除防火牆原始規則
[root@huyinglan ~]# iptables -t filter -f
[root@huyinglan ~]# iptables -t nat -f
[root@huyinglan ~]# iptables -t mangle -f
3、給防火牆寫入新的規則(web/dns/電子郵件/smtp/)
[root@huyinglan ~]# iptables -a forward -i eth0 -p tcp --dport 80 -j accept
[root@huyinglan ~]# iptables -a forward -i eth0 -p udp --dport 80 -j accept
[root@huyinglan ~]# iptables -a forward -i eth0 -p tcp --dport 53 -j accept
[root@huyinglan ~]# iptables -a forward -i eth0 -p udp --dport 53 -j accept
[root@huyinglan ~]# iptables -a forward -i eth0 -p tcp --dport 25 -j accept
[root@huyinglan ~]# iptables -a forward -i eth0 -p udp --dport 25 -j accept
[root@huyinglan ~]# iptables -a forward -i eth0 -p tcp --dport 110 -j accept
[root@huyinglan ~]# iptables -a forward -i eth0 -p udp --dport 110 -j accept
[root@huyinglan ~]# iptables -l
4、防止外部主機ping內部主機(防止聯通)
[root@huyinglan ~]# iptables -a input -p icmp --icmp-type 8 -j drop(進入的包是請求包,拒絕)
[root@huyinglan ~]# iptables -a output -p icmp --icmp-type 0 -j drop(出的包是應答的包,拒絕)
[root@huyinglan ~]# iptables -a forward -p icmp --icmp-type 0 -j drop**發的包也拒絕)
[root@huyinglan ~]# iptables -a forward -p icmp --icmp-type 8 -j drop
5、防止外部主機對內部主機進行掃瞄和攻擊(對tcp協議的標誌進行控制)
[root@huyinglan ~]# iptables -a input -p tcp --tcp-flags all all -j drop
[root@huyinglan ~]# iptables -a forward -p tcp --tcp-flags all all -j drop
[root@huyinglan ~]# iptables -a input -p tcp --tcp-flags all none -j drop
[root@huyinglan ~]# iptables -a forward -p tcp --tcp-flags all none -j drop
[root@huyinglan ~]# iptables -a input -p tcp --tcp-flags all fin,urg,psh -j drop(對控制類進行控制)
[root@huyinglan ~]# iptables -a forward -p tcp --tcp-flags all fin,urg,psh -j drop
實現nat功能
6、開啟路由**功能
echo 1 > /proc/sys/net/ipv4/ip_forward
7、啟動iptables的nat功能
iptables -t nat -a postrouting -s 192.168.1.0/24 -o eth0 -j snat --to-source 172.30.1
[root@huyinglan ~]# iptables -a forward -i eth1 -p tcp --dport 80 -j accept
[root@huyinglan ~]# iptables -a forward -i eth1 -p udp --dport 80 -j accept
[root@huyinglan ~]# iptables -a forward -i eth1 -p tcp --dport 53 -j accept
[root@huyinglan ~]# iptables -a forward -i eth1 -p udp --dport 53 -j accept
[root@huyinglan ~]# iptables -a forward -i eth1 -p tcp --dport 25 -j accept
[root@huyinglan ~]# iptables -a forward -i eth1 -p udp --dport 25 -j accept
[root@huyinglan ~]# iptables -a forward -i eth1 -p tcp --dport 110 -j accept
[root@huyinglan ~]# iptables -a forward -i eth1 -p udp --dport 110 -j accept
檢視語句:
[root@huyinglan ~]# iptables -l
[root@huyinglan ~]# iptables -l|more
[root@huyinglan ~]# iptables -l -v|more
二、kuehuji操作
1、重啟網絡卡
service network start
1、設定客戶機連線外網的ip位址
ifconfig eth0 192.168.1.100
2、設定預設閘道器
route add default gw 192.168.1.2
3、設定dns伺服器
vi /etc/resolv.conf
1、按i 將其中乙個位址改為192.168.1.100
2、驗證能否通過nat**上網
資料查詢**:
配置防火牆
今天學了下如何配置網路防火牆,用於過濾乙個段的ip位址不能訪問路由器。第二步開啟防火牆 firewall enable 第三步設定預設,允許或者禁止 firewall default permit 第四步設定規則 acl number 2001 rule 1 deny source 192.168....
防火牆配置
一次在某個防火牆配置策略裡看到如下的 iptables a input p icmp icmp type 8 j accept iptables a forward p icmp icmp type 8 j accept iptables a input p icmp icmp type 11 j ...
防火牆配置
環境 ensp 防火牆usg6000v cloud web端登入 預設使用者名稱和密碼admin admin 123telnet登入 系統檢視下開啟telnet server sys usg6000v1 telnet server enable 建立vty下的策略 usg6000v1 user in...