HamVOIP OpenVPN Port Forwarding

VPS Server:

sudo apt-get update

sudo apt-get upgrade

sudo apt-get install iptables-persistent

sudo apt-get install curl

curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh

chmod +x openvpn-install.sh

./openvpn-install.sh

IPTables

iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 ! -d 10.8.0.0/24 -j SNAT --to-source
your.public.ip.address
iptables -t nat -A POSTROUTING -s 10.8.0.2/32 ! -d 10.8.0.2/32 -j SNAT --to-source
your.public.ip.address

iptables -t nat -A PREROUTING -d your.public.ip.address/32 -i eth0 -p udp -m udp --dport 4569
-j DNAT --to-destination 10.8.0.2:4569

iptables -t nat -A PREROUTING -d your.public.ip.address/32 -i eth0 -p tcp -m tcp --dport 5038
-j DNAT --to-destination 10.8.0.2:5038

iptables-save
netfilter-persistent save

HamVOIP:

pacman -R openvpn
pacman -Sy hamvoip-openvpn

nano /usr/local/etc/allstar.env

export VPN_Network=”enabled”

Install OpenVPN config to /etc/openvpn/client.conf

Remove "persist-tun" from ovpn configuration. If this is added, autoreconnect will not work properly. 

Reboot

 

DD-WRT Firewall

iptables -t nat -I PREROUTING -i tun1 -p tcp --dport 8080 -j DNAT --to 192.168.1.100:8080
iptables -I FORWARD -i tun1 -p tcp -d 192.168.1.100 --dport 8080 -j ACCEPT

Forward All Ports from VPN on DD-WRT Firewall (1-65535)

iptables -t nat -I PREROUTING -i tun1 -p tcp --dport 1:65535 -j DNAT --to 192.168.1.100:1-65535
iptables -I FORWARD -i tun1 -p tcp -d 192.168.1.100 --dport 1:65535 -j ACCEPT

iptables -t nat -I POSTROUTING -j MASQUERADE

DNS Fix

nano /etc/resolv.conf

nameserver 127.0.0.1
nameserver 1.1.1.1
nameserver 1.0.0.1
nameserver 8.8.8.8
nameserver 8.8.4.4