CentOS 端口转发的问题,求帮助
来源: 互联网 发布时间:2017-05-30
本文导语: iptables中的内容 # Generated by iptables-save v1.3.5 on Mon Oct 6 07:55:24 2014 *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [457:46034] :RH-Firewall-1-INPUT - [0:0] -A INPUT -j RH-Firewall-1-INPUT -A INPUT -p tcp -m tcp --dport 8...
iptables中的内容
# Generated by iptables-save v1.3.5 on Mon Oct 6 07:55:24 2014
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [457:46034]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp -m icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p esp -j ACCEPT
-A RH-Firewall-1-INPUT -p ah -j ACCEPT
-A RH-Firewall-1-INPUT -d 224.0.0.251 -p udp -m udp --dport 5353 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 9999 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Completed on Mon Oct 6 07:55:24 2014
# Generated by iptables-save v1.3.5 on Mon Oct 6 07:55:24 2014
*nat
:PREROUTING ACCEPT [7:224]
:POSTROUTING ACCEPT [18:1350]
:OUTPUT ACCEPT [18:1350]
-A PREROUTING -p tcp -m tcp --dport 8080 -j DNAT --to-destination 192.168.1.100:1521
-A POSTROUTING -p tcp -m tcp --dport 1521 -j SNAT --to-source 192.168.1.110
COMMIT
# Completed on Mon Oct 6 07:55:24 2014
##**********************************************************
#本地网卡IP 192.168.1.110
#我想实现 访问192.168.1.110:8080的时候,端口转发到192.168.1.100:1521(是web服务)
#为啥如上面设置不行
# Generated by iptables-save v1.3.5 on Mon Oct 6 07:55:24 2014
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [457:46034]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp -m icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p esp -j ACCEPT
-A RH-Firewall-1-INPUT -p ah -j ACCEPT
-A RH-Firewall-1-INPUT -d 224.0.0.251 -p udp -m udp --dport 5353 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 9999 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Completed on Mon Oct 6 07:55:24 2014
# Generated by iptables-save v1.3.5 on Mon Oct 6 07:55:24 2014
*nat
:PREROUTING ACCEPT [7:224]
:POSTROUTING ACCEPT [18:1350]
:OUTPUT ACCEPT [18:1350]
-A PREROUTING -p tcp -m tcp --dport 8080 -j DNAT --to-destination 192.168.1.100:1521
-A POSTROUTING -p tcp -m tcp --dport 1521 -j SNAT --to-source 192.168.1.110
COMMIT
# Completed on Mon Oct 6 07:55:24 2014
##**********************************************************
#本地网卡IP 192.168.1.110
#我想实现 访问192.168.1.110:8080的时候,端口转发到192.168.1.100:1521(是web服务)
#为啥如上面设置不行
|
have u done this yet?
sysctl -w net.ipv4.ip_forward=1
make sure you enable ip forwarding first
then here is a good reference
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Security_Guide/s1-firewall-ipt-fwd.html
sysctl -w net.ipv4.ip_forward=1
make sure you enable ip forwarding first
then here is a good reference
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Security_Guide/s1-firewall-ipt-fwd.html