How do I assign specific IP address to my OpenVPN server?

Solution 1:

I point you to the documentation for the --server option. If you want to manually specify things do not use the --server option. Instead manually put in the directives you want. See the full man page for a listing of what --server does.

   --server network netmask
          A helper directive designed to  simplify  the  configuration  of
          OpenVPN's  server  mode.   This directive will set up an OpenVPN
          server which will allocate addresses to clients out of the given
  ->>>>   network/netmask.   The  server itself will take the ".1" address
          of the given network for use as the server-side endpoint of  the
          local TUN/TAP interface.

          For example, --server 10.8.0.0 255.255.255.0 expands as follows:

               mode server
               tls-server
               push "topology [topology]"

               ...

               if dev tap OR (dev tun AND topology == subnet):
                 ifconfig 10.8.0.1 255.255.255.0
                 if !nopool:
                   ifconfig-pool 10.8.0.2 10.8.0.254 255.255.255.0
                 push "route-gateway 10.8.0.1"

Solution 2:

For example if you wish that your server uses 10.8.0.254 IP instead 10.8.0.1 then you need to make few changes to your config file.

First change "proto tcp" or "proto udp" line into "proto tcp-server" or "proto udp-server"

Then comment out this line:

server 10.8.0.0 255.255.255.0

and add these lines instead:

mode server
tls-server
ifconfig 10.8.0.254 10.8.0.253
ifconfig-pool 10.8.0.1 10.8.0.252
route 10.8.0.0 255.255.255.0
push "route 10.8.0.254"

restart openvpn service and that is it.