I have an asterisk server behind a NAT'd gateway that is using iptables. Internally, I have no problems connecting to asterisk. I would like to be able to use a sip softphone from outside the gateway, and become an extension on my asterisk PBX.
Here are the iptables commands in my current setup (that don't work):
$iptables -A FORWARD -i eth0 -p tcp --dport 5060:5080 -j ACCEPT
$iptables -t nat -A PREROUTING -i eth0 -p tcp -d x.x.x.x --dport 5060:5080 -j DNAT --to-destination 192.168.1.40:5060:5080
$iptables -A FORWARD -i eth0 -p udp --dport 10000:20000 -j ACCEPT
$iptables -t nat -A PREROUTING -i eth0 -p udp -d x.x.x.x --dport 10000:20000 -j DNAT --to-destination 192.168.1.40:10000:20000
192.168.1.40 is the address of my Asterisk server. x.x.x.x is my external IP address. I got these commands by copying commands I have successfully used to forward the ports used for VNC, and because I saw stuff on the internet that said I needed to hand the RTP ports as well as SIP.
Why doesn't this work, and what commands will work ?