OpenVPN client nslookup failure after disconnectProblems setting up a VPN: can connect but can't ping...

Tcolorbox as an item in list environment

What to do when being responsible for data protection in your lab, yet advice is ignored?

How to kill a localhost:8080

What is this waxed root vegetable?

Did 5.25" floppies undergo a change in magnetic coating?

Is there any relevance to Thor getting his hair cut other than comedic value?

Are small insurances worth it

How can I be pwned if I'm not registered on the compromised site?

Non-Italian European mafias in USA?

A right or the right?

How to deal with being jealous of your own players?

my breadboard simulation doesn't work properly

Manipulate scientific format without the "e"

Is the helper verb 'werden' mandatory in both passive clauses separated by an 'oder', or only at the very the end?

Wrap all numerics in JSON with quotes

How to count occurrences of Friday 13th

How do you say "powers of ten"?

How do ISS astronauts "get their stripes"?

Perpetuum Mobile: Where did I think wrong?

Inverse of the covariance matrix of a multivariate normal distribution

Is there a ternary operator in math?

Filling in Area Under Curve Causes Alignment Issues

Is it possible to convert a suspension fork to rigid by drilling it?

How can I handle a player who pre-plans arguments about my rulings on RAW?



OpenVPN client nslookup failure after disconnect


Problems setting up a VPN: can connect but can't ping anyoneOpenVPN routing problemopenvpn multiple instances route issue?Anonymizing OpenVPN Allow SSH Access to Internal ServerOpenVPN: forward client's LAN to the VPNAllowing SSH on a server with an active OpenVPN clientConnect AWS and Azure via OpenVPNConnecting two clients openvpnOpenvpn: client can ping server, server cannot ping clientopenvpn - forward network traffic from specific subnet to specific tun interface













0















Currently I am trying to route my traffic through a gateway running Debian Linux which forwards all incoming traffic thorugh a VPN connection (Client -> Gateway with OpenVPN client -> VPN server -> Internet). This works fine exept it loses the connection from time to time and is unable to reconnect ifself due to nslookup timeouts. This happens every few days, mostly at night (as far as I know, some servers are terminating the session if no traffic was sent for a long time).



When happening, I'll try to connect through SSH but after entering the username the server waits about 20 seconds before asking for the password which is also strange. Normally it askes for the password immediately.



When looking into the syslog this one comes up:



Jul 20 00:50:11 gateway ovpn-cyberghost[23893]: RESOLVE: Cannot resolve host address: 5-nl.cg-dialup.net: Temporary failure in name resolution



ifconfig and route shows, that the VPN interface is still up but seems to be hung up.



root@gateway:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.129.57.169 128.0.0.0 UG 0 0 0 tun0
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth2
10.129.57.169 0.0.0.0 255.255.255.255 UH 0 0 0 tun0
93.190.138.125 192.168.0.1 255.255.255.255 UGH 0 0 0 eth2
128.0.0.0 10.129.57.169 128.0.0.0 UG 0 0 0 tun0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
217.23.12.229 192.168.0.1 255.255.255.255 UGH 0 0 0 eth2


Heres my OpenVPN config:



client
remote 5-nl.cg-dialup.net 443
dev tun
proto udp
auth-user-pass /etc/openvpn/auth.txt
route-nopull

resolv-retry infinite
redirect-gateway def1
persist-key
persist-tun
writepid /run/openvpn.pid
nobind
cipher AES-256-CBC
auth MD5
ping 5
ping-restart 20
persist-local-ip
ping-timer-rem
explicit-exit-notify 2
script-security 2
remote-cert-tls server
route-delay 5
tun-mtu 1500
fragment 1300
mssfix 1300
verb 1
comp-lzo


Heres my resolv.conf:



 root@gateway:~# cat /etc/resolv.conf
nameserver 85.214.20.141
nameserver 213.73.91.35


Changing the nameservers, for example to 127.0.0.1 (bind9 correctly installed as a dns resolver), did not solve anything but I do not expect to find the problem here.



I guess, the following is the reason: The server closed the session due inactivity of the client so the client tries to reconnect. In the process of reconnecting OpenVPN resolves the hostname of the VPN server but it uses the broken VPN interface which is set as the default gateway instead of the correct default gateway. No cleanup is made (remove tun0 interface and deleting the routes), which would perhaps solve the problem. Also I think there could be an issue having two default gateways but I am not sure.



After terminating the OpenVPN process manually and starting it again everything works fine like nothing ever happend.



I don't know how either tell OpenVPN to use the eth2 interface for that initial nslookup or to get OpenVPN to cleanup the routes. Did I forgot to add something in the config file (I didn't found any helpful commands in the manpage)?










share|improve this question














bumped to the homepage by Community 3 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    0















    Currently I am trying to route my traffic through a gateway running Debian Linux which forwards all incoming traffic thorugh a VPN connection (Client -> Gateway with OpenVPN client -> VPN server -> Internet). This works fine exept it loses the connection from time to time and is unable to reconnect ifself due to nslookup timeouts. This happens every few days, mostly at night (as far as I know, some servers are terminating the session if no traffic was sent for a long time).



    When happening, I'll try to connect through SSH but after entering the username the server waits about 20 seconds before asking for the password which is also strange. Normally it askes for the password immediately.



    When looking into the syslog this one comes up:



    Jul 20 00:50:11 gateway ovpn-cyberghost[23893]: RESOLVE: Cannot resolve host address: 5-nl.cg-dialup.net: Temporary failure in name resolution



    ifconfig and route shows, that the VPN interface is still up but seems to be hung up.



    root@gateway:~# route -n
    Kernel IP routing table
    Destination Gateway Genmask Flags Metric Ref Use Iface
    0.0.0.0 10.129.57.169 128.0.0.0 UG 0 0 0 tun0
    0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth2
    10.129.57.169 0.0.0.0 255.255.255.255 UH 0 0 0 tun0
    93.190.138.125 192.168.0.1 255.255.255.255 UGH 0 0 0 eth2
    128.0.0.0 10.129.57.169 128.0.0.0 UG 0 0 0 tun0
    192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
    217.23.12.229 192.168.0.1 255.255.255.255 UGH 0 0 0 eth2


    Heres my OpenVPN config:



    client
    remote 5-nl.cg-dialup.net 443
    dev tun
    proto udp
    auth-user-pass /etc/openvpn/auth.txt
    route-nopull

    resolv-retry infinite
    redirect-gateway def1
    persist-key
    persist-tun
    writepid /run/openvpn.pid
    nobind
    cipher AES-256-CBC
    auth MD5
    ping 5
    ping-restart 20
    persist-local-ip
    ping-timer-rem
    explicit-exit-notify 2
    script-security 2
    remote-cert-tls server
    route-delay 5
    tun-mtu 1500
    fragment 1300
    mssfix 1300
    verb 1
    comp-lzo


    Heres my resolv.conf:



     root@gateway:~# cat /etc/resolv.conf
    nameserver 85.214.20.141
    nameserver 213.73.91.35


    Changing the nameservers, for example to 127.0.0.1 (bind9 correctly installed as a dns resolver), did not solve anything but I do not expect to find the problem here.



    I guess, the following is the reason: The server closed the session due inactivity of the client so the client tries to reconnect. In the process of reconnecting OpenVPN resolves the hostname of the VPN server but it uses the broken VPN interface which is set as the default gateway instead of the correct default gateway. No cleanup is made (remove tun0 interface and deleting the routes), which would perhaps solve the problem. Also I think there could be an issue having two default gateways but I am not sure.



    After terminating the OpenVPN process manually and starting it again everything works fine like nothing ever happend.



    I don't know how either tell OpenVPN to use the eth2 interface for that initial nslookup or to get OpenVPN to cleanup the routes. Did I forgot to add something in the config file (I didn't found any helpful commands in the manpage)?










    share|improve this question














    bumped to the homepage by Community 3 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      0












      0








      0








      Currently I am trying to route my traffic through a gateway running Debian Linux which forwards all incoming traffic thorugh a VPN connection (Client -> Gateway with OpenVPN client -> VPN server -> Internet). This works fine exept it loses the connection from time to time and is unable to reconnect ifself due to nslookup timeouts. This happens every few days, mostly at night (as far as I know, some servers are terminating the session if no traffic was sent for a long time).



      When happening, I'll try to connect through SSH but after entering the username the server waits about 20 seconds before asking for the password which is also strange. Normally it askes for the password immediately.



      When looking into the syslog this one comes up:



      Jul 20 00:50:11 gateway ovpn-cyberghost[23893]: RESOLVE: Cannot resolve host address: 5-nl.cg-dialup.net: Temporary failure in name resolution



      ifconfig and route shows, that the VPN interface is still up but seems to be hung up.



      root@gateway:~# route -n
      Kernel IP routing table
      Destination Gateway Genmask Flags Metric Ref Use Iface
      0.0.0.0 10.129.57.169 128.0.0.0 UG 0 0 0 tun0
      0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth2
      10.129.57.169 0.0.0.0 255.255.255.255 UH 0 0 0 tun0
      93.190.138.125 192.168.0.1 255.255.255.255 UGH 0 0 0 eth2
      128.0.0.0 10.129.57.169 128.0.0.0 UG 0 0 0 tun0
      192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
      217.23.12.229 192.168.0.1 255.255.255.255 UGH 0 0 0 eth2


      Heres my OpenVPN config:



      client
      remote 5-nl.cg-dialup.net 443
      dev tun
      proto udp
      auth-user-pass /etc/openvpn/auth.txt
      route-nopull

      resolv-retry infinite
      redirect-gateway def1
      persist-key
      persist-tun
      writepid /run/openvpn.pid
      nobind
      cipher AES-256-CBC
      auth MD5
      ping 5
      ping-restart 20
      persist-local-ip
      ping-timer-rem
      explicit-exit-notify 2
      script-security 2
      remote-cert-tls server
      route-delay 5
      tun-mtu 1500
      fragment 1300
      mssfix 1300
      verb 1
      comp-lzo


      Heres my resolv.conf:



       root@gateway:~# cat /etc/resolv.conf
      nameserver 85.214.20.141
      nameserver 213.73.91.35


      Changing the nameservers, for example to 127.0.0.1 (bind9 correctly installed as a dns resolver), did not solve anything but I do not expect to find the problem here.



      I guess, the following is the reason: The server closed the session due inactivity of the client so the client tries to reconnect. In the process of reconnecting OpenVPN resolves the hostname of the VPN server but it uses the broken VPN interface which is set as the default gateway instead of the correct default gateway. No cleanup is made (remove tun0 interface and deleting the routes), which would perhaps solve the problem. Also I think there could be an issue having two default gateways but I am not sure.



      After terminating the OpenVPN process manually and starting it again everything works fine like nothing ever happend.



      I don't know how either tell OpenVPN to use the eth2 interface for that initial nslookup or to get OpenVPN to cleanup the routes. Did I forgot to add something in the config file (I didn't found any helpful commands in the manpage)?










      share|improve this question














      Currently I am trying to route my traffic through a gateway running Debian Linux which forwards all incoming traffic thorugh a VPN connection (Client -> Gateway with OpenVPN client -> VPN server -> Internet). This works fine exept it loses the connection from time to time and is unable to reconnect ifself due to nslookup timeouts. This happens every few days, mostly at night (as far as I know, some servers are terminating the session if no traffic was sent for a long time).



      When happening, I'll try to connect through SSH but after entering the username the server waits about 20 seconds before asking for the password which is also strange. Normally it askes for the password immediately.



      When looking into the syslog this one comes up:



      Jul 20 00:50:11 gateway ovpn-cyberghost[23893]: RESOLVE: Cannot resolve host address: 5-nl.cg-dialup.net: Temporary failure in name resolution



      ifconfig and route shows, that the VPN interface is still up but seems to be hung up.



      root@gateway:~# route -n
      Kernel IP routing table
      Destination Gateway Genmask Flags Metric Ref Use Iface
      0.0.0.0 10.129.57.169 128.0.0.0 UG 0 0 0 tun0
      0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth2
      10.129.57.169 0.0.0.0 255.255.255.255 UH 0 0 0 tun0
      93.190.138.125 192.168.0.1 255.255.255.255 UGH 0 0 0 eth2
      128.0.0.0 10.129.57.169 128.0.0.0 UG 0 0 0 tun0
      192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
      217.23.12.229 192.168.0.1 255.255.255.255 UGH 0 0 0 eth2


      Heres my OpenVPN config:



      client
      remote 5-nl.cg-dialup.net 443
      dev tun
      proto udp
      auth-user-pass /etc/openvpn/auth.txt
      route-nopull

      resolv-retry infinite
      redirect-gateway def1
      persist-key
      persist-tun
      writepid /run/openvpn.pid
      nobind
      cipher AES-256-CBC
      auth MD5
      ping 5
      ping-restart 20
      persist-local-ip
      ping-timer-rem
      explicit-exit-notify 2
      script-security 2
      remote-cert-tls server
      route-delay 5
      tun-mtu 1500
      fragment 1300
      mssfix 1300
      verb 1
      comp-lzo


      Heres my resolv.conf:



       root@gateway:~# cat /etc/resolv.conf
      nameserver 85.214.20.141
      nameserver 213.73.91.35


      Changing the nameservers, for example to 127.0.0.1 (bind9 correctly installed as a dns resolver), did not solve anything but I do not expect to find the problem here.



      I guess, the following is the reason: The server closed the session due inactivity of the client so the client tries to reconnect. In the process of reconnecting OpenVPN resolves the hostname of the VPN server but it uses the broken VPN interface which is set as the default gateway instead of the correct default gateway. No cleanup is made (remove tun0 interface and deleting the routes), which would perhaps solve the problem. Also I think there could be an issue having two default gateways but I am not sure.



      After terminating the OpenVPN process manually and starting it again everything works fine like nothing ever happend.



      I don't know how either tell OpenVPN to use the eth2 interface for that initial nslookup or to get OpenVPN to cleanup the routes. Did I forgot to add something in the config file (I didn't found any helpful commands in the manpage)?







      debian routing openvpn nslookup






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jul 20 '15 at 0:36









      user2626702user2626702

      4828




      4828





      bumped to the homepage by Community 3 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 3 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          https://askubuntu.com/questions/28733/how-do-i-run-a-script-after-openvpn-has-connected-successfully tells how you can execute custom scripts after connection going up or down.



          So, you should create a down script, which would clean up the routes and make OpenVPN execute that when connection goes down.






          share|improve this answer


























          • I created such a script and append down /etc/openvpn/down.sh in the config. The script only contains the command route del -net 0.0.0.0 gw $5 netmask 128.0.0.0 dev tun0. I know this is a little bit dirty, but while testing it seems to work. But OpenVPN does not execute the script when restarting as there is no verbose log as like in the up.sh script.

            – user2626702
            Jul 21 '15 at 15:02













          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "2"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f706928%2fopenvpn-client-nslookup-failure-after-disconnect%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          https://askubuntu.com/questions/28733/how-do-i-run-a-script-after-openvpn-has-connected-successfully tells how you can execute custom scripts after connection going up or down.



          So, you should create a down script, which would clean up the routes and make OpenVPN execute that when connection goes down.






          share|improve this answer


























          • I created such a script and append down /etc/openvpn/down.sh in the config. The script only contains the command route del -net 0.0.0.0 gw $5 netmask 128.0.0.0 dev tun0. I know this is a little bit dirty, but while testing it seems to work. But OpenVPN does not execute the script when restarting as there is no verbose log as like in the up.sh script.

            – user2626702
            Jul 21 '15 at 15:02


















          0














          https://askubuntu.com/questions/28733/how-do-i-run-a-script-after-openvpn-has-connected-successfully tells how you can execute custom scripts after connection going up or down.



          So, you should create a down script, which would clean up the routes and make OpenVPN execute that when connection goes down.






          share|improve this answer


























          • I created such a script and append down /etc/openvpn/down.sh in the config. The script only contains the command route del -net 0.0.0.0 gw $5 netmask 128.0.0.0 dev tun0. I know this is a little bit dirty, but while testing it seems to work. But OpenVPN does not execute the script when restarting as there is no verbose log as like in the up.sh script.

            – user2626702
            Jul 21 '15 at 15:02
















          0












          0








          0







          https://askubuntu.com/questions/28733/how-do-i-run-a-script-after-openvpn-has-connected-successfully tells how you can execute custom scripts after connection going up or down.



          So, you should create a down script, which would clean up the routes and make OpenVPN execute that when connection goes down.






          share|improve this answer















          https://askubuntu.com/questions/28733/how-do-i-run-a-script-after-openvpn-has-connected-successfully tells how you can execute custom scripts after connection going up or down.



          So, you should create a down script, which would clean up the routes and make OpenVPN execute that when connection goes down.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 13 '17 at 12:22









          Community

          1




          1










          answered Jul 20 '15 at 8:07









          Tero KilkanenTero Kilkanen

          20.3k22644




          20.3k22644













          • I created such a script and append down /etc/openvpn/down.sh in the config. The script only contains the command route del -net 0.0.0.0 gw $5 netmask 128.0.0.0 dev tun0. I know this is a little bit dirty, but while testing it seems to work. But OpenVPN does not execute the script when restarting as there is no verbose log as like in the up.sh script.

            – user2626702
            Jul 21 '15 at 15:02





















          • I created such a script and append down /etc/openvpn/down.sh in the config. The script only contains the command route del -net 0.0.0.0 gw $5 netmask 128.0.0.0 dev tun0. I know this is a little bit dirty, but while testing it seems to work. But OpenVPN does not execute the script when restarting as there is no verbose log as like in the up.sh script.

            – user2626702
            Jul 21 '15 at 15:02



















          I created such a script and append down /etc/openvpn/down.sh in the config. The script only contains the command route del -net 0.0.0.0 gw $5 netmask 128.0.0.0 dev tun0. I know this is a little bit dirty, but while testing it seems to work. But OpenVPN does not execute the script when restarting as there is no verbose log as like in the up.sh script.

          – user2626702
          Jul 21 '15 at 15:02







          I created such a script and append down /etc/openvpn/down.sh in the config. The script only contains the command route del -net 0.0.0.0 gw $5 netmask 128.0.0.0 dev tun0. I know this is a little bit dirty, but while testing it seems to work. But OpenVPN does not execute the script when restarting as there is no verbose log as like in the up.sh script.

          – user2626702
          Jul 21 '15 at 15:02




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Server Fault!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f706928%2fopenvpn-client-nslookup-failure-after-disconnect%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          As a Security Precaution, the user account has been locked The Next CEO of Stack OverflowMS...

          Список ссавців Італії Природоохоронні статуси | Список |...

          Українські прізвища Зміст Історичні відомості |...