gudul
Hi,
I am running an openVPN server with multiple clients in tun mode.
I noticed that the ipp.txt file written by the directive ifconfig-pool-persist shows IP addressed that are systematically lower than the real IP address by "two".
Can anybody explain this behaviour?
Also I am looking for an example of a script to automatically update the /etc/hosts file (ubuntu) when a new client connects or disconnects, using the directives"client-connect " and "client-disconnect".
I'm using OpenVPN 2.2.1 on Ubuntu Server 12.04LTS
Thanks.
Wheelz
I believe when you connect a client to OpenVPN server it assigns a /30 address which gives two usable hosts. One for the client and another for it's "gateway" back to OpenVPN server (guessing on the latter).
gudul
Yes that's correct there are two addresses allocaed to the client.
I simply wondering why the ipp.txt file doesn't show the client IP address but the client address -2. For instance a client "client1" with IP address 10.8.0.6 (address used to ssh to the client) appears in the ipp.txt file as "client1, 10.8.0.4"
mgrant
I too am wondering about this.
I need to write a script which keeps track of all currently connected clients. I need to know the IP address of each client. I went to look in ipp.txt and noticed that the info there is wrong or misleading. Can I always just add 2 to get the remote client's ip address?
Michael Grant
mgrant
I see, that makes sense! Thanks for that. The 10.8.0.4 is the network part of the address without a host part, the last 2 bits being the host part being 0. The first network, the 10.8.0.0 network, belongs to the server itself.
I've discovered that the definitive place to get the ip address of the connected host seems to be from the log file openvpn-status.log, or to set up a management port with 'management localhost 7505' in the config and telnet to this port and then send status queries. That seems to be the best most accurate info on which clients are currently connected and what their address is.
If you were trying to update /etc/hosts, you might create a shell or perl script to poll the log or the management port and update /etc/hosts accordingly. I've no doubt that someone out there may already have created something to do this.
Michael