網關防火墻基礎配置
阿新 • • 發佈:2018-07-30
rest 針對性 策略 lin 防火墻 mef ice 針對 linu 網關服務器上的防火墻簡略配置:
- vim /etc/sysctl.conf 修改內核參數 net.ipv4.ip_forward=1【開啟路由轉發】
sysctl -p 【使配置生效】 - iptables -t nat -A POSTROUTING -s 【內網網段/24】-o eth0 【外網網卡】-j
SNAT--to-source 【公網地址】{配置SNAT策略使內網主機共享固定IP上網} - iptables -t nat -A POSTROUTING -s 【內網網段/24】-o ppp0 -j MASQUERADE
【共享動態ip地址上網】 - iptables -t nat -A PREROUTING -d 【公網地址】-i eth0 【外網網卡】-p
{配置DNAT策略發布企業內部web服務器} -
對於linux網關服務器來說,在默認拒絕的情況下,若要實現共享上網,除了正常的SNAT策略以外,還需要放行內網PC與Internet中的DNS、Web、FTP等服務的通信。
iptables -A FORWARD -s 【內網網段/24】-o【外網網卡】-p udp --dport 53 -j ACCEPT
iptables -A FORWARD -s 【內網網段/24】-o【外網網卡】-p tcp --dport 80 -j ACCEPT
iptables -A FORWARD -s 【內網網段/24】-o【外網網卡】-p tcp --dport 20:21 -j ACCEPT
,RELATED -j ACCEPT - service iptables save
iptables-save >/tmp/somefile 【導出防火墻配置】
iptalbles-restore </tmp/somefile 【導入防火墻配置】
具體工作中,根據實際情況有針對性的設計,並做好整體測試,避免因規則不當而導致的網絡通信故障。
網關防火墻基礎配置