Hi, having a small problem with port forwarding using iptables. I want to forward all connections to port 5500 on ppp0, the external interface, to my internal windoze box, 192.168.0.99 on the same port, 5500. Its for a hotline server. here is my iptables init script, very basic, which already works for masquerading, although not very securely.
Any help would be nice on the port forwarding, thanx
#firewall/routing
modprobe ipt_MASQUERADE
/sbin/iptables -F
/sbin/iptables -P INPUT ACCEPT
/sbin/iptables -F INPUT
/sbin/iptables -P OUTPUT ACCEPT
iptables -F OUTPUT
iptables -P FORWARD ACCEPT
iptables -F FORWARD
iptables -A FORWARD -i ppp0 -p tcp --dport 5500 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i ppp0 -p udp --dport 5500 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i ppp0 -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i eth1 -j ACCEPT
iptables -A INPUT -i ppp0 -p TCP --destination-port 139 -j REJECT
iptables -A INPUT -i ppp0 -p UDP --destination-port 139 -j REJECT
iptables -A INPUT -i ppp0 -p TCP --destination-port 6000 -j REJECT
iptables -t nat -F
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
iptables -t nat -A PREROUTING -i ppp0 -p tcp --dport 5500 -j DNAT --to-destination 192.168.0.99:5500
iptables -t nat -A PREROUTING -i ppp0 -p udp --dport 5500 -j DNAT --to-destination 192.168.0.99:5500
iptables -t nat -A PREROUTING -i eth1 -p tcp -d 192.168.0.1 --dport 5500 -j DNAT --to-destination 192.168.0.99:5500
iptables -t nat -A PREROUTING -i eth1 -p udp -d 192.168.0.1 --dport 5500 -j DNAT --to-destination 192.168.0.99:5500
# - Enables packet forwarding by kernel
echo 1 > /proc/sys/net/ipv4/ip_forward
Any help would be nice on the port forwarding, thanx
#firewall/routing
modprobe ipt_MASQUERADE
/sbin/iptables -F
/sbin/iptables -P INPUT ACCEPT
/sbin/iptables -F INPUT
/sbin/iptables -P OUTPUT ACCEPT
iptables -F OUTPUT
iptables -P FORWARD ACCEPT
iptables -F FORWARD
iptables -A FORWARD -i ppp0 -p tcp --dport 5500 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i ppp0 -p udp --dport 5500 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i ppp0 -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i eth1 -j ACCEPT
iptables -A INPUT -i ppp0 -p TCP --destination-port 139 -j REJECT
iptables -A INPUT -i ppp0 -p UDP --destination-port 139 -j REJECT
iptables -A INPUT -i ppp0 -p TCP --destination-port 6000 -j REJECT
iptables -t nat -F
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
iptables -t nat -A PREROUTING -i ppp0 -p tcp --dport 5500 -j DNAT --to-destination 192.168.0.99:5500
iptables -t nat -A PREROUTING -i ppp0 -p udp --dport 5500 -j DNAT --to-destination 192.168.0.99:5500
iptables -t nat -A PREROUTING -i eth1 -p tcp -d 192.168.0.1 --dport 5500 -j DNAT --to-destination 192.168.0.99:5500
iptables -t nat -A PREROUTING -i eth1 -p udp -d 192.168.0.1 --dport 5500 -j DNAT --to-destination 192.168.0.99:5500
# - Enables packet forwarding by kernel
echo 1 > /proc/sys/net/ipv4/ip_forward