[iptables]啟用nat

RHEL
回覆文章
schumi
Site Admin
文章: 696
註冊時間: 2004-04-15 14:30:34

[iptables]啟用nat

文章 schumi »

vi /etc/sysctl.conf

把 net.ipv4.ip_forward = 0
改成
net.ipv4.ip_forward = 1

sysctl -p /etc/sysctl.conf

vi /etc/sysconfig/iptables

代碼: 選擇全部

*nat
:PREROUTING ACCEPT [3191:362093]
:POSTROUTING ACCEPT [38:5551]
:OUTPUT ACCEPT [38:5551]
-A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
COMMIT
# Completed on Fri Sep 26 10:28:34 2014
# Generated by iptables-save v1.4.7 on Fri Sep 26 10:28:34 2014
*filter
:INPUT ACCEPT [22646:28607356]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [11834:1981303]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
# allow 80,8080
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
#
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
回覆文章

回到「Red Hat Enterprise Linux」