/sbin/sysctl net.ipv4.ip_forwardif return
net.ipv4.ip_forward = 1
then it is enabled. if not edit /etc/sysctl.conf
and set net.ipv4.ip_forward = 1
. 2. COnfigure and restart iptables
/sbin/sysctl -p /etc/sysctl.conf /sbin/service iptables restart3. Adding IP forwarding rules to IpTables
/sbin/iptables -I FORWARD 1 -m state --state ESTABLISHED,RELATED -j ACCEPT /sbin/iptables -I FORWARD 1 -p tcp --dport 80 -j ACCEPT /sbin/iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 10.0.1.1:8080 /sbin/iptables -t nat -A POSTROUTING -j MASQUERADE /sbin/service iptables save /sbin/service iptables restartThe content of /etc/sysconfig/iptables files looks like:
# Generated by iptables-save v1.3.5 on Fri Mar 8 10:27:21 2013 *nat :PREROUTING ACCEPT [0:0] :POSTROUTING ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A PREROUTING -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.0.1.1:8080 -A POSTROUTING -j MASQUERADE COMMIT # Completed on Fri Mar 8 10:27:21 2013 # Generated by iptables-save v1.3.5 on Fri Mar 8 10:27:21 2013 *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [234:26336] :RH-Firewall-1-INPUT - [0:0] -A INPUT -j RH-Firewall-1-INPUT -A FORWARD -p tcp -m tcp --dport 80 -j ACCEPT -A FORWARD -m state --state RELATED,ESTABLISHED -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 -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 -j REJECT --reject-with icmp-host-prohibited COMMIT
No comments:
Post a Comment