Page 1 of 1

Assign a public ip to openvpn client

Posted: Wed Jul 22, 2015 7:13 am
by Elmasry
For learning purposes, I'm trying to set up openvpn server, so that each connected client would get a unique public ip address.

I have a vps server and I ordered extra 8 static ips and they are rerouted to the vpn server.

What I have so far: - Ubuntu server 14.04 - Working openvpn server and client in tun mode

Current status: All clients connected to openvpn server get assigned the ip address 37.xxx.xxx.112

Plan: Each connected client (Linux pcs running Ubuntu 14.04 as well) gets assigned one of those 8 static ips. They are in the range 46.38.230.249 to 46.38.230.256, but they could have been also non sequential.

I'm just trying to wrap my head around the whole thing, so please help me out:

First solution:

For each user assign a fixed ip:

Add the following line to client1

Code: Select all

ifconfig-push 46.38.230.249 10.8.0.5
And using iptables nat do a prerouting/postrouting between this public ip and some internal ip in that subnet, for example 10.8.0.6 Drawback: No IP pool. One fixed IP per user

Second Solution:

Use ifconfig-pool to assign a pool to the users, BUT 1. This option seems to be used for specifying an internal ip pool not external one 2. It can not be specified multiple times, but what if I have several pools, subnet masks

So to wrap up my question: How to configure openvpn server to allocate a unique public IP address from ip several pools?

Re: Assign a public ip to openvpn client

Posted: Thu Jul 23, 2015 9:26 am
by Traffic
OpenVPN assigns VPN IP addresses not public IP addresses ..

Re: Assign a public ip to openvpn client

Posted: Thu Jul 23, 2015 6:21 pm
by Elmasry
Ok, but after connecting to the openvpn server and querying my PC public IP, I can see that it is the same as the server's public ip

Is this because the client connected to that server and thus obtained its public IP? or did OpenVPN "pushed" that public IP somehow to the server??

Re: Assign a public ip to openvpn client

Posted: Thu Jul 23, 2015 8:03 pm
by Elmasry
Or maybe I should ask this differently....

OpenVPN is running on eth0

I have a bunch of IPs, each defined as its own network interface eth0:0, eth0:1, etc...
This works fine and I'm able to ping/ssh the server on these interfaces.

The main eth0 IP those of eth0:x are in different subnets, hence I cannot connect to OpenVPN via these IPs
Should I create bridges between the main IP and each of those IPs, or should I route their traffic to the main IP?

This all probably sounds quite noob I know, but I'm clueless here

Thanks

Re: Assign a public ip to openvpn client

Posted: Sat Aug 01, 2015 6:33 pm
by Traffic
please post your server and client configs