{"id":684,"date":"2013-06-10T23:50:28","date_gmt":"2013-06-10T21:50:28","guid":{"rendered":"http:\/\/michlstechblog.info\/blog\/?p=684"},"modified":"2021-04-06T08:16:47","modified_gmt":"2021-04-06T06:16:47","slug":"openvpn-set-a-static-ip-address-for-a-client","status":"publish","type":"post","link":"https:\/\/michlstechblog.info\/blog\/openvpn-set-a-static-ip-address-for-a-client\/","title":{"rendered":"OpenVPN: Set a static IP Address for a client"},"content":{"rendered":"<div class=\"twoclick_social_bookmarks_post_684 social_share_privacy clearfix 1.6.4 locale-en_US sprite-en_US\"><\/div><div class=\"twoclick-js\"><script type=\"text\/javascript\">\/* <![CDATA[ *\/\njQuery(document).ready(function($){if($('.twoclick_social_bookmarks_post_684')){$('.twoclick_social_bookmarks_post_684').socialSharePrivacy({\"services\":{\"flattr\":{\"uid\":\"Michl\",\"status\":\"on\",\"the_title\":\"OpenVPN%3A%20Set%20a%20static%20IP%20Address%20for%20a%20client\",\"the_excerpt\":\"Hi%2C%0D%0A%0D%0Asometimes%20you%20have%20to%20set%20a%20static%20IP%20Address%20for%20some%20VPN%20Clients.%20Because%20they%20provide%20some%20server%20services%20which%20always%20must%20be%20reached%20at%20the%20same%20IP%20Address.%0D%0A%0D%0AThe%20client%20configuration%20do%20not%20provide%20any%20option%20to%20do%20that%2C%20set%20a%20static%20IP%20Address%20on%20the%20adapter%20itself%20is%20also%20always%20being%20overwritten%20when%20the%20client%20establish%20a%20connection%20to%20the%20OpenVPN%20server.%0D%0A%0D%0ASolution%3A%20Define%20...\",\"txt_info\":\"2 clicks for more data protection:\\r\\n\\r\\nOnly when you click here, the button will be come active and you can send your recommendation to Flattr. When activating, data are transmitted to third parties. \",\"perma_option\":\"off\"}},\"txt_help\":\"When you activate these fields by clicking, information to Flattr may be transferred abroad, and probably may also stored there.\",\"settings_perma\":\"Enable permanently and accept data transmission. \",\"info_link\":\"http:\\\/\\\/www.heise.de\\\/ct\\\/artikel\\\/2-Klicks-fuer-mehr-Datenschutz-1333879.html\",\"uri\":\"https:\\\/\\\/michlstechblog.info\\\/blog\\\/openvpn-set-a-static-ip-address-for-a-client\\\/\",\"post_id\":684,\"post_title_referrer_track\":\"OpenVPN%3A+Set+a+static+IP+Address+for+a+client\",\"display_infobox\":\"on\"});}});\n\/* ]]> *\/<\/script><\/div><p>Hi,<\/p>\n<p>sometimes you have to set a static IP Address for some VPN Clients. Because they provide some server services which always must be reached at the same IP Address.<\/p>\n<p>The client configuration do not provide any option to do that, set a static IP Address on the adapter itself is also always being overwritten when the client establish a connection to the OpenVPN server.<\/p>\n<p>Solution: Define a client specific script at the server.<\/p>\n<p>In this example the openvpn server&#8217;s OS is linux (tap Interface IP 10.1.134.62), the client runs at Windows (static IP 10.1.134.1).<\/p>\n<p>Define a directory where the client scripts should be stored , e.g. \/etc\/openvpn\/staticclients and create the directory<\/p>\n<p><code>mkdir \/etc\/openvpn\/staticclients<\/code><\/p>\n<p>Add this directory as option to your openvpn configfile at the server:<br \/>\n<code><br \/>\nclient-config-dir \/etc\/openvpn\/staticclients<\/code><\/p>\n<p>For each client you have to create a file. The filename must match the &#8220;common name&#8221; attribute that was specified at the X509 certificate of the client.This command gets the CN from the computers certificate:<\/p>\n<p><code>root@devdeb~ &gt; openssl x509 -in \/etc\/openvpn\/yourClientCertificate.cer -noout -subject | sed -e 's\/.*CN=\\(.*\\)\\\/.*\/\\1\/'<\/code><\/p>\n<p><code>TESTCLIENT<\/code><\/p>\n<p>This example pushs the IP Address 10.1.134.1\/255.255.255.192 to the Client with the common name TESTCLIENT and also pushes a additional route for subnet 10.1.135.0.<br \/>\n<code><br \/>\ncat \/etc\/openvpn\/staticclients\/TESTCLIENT<\/code><\/p>\n<p><code>ifconfig-push 10.1.134.1 255.255.255.192<br \/>\npush \"route 10.1.135.0\u00a0<code>255.255.255.0<\/code> 10.1.134.62\"<br \/>\n# push \"dhcp-option WINS addr\"<br \/>\n# push \"dhcp-option DNS addr\"<\/code><\/p>\n<p>Michael<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, sometimes you have to set a static IP Address for some VPN Clients. Because they provide some server services which always must be reached at the same IP Address. The client configuration do not provide any option to do that, set a static IP Address on the adapter itself is also always being overwritten &hellip; <a href=\"https:\/\/michlstechblog.info\/blog\/openvpn-set-a-static-ip-address-for-a-client\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">OpenVPN: Set a static IP Address for a client<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[164,180,182,857,181],"class_list":["post-684","post","type-post","status-publish","format-standard","hentry","category-openvpn","tag-address","tag-client","tag-ip","tag-openvpn","tag-static"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/684","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/comments?post=684"}],"version-history":[{"count":14,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/684\/revisions"}],"predecessor-version":[{"id":1585,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/684\/revisions\/1585"}],"wp:attachment":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/media?parent=684"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/categories?post=684"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/tags?post=684"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}