OpenVPN Configuration - Multiple Ports

Hello,

I currently have my OpenVPN connection setup to accept connections from: TCP 443, TCP 8080, and UDP 1194. Is there a way that I can have all three of these server configurations assign from just one IP pool? (For ex. 10.7.0.x)

Right now they all assign on their own IP pools:

TCP 443 - 10.7.0.1

TCP 8080 - 10.8.0.1

UDP 1194 - 10.9.0.1

Thank you in advance!

3 Replies

I'm assuming you're currently running 3 different OpenVPN servers - one for each port?

You can run just one OpenVPN server for all TCP ports, and just one OpenVPN server for all UDP ports, and give each server its own IP address pool. Then you can use iptables to redirect ports. Unfortunately it's not possible to combine the TCP and UDP servers because TCP and UDP are very different protocols.

If you want to do this with your TCP servers, choose just one of the ports to run OpenVPN on (let's say 443), and then set up the following iptables rule for the other port (8080):

iptables -t nat -A PREROUTING -d X.X.X.X -p tcp --dport 443 -j DNAT --to-destination :8080

(replace X.X.X.X with your server's IP address)

Thanks for the suggestion. But, the problem I am trying to solve is a little more complicated. My email server is located at 10.8.0.1 and I currently use dnsmasq to set internal-network.example.com to route to 10.8.0.1 so that my SSL certificate would be valid for *.example.com.

However, I have now run into the problem where if I connect via TCP 443, there is no set route to 10.8.0.1 and it causes it to try to connect to the local wireless AP I am connected to, which causes my connection to fail.

Is there a solution to this problem? Thanks! :D

Yeah, you can configure each VPN server to push a route to the other VPN subnets, by adding options like these to the config files:

push "route 10.7.0.0 255.255.255.0"
push "route 10.8.0.0 255.255.255.0"
push "route 10.9.0.0 255.255.255.0"

Now when VPN clients connect they should get routes to your mail server at 10.8.0.1 regardless of which VPN server they connected to.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct