1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

OpenVPN - how to set static IP address for clients?

Discussion in 'Tomato Firmware' started by Jason404, Mar 18, 2012.

  1. Jason404

    Jason404 Addicted to LI Member

    How would I force an OpenVPN client to have a particular IP address?

    I am connecting a could-based replica DC through OpenVPN, so I need to make sure that it always has the same IP address (172.31.111.150).

    Thanks.
     
  2. EOC_Jason

    EOC_Jason Networkin' Nut Member

    IP addresses for machines are handled by local DHCP servers, so that is what you would need to configure. The OpenVPN link would be (mostly) transparent as all it provides is an alternate route for traffic.
     
  3. Jason404

    Jason404 Addicted to LI Member

    The OpenVPN subnet for this connection is 172.31.111.144/28. The DC client has been assigned 172.31.111.150 and ipconfig /all says that the DHCP server has the address 172.31.111.149. I assume this is within the Tomato OpenVPN server (172.31.111.1, OpenVPN interface - 172.31.111.145).
     
  4. Jason404

    Jason404 Addicted to LI Member

    When using standalone OpenVPN (not integrated into Tomato), there is a directive:

    client-config-dir /etc/openvpn/ccd

    ..and in the CCD directory, you the comatined client files can have this to set a static IP address:

    for Windows Clients:
    #ifconfig-push clientIP serverIP
    ifconfig-push 172.31.111.150 172.31.111.145
    for Linux Clients:
    #ifconfig-push clientIP Netmask
    ifconfig-push 172.31.111.150 255.255.255.252

    How do I do this in the OpenVPN server config on Tomato? Does it go in Custom Configuration somehow?
     
  5. Jason404

    Jason404 Addicted to LI Member

    If anybody else wants to know how to do this, you simply add the usual configuration directives in the Custom Configuration section:

    ccd-exclusive
    client-config-dir /cifs1/CCD

    ...and then have a file named the same as the client Common Name in the cifs/jffs share with the IP address and subnet mask:

    iroute 172.31.111.150 255.255.255.252
     
  6. occamsrazor

    occamsrazor Network Guru Member

    Maybe I'm misunderstanding something.... but can't you just set a static DHCP IP using the normal Tomato router functions based on the MAC address of the remote client's OpenVPN interface? That's what I've done in the past - just got the remote client to connect, find its entry in the Device List, then just assign that MAC a static DHCP address. I guess perhaps your setup is more complicated....
     

Share This Page