[SOLVED] VPN with Dedicated IP (Edit /Port Forwarding)

Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking
Goto page Previous  1, 2
Author Message
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12889
Location: Netherlands

PostPosted: Wed Mar 22, 2023 11:34    Post subject: Reply with quote
If lighttpd is residing on the router on port 8080 you have to allow port 8080 on the INPUT chain.

You are allowing the external port but the PREROUTING rule comes first so it is already translated from external to internal port

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
Sponsor
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12889
Location: Netherlands

PostPosted: Wed Mar 22, 2023 11:42    Post subject: Reply with quote
I am updating the instructions (still a WIP):

Port forwarding via WireGuard (oet) interface
This is an example to port forward via the oet interface which might come in handy if you are connected via the oet interface to a server and you want to port forward, this is an example where I chose port 444000 to port forward to port 80 on 192.168.1.1 and assuming you are using the first tunnel e.g. oet1.
Quote:
#!/bin/sh
ext_port=444000
int_port=80
int_ip=192.168.1.1
tunnelnr=1 # adjust for used tunnel number first tunnel is 1

iptables -t nat -D PREROUTING -p tcp -d $(nvram get oet${tunnelnr}_ipaddr) --dport $ext_port -j DNAT --to $int_ip:$int_port
iptables -t nat -D PREROUTING -p udp -d $(nvram get oet${tunnelnr}_ipaddr) --dport $ext_port -j DNAT --to $int_ip:$int_port
iptables -D FORWARD -p tcp -d $int_ip --dport $int_port -j ACCEPT
iptables -D FORWARD -p udp -d $int_ip --dport $int_port -j ACCEPT

#For FORWARDING to LAN Clients
iptables -t nat -I PREROUTING -p tcp -d $(nvram get oet${tunnelnr}_ipaddr) --dport $ext_port -j DNAT --to $int_ip:$int_port
iptables -t nat -I PREROUTING -p udp -d $(nvram get oet${tunnelnr}_ipaddr) --dport $ext_port -j DNAT --to $int_ip:$int_port
iptables -I FORWARD -p tcp -d $int_ip --dport $int_port -j ACCEPT
iptables -I FORWARD -p udp -d $int_ip --dport $int_port -j ACCEPT

#To allow to connect to processes on the router itself e.g. remote administration, lighttpd etc:
iptables -D INPUT -i oet${tunnelnr} -p tcp --dport $int_port -j ACCEPT
iptables -I INPUT -i oet${tunnelnr} -p tcp --dport $int_port -j ACCEPT


Test this script from the command line and if it works: Administration/Commands and Save as Firewall

Furthermore Disable CVE mitigation in the GUI and probably disable SFE (Shortcut Forwarding Engine) on Setup page.

Note
For some providers the oet endpoint address is not the same as the exit address (the address you have to use to connect from the outside).
You can look for the exit address with ipleak.net or dnsleaktest.com.

You can use DDNS on the router to keep track of the exit address in case it changes, make sure you have Use External IP check enabled, take care if you are using Policy Based routing that the router is routed via the tunnel.

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
StillBlue
DD-WRT User


Joined: 11 Apr 2009
Posts: 257
Location: UK

PostPosted: Wed Mar 22, 2023 13:12    Post subject: Reply with quote
OK, adding 8080 to the input chain now makes the port reachable on the port checker.

For some reason though the website still fails to load. Certainly a step in the right direction though.
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12889
Location: Netherlands

PostPosted: Wed Mar 22, 2023 13:17    Post subject: Reply with quote
I do not use lighttpd but maybe you have to use http:// instead of https:// ?
Note not all browser allow http://

When I want to connect to my routers GUI remote administration via the VPN (only for a test not recommended to use in real life for security reasons), I do:
http://<mullvad-external-ip>:53777

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
StillBlue
DD-WRT User


Joined: 11 Apr 2009
Posts: 257
Location: UK

PostPosted: Wed Mar 22, 2023 13:22    Post subject: Reply with quote
I have tried both http and https:://x.x.x.x:portnumber, but nothing.

It does seem lighttpd must be be listening else the port checker wouldn't be receiving a response though. Tried a couple of other port checkers too, and they all now say that the port is open, so I will focus on lighttpd and see if I can work out why it isn't serving up pages.
StillBlue
DD-WRT User


Joined: 11 Apr 2009
Posts: 257
Location: UK

PostPosted: Wed Mar 22, 2023 13:25    Post subject: Reply with quote
Ah, it's something to do with my browser or the fact I am on the VPN. I have just tried through a proxy website viewer and it works.
StillBlue
DD-WRT User


Joined: 11 Apr 2009
Posts: 257
Location: UK

PostPosted: Wed Mar 22, 2023 13:27    Post subject: Reply with quote
It's working perfectly off my phone. For whatever reason, when connected to the VPN, it doesn't work (I assume the VPN isn't allowing it), the computer connected through my phone, no VPN and it works perfectly.

Thank you for all the help.
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12889
Location: Netherlands

PostPosted: Wed Mar 22, 2023 13:27    Post subject: Reply with quote
As a test you can use port 80 instead of 8080 for internal port and you should see your routers http page when doing http://<mullvad-external-ip>:55923
_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
StillBlue
DD-WRT User


Joined: 11 Apr 2009
Posts: 257
Location: UK

PostPosted: Wed Mar 22, 2023 13:37    Post subject: Reply with quote
Just swapped those and strangely it's the same. I can see the router login if I use my phone or turn the VPN off, but over the VPN it doesn't come through.

It seems as if the VPN is trying to protect me from my own website. Laughing
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12889
Location: Netherlands

PostPosted: Wed Mar 22, 2023 14:10    Post subject: Reply with quote
If you connect to the same VPN server I can imagine it does not work.

What if you let your phone connect to a VPN in another server/city?

Mullvad lets you use multiple addresses/cities

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
StillBlue
DD-WRT User


Joined: 11 Apr 2009
Posts: 257
Location: UK

PostPosted: Wed Mar 22, 2023 14:50    Post subject: Reply with quote
Yes, seems fine off another server.

Obviously as my router gives my home network access to the world through the VPN, that is why the devices on it are seeing it through the server that the port is open on.

Everything works fine though.

Thank you again for all your help, it has enabled me once again to get the router doing everything I want it too.
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12889
Location: Netherlands

PostPosted: Wed Mar 22, 2023 15:00    Post subject: Reply with quote
Glad I could be of assistance Smile
_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
StillBlue
DD-WRT User


Joined: 11 Apr 2009
Posts: 257
Location: UK

PostPosted: Tue Mar 28, 2023 8:43    Post subject: Reply with quote
Just for info, so far my experience seems to be that once you have opened a port on the VPN, you always seem to get the same IP (mine hasn't changed through many restarts). I can't confirm this 100% yet, but it does seem that way.

Also something I wasn't that fond of was for the webpages hosted on my router, I was only able to access them through http://domain.com:53777 which wasn't ideal. However setting up my DNS through cloudflare and using it's proxying service allows me to make a port forward here too, so the end users experience is transparent. They just put in http://domain.com or https://domain.com and cloudflare proxies them to the relevent open port on the VPN. It's also an added layer of security.
Goto page Previous  1, 2 Display posts from previous:    Page 2 of 2
Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum