NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.

Forum Discussion

dfilip's avatar
dfilip
Guide
Jul 01, 2019

OpenVPN w/BR500 and Static IP

I have OpenVPN working from my Cloud (AWS) server to my local LAN network through a BR500 router:

 

    [AWS Cloud Server] <--> [Public Internet] <--> [BR500] <--> [Local LAN Servers]

 

However, I would like to know whether I can get the same local (LAN) IP statically assigned to my OpenVPN connected Cloud server?  The reason is that I want to be able to access services on the Cloud server from my LAN servers, which makes it difficult if the IP address changes.

 

All of the information I have found on the 'Net talks about changing the OpenVPN from the server side -- i.e., no way to request an IP from the client -- and while my first thought was to do so via Setup => LAN Setup => Address Reservation, I'm not sure if my VPN tunnel has a MAC address?  If so, I don't see it on the client side (Linux):

 

tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1500

        inet 192.168.2.2  netmask 255.255.255.0  destination 192.168.2.2

        inet6 fe80::88cb:771a:fe14:b5c3  prefixlen 64  scopeid 0x20<link>

        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 100  (UNSPEC)

        RX packets 474  bytes 61122 (59.6 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 512  bytes 60155 (58.7 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

and my OpenVPN server does not show up on the Dashboard page under 'Attached Devices'.

 

Anyone out there have any ideas as to whether I can always get the same IP assigned by OpenVPN on the BR500, perhaps by matching the certificate?  The alternative would be using DynDNS, but I'd like to avoid that if possible given caching delays, additional complexity to detect IP changes, etc., and I can't use DNS names in (local LAN server) firewall rules.

7 Replies

  • MrJoshW's avatar
    MrJoshW
    NETGEAR Employee Retired

    Hello,

     

    You wouldn't be able to reserve an OpenVPN IP address on the BR500, as the setup on the BR500 is client to site with the OpenVPN. DynDNS would not work as well as the DynDNS would resolve to the WANIP. If your AWS setup supports IPSEC you could setup a site to site configuration from AWS to BR500 and the AWS could then access the resources on the LAN.

    • schumaku's avatar
      schumaku
      Guru - Experienced User

      Check  ifconfig-push

      „Push virtual IP endpoints for client tunnel, overriding the –ifconfig-pool dynamic allocation.” https://openvpn.net/index.php/open-source/documentation/manuals/65-openvpn-20x-manpage.html

       

      ===

      –ifconfig-push local remote-netmaskPush virtual IP endpoints for client tunnel, overriding the –ifconfig-pool dynamic allocation.The parameters local and remote-netmask are set according to the –ifconfig directive which you want to execute on the client machine to configure the remote end of the tunnel. Note that the parameters local and remote-netmask are from the perspective of the client, not the server. They may be DNS names rather than IP addresses, in which case they will be resolved on the server at the time of client connection.

       

      This option must be associated with a specific client instance, which means that it must be specified either in a client instance config file using –client-config-dir or dynamically generated using a –client-connect script.

      Remember also to include a –route directive in the main OpenVPN config file which encloses local, so that the kernel will know to route it to the server’s TUN/TAP interface.

      OpenVPN’s internal client IP address selection algorithm works as follows:

      1 — Use –client-connect script generated file for static IP (first choice).
      2 — Use –client-config-dir file for static IP (next choice).
      3 — Use –ifconfig-pool allocation for dynamic IP (last choice).

      ===

       

      • dfilip's avatar
        dfilip
        Guide

        Yes, I originally looked at this, but the problems is that it requires me dropping a file into the "CCD" (Client Configuration Directory?) directory of the OpenVPN server that matches the name or remote IP or certificate name of the OpenVPN client.  The challenge here is that the BR500 is the OpenVPN server ... and I don't know of any way to drop a client-speciifc file into the BR500's OpenVPN configuration directory???

    • dfilip's avatar
      dfilip
      Guide

      Correct in that the OpenDNS setting configured within the BR500 OpenVPN page would not help -- as that is set to the external (Internet / WAN) IP of the BR500.

       

      However, it looks like on the client side of OpenVPN -- which in my case is a Linux server -- there is a '--ipchange {command}' option, which will run a named script or command, passing the IP address assigned.  I could have this update a different DynDNS name, separate from the BR500's external name, with the IP address that has been assigned by the BR500's OpenVPN server.

       

      There are also 'up' (and 'down') scripts that can be referenced in the client configuration file, which run a script when an OpenVPN connection is brought up (down).  Again, these could be used to update a DynDNS name (separate from the external name of the BR500).

       

      Or, perhaps a bit more daring, even run a remote script to edit the /etc/hosts file(s) of the LAN server(s) with the IP assigned to the Linux server.  This is a bit more brute force, but gets around DNS caching (although I could set the DNS TTL as low as 1 min).

       

      Nonetheless, probably cleaner to do on the OpenVPN server side buy dropping a configuration file into the CCD (Client Configuration Directory?) which matches the client -- and also provides a lot more options, like specifiing a route command -- but alas, I don't know how to drop a file into the /etc/openvpn/ccd directory of the OpenVPN server running within the BR500 (although since the BR500 if running Linux, I know it is there!).

       

      • schumaku's avatar
        schumaku
        Guru - Experienced User

        Can't simply adjust the config pre-made for MacOS (and other systems) and change the script called using the "up" statement in the config file from DHCP to a fixed IP?

NETGEAR Academy

Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology! 

Join Us!

ProSupport for Business

Comprehensive support plans for maximum network uptime and business peace of mind.

 

Learn More