Here's the hardcoded method. For this method you need to know the IPs. This is the
not recommended method. In the following example, its assumed that '124.66.90.100' is the WAN IP of the VPN server, and '10.0.0.2' is the IP assigned to the client from the VPN.
iptables -A FORWARD -p tcp -i eth0 -d 124.66.90.100 --dport 12000 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -d 10.0.0.2 --dport 12000 -j DNAT --to-destination 124.66.90.100:12000
Below is the softcoded method, and using an up-script.
Below is the recommended method.
Add to server.conf:
client-connect /etc/openvpn/clientconnect.sh
client-disconnect /etc/openvpn/clientdisconnect.sh
script-security 2
You need to create these two files manually (clientconnect.sh and clientdisconnect.sh [remember to make them executable - 755]), and in the clientconnect.sh you put the following code:
PORT = 12000
iptables -A FORWARD -p tcp -i eth0 -d $ifconfig_pool_remote_ip --dport $PORT -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -d $ifconfig_local --dport $PORT -j DNAT --to-destination $ifconfig_pool_remote_ip:$PORT
Since this topic is raised occasionally, there is now a proper how-to.
See:
Board index » Scripting and Customizations » Routing and Firewall Scripts » IPTABLES - Portforwarding