openvpn client override default gateway for vpn severCorrect Network IP addressing if your users have ability to VPN inOpenVPN with two gateway and DNS serverOpenVPN doesn't use remote gateway by defaultOpenVPN client as gateway for other clientsOpenVPN client nslookup failure after disconnectopenvpn client restarts if default gateway is changedOpenVPN server sending bogus default gateway information to client?ubuntu network manager openvpn overwrites default routeOpenVPN needs a gateway parameter fo a --route optionApply OpenVPN gateway to a single interface

Why doesn't Iron Man's action affect this person in Endgame?

Is this possible when it comes to the relations of P, NP, NP-Hard and NP-Complete?

How do I adjust encounters to challenge my lycanthrope players without negating their cool new abilities?

How can we allow remote players to effectively interact with a physical tabletop battle-map?

Substring join or additional table, which is faster?

Why are solar panels kept tilted?

How do I identify the partitions of my hard drive in order to then shred them all?

Polynomial division: Is this trick obvious?

Is 12 minutes connection in Bristol Temple Meads long enough?

Can multiple outlets be directly attached to a single breaker?

Meaning of "work with shame"

AMPScript Lookup From Child Business Unit

Why does SSL Labs now consider CBC suites weak?

Would life always name the light from their sun "white"

Source of the Wildfire?

Single word that parallels "Recent" when discussing the near future

Motorola 6845 and bitwise graphics

Who commanded or executed this action in Game of Thrones S8E5?

Is there any way to adjust the damage type of the Eldritch Blast cantrip so that it does fire damage?

What was the ring Varys took off?

Why can't I share a one use code with anyone else?

How to not get blinded by an attack at dawn

Is there any good reason to write "it is easy to see"?

Segmentation fault when popping x86 stack



openvpn client override default gateway for vpn sever


Correct Network IP addressing if your users have ability to VPN inOpenVPN with two gateway and DNS serverOpenVPN doesn't use remote gateway by defaultOpenVPN client as gateway for other clientsOpenVPN client nslookup failure after disconnectopenvpn client restarts if default gateway is changedOpenVPN server sending bogus default gateway information to client?ubuntu network manager openvpn overwrites default routeOpenVPN needs a gateway parameter fo a --route optionApply OpenVPN gateway to a single interface






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2















When openvpn client connects to a vpn server it creates a route for server ip with old default gateway. How can I tell openvpn not to use old default gateway but use my provided custom gateway ip.



I.e. when I have vpn server in another vpn network which is not default route on my machine.










share|improve this question






















  • Please elaborate. Currently, I'm unable to understand what you would like to achieve.

    – gf_
    Dec 23 '16 at 15:26











  • @gf_ when I run openvpn it uses comman /sbin/route add -net [VPN_SERVER_IP] [OLD_DEFAULT_GATEWAY] 255.255.255.255, right? so I need way to specify my own [OLD_DEFAULT_GATEWAY] value

    – igor
    Dec 23 '16 at 17:47






  • 1





    If you remove the old default gateway from your routing table when bringing up the first VPN, won't the second one use the default set by the first one? You should be able to use --redirect-gateway without the def1 flag (which preserves the old gateway), or write and run a script which has the same effect after the first VPN is brought up.

    – user4556274
    Dec 23 '16 at 18:10











  • @user4556274 I also don't want the first VPN to be default gateway. I just need it only for certain subnet.

    – igor
    Dec 25 '16 at 14:14











  • @kitty No, openvpn uses command /sbin/route add -net [VPN_SERVER_IP] [OLD_GATEWAY_FOR_VPN_SERVER_IP] 255.255.255.255. So, while connecting to second vpn, if the vpnserver2 is routed through first VPN, then the correct route will automatically be added by openvpn.

    – Tanmay
    Dec 28 '16 at 11:47

















2















When openvpn client connects to a vpn server it creates a route for server ip with old default gateway. How can I tell openvpn not to use old default gateway but use my provided custom gateway ip.



I.e. when I have vpn server in another vpn network which is not default route on my machine.










share|improve this question






















  • Please elaborate. Currently, I'm unable to understand what you would like to achieve.

    – gf_
    Dec 23 '16 at 15:26











  • @gf_ when I run openvpn it uses comman /sbin/route add -net [VPN_SERVER_IP] [OLD_DEFAULT_GATEWAY] 255.255.255.255, right? so I need way to specify my own [OLD_DEFAULT_GATEWAY] value

    – igor
    Dec 23 '16 at 17:47






  • 1





    If you remove the old default gateway from your routing table when bringing up the first VPN, won't the second one use the default set by the first one? You should be able to use --redirect-gateway without the def1 flag (which preserves the old gateway), or write and run a script which has the same effect after the first VPN is brought up.

    – user4556274
    Dec 23 '16 at 18:10











  • @user4556274 I also don't want the first VPN to be default gateway. I just need it only for certain subnet.

    – igor
    Dec 25 '16 at 14:14











  • @kitty No, openvpn uses command /sbin/route add -net [VPN_SERVER_IP] [OLD_GATEWAY_FOR_VPN_SERVER_IP] 255.255.255.255. So, while connecting to second vpn, if the vpnserver2 is routed through first VPN, then the correct route will automatically be added by openvpn.

    – Tanmay
    Dec 28 '16 at 11:47













2












2








2


2






When openvpn client connects to a vpn server it creates a route for server ip with old default gateway. How can I tell openvpn not to use old default gateway but use my provided custom gateway ip.



I.e. when I have vpn server in another vpn network which is not default route on my machine.










share|improve this question














When openvpn client connects to a vpn server it creates a route for server ip with old default gateway. How can I tell openvpn not to use old default gateway but use my provided custom gateway ip.



I.e. when I have vpn server in another vpn network which is not default route on my machine.







openvpn






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 7 '16 at 17:59









igorigor

48128




48128












  • Please elaborate. Currently, I'm unable to understand what you would like to achieve.

    – gf_
    Dec 23 '16 at 15:26











  • @gf_ when I run openvpn it uses comman /sbin/route add -net [VPN_SERVER_IP] [OLD_DEFAULT_GATEWAY] 255.255.255.255, right? so I need way to specify my own [OLD_DEFAULT_GATEWAY] value

    – igor
    Dec 23 '16 at 17:47






  • 1





    If you remove the old default gateway from your routing table when bringing up the first VPN, won't the second one use the default set by the first one? You should be able to use --redirect-gateway without the def1 flag (which preserves the old gateway), or write and run a script which has the same effect after the first VPN is brought up.

    – user4556274
    Dec 23 '16 at 18:10











  • @user4556274 I also don't want the first VPN to be default gateway. I just need it only for certain subnet.

    – igor
    Dec 25 '16 at 14:14











  • @kitty No, openvpn uses command /sbin/route add -net [VPN_SERVER_IP] [OLD_GATEWAY_FOR_VPN_SERVER_IP] 255.255.255.255. So, while connecting to second vpn, if the vpnserver2 is routed through first VPN, then the correct route will automatically be added by openvpn.

    – Tanmay
    Dec 28 '16 at 11:47

















  • Please elaborate. Currently, I'm unable to understand what you would like to achieve.

    – gf_
    Dec 23 '16 at 15:26











  • @gf_ when I run openvpn it uses comman /sbin/route add -net [VPN_SERVER_IP] [OLD_DEFAULT_GATEWAY] 255.255.255.255, right? so I need way to specify my own [OLD_DEFAULT_GATEWAY] value

    – igor
    Dec 23 '16 at 17:47






  • 1





    If you remove the old default gateway from your routing table when bringing up the first VPN, won't the second one use the default set by the first one? You should be able to use --redirect-gateway without the def1 flag (which preserves the old gateway), or write and run a script which has the same effect after the first VPN is brought up.

    – user4556274
    Dec 23 '16 at 18:10











  • @user4556274 I also don't want the first VPN to be default gateway. I just need it only for certain subnet.

    – igor
    Dec 25 '16 at 14:14











  • @kitty No, openvpn uses command /sbin/route add -net [VPN_SERVER_IP] [OLD_GATEWAY_FOR_VPN_SERVER_IP] 255.255.255.255. So, while connecting to second vpn, if the vpnserver2 is routed through first VPN, then the correct route will automatically be added by openvpn.

    – Tanmay
    Dec 28 '16 at 11:47
















Please elaborate. Currently, I'm unable to understand what you would like to achieve.

– gf_
Dec 23 '16 at 15:26





Please elaborate. Currently, I'm unable to understand what you would like to achieve.

– gf_
Dec 23 '16 at 15:26













@gf_ when I run openvpn it uses comman /sbin/route add -net [VPN_SERVER_IP] [OLD_DEFAULT_GATEWAY] 255.255.255.255, right? so I need way to specify my own [OLD_DEFAULT_GATEWAY] value

– igor
Dec 23 '16 at 17:47





@gf_ when I run openvpn it uses comman /sbin/route add -net [VPN_SERVER_IP] [OLD_DEFAULT_GATEWAY] 255.255.255.255, right? so I need way to specify my own [OLD_DEFAULT_GATEWAY] value

– igor
Dec 23 '16 at 17:47




1




1





If you remove the old default gateway from your routing table when bringing up the first VPN, won't the second one use the default set by the first one? You should be able to use --redirect-gateway without the def1 flag (which preserves the old gateway), or write and run a script which has the same effect after the first VPN is brought up.

– user4556274
Dec 23 '16 at 18:10





If you remove the old default gateway from your routing table when bringing up the first VPN, won't the second one use the default set by the first one? You should be able to use --redirect-gateway without the def1 flag (which preserves the old gateway), or write and run a script which has the same effect after the first VPN is brought up.

– user4556274
Dec 23 '16 at 18:10













@user4556274 I also don't want the first VPN to be default gateway. I just need it only for certain subnet.

– igor
Dec 25 '16 at 14:14





@user4556274 I also don't want the first VPN to be default gateway. I just need it only for certain subnet.

– igor
Dec 25 '16 at 14:14













@kitty No, openvpn uses command /sbin/route add -net [VPN_SERVER_IP] [OLD_GATEWAY_FOR_VPN_SERVER_IP] 255.255.255.255. So, while connecting to second vpn, if the vpnserver2 is routed through first VPN, then the correct route will automatically be added by openvpn.

– Tanmay
Dec 28 '16 at 11:47





@kitty No, openvpn uses command /sbin/route add -net [VPN_SERVER_IP] [OLD_GATEWAY_FOR_VPN_SERVER_IP] 255.255.255.255. So, while connecting to second vpn, if the vpnserver2 is routed through first VPN, then the correct route will automatically be added by openvpn.

– Tanmay
Dec 28 '16 at 11:47










4 Answers
4






active

oldest

votes


















0














Adding this two line to the Server Config File will force all traffic to go through your VPN



push "redirect-gateway def1"
push "dhcp-option DNS 8.8.8.8"





share|improve this answer


















  • 1





    sorry this is not what I'm asking :)

    – igor
    Dec 8 '16 at 11:04











  • I have two vpns and I want second vpn go through first vpn instead of going to real interface, which is default gateway

    – igor
    Dec 8 '16 at 11:06











  • I don't know how a client computer to have 2 openvpn connections at the same time but it is more likely to work if you use 2 different vpn services

    – akgren_soar
    Dec 8 '16 at 12:05


















0














If you want to set a next-hop router for a specific subnet after both VPNs are established, use something like



ip -4 route add $DESTINATION_SUBNET via $NEXT_HOP dev $INTERFACE_NAME


for example



ip -4 route add 10.0.0.0/8 via 172.16.0.1 dev eth0


You don't need to modify either default gateway; the more specific route will be chosen over the default route.






share|improve this answer























  • that is exactly what I don't want to do - do something manually after establishing vpn connections. I want it to be inside openvpn client config file

    – igor
    Dec 25 '16 at 22:37


















0














The redirect-gateway option may or may not change the gateway for reaching the OpenVPN server, depending on the flags provided to it.



According to man page of openvpn:




Option flags:



local -- Add the local flag if both OpenVPN servers are directly connected via a common subnet, such as with wireless. The local flag will cause step 1 above (Creation of a static route for the --remote address which forwards to the pre-existing default gateway) to be omitted.




So, just add a redirect-gateway local option in client config file, to override the pushed option. This will cause openvpn to just add a new default route, and not a specific route for the server. So the current route being used to connect to ther server will continue to be used.



If you want this behavior for all clients, edit the server config file and change the option push "redirect-gateway" to push "redirect-gateway local".






share|improve this answer






























    0















    I also don't want the first VPN to be default gateway. I just need it
    only for certain subnet.




    On the client side you can ignore any routes from vpn server with the following options



    script-security 2
    route-noexec
    route-up setup-routing.sh


    and configure your own routes with route-up script, that could be something like this



    $ cat setup-routing.sh 

    #!/bin/bash

    ip ro add 192.168.10.0/24 via $route_vpn_gateway


    Where route_vpn_gateway is environment variable that points to the default gateway used by --route options, as specified in either the --route-gateway option or the second parameter to --ifconfig when --dev tun is specified.






    share|improve this answer























      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%2f819339%2fopenvpn-client-override-default-gateway-for-vpn-sever%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      Adding this two line to the Server Config File will force all traffic to go through your VPN



      push "redirect-gateway def1"
      push "dhcp-option DNS 8.8.8.8"





      share|improve this answer


















      • 1





        sorry this is not what I'm asking :)

        – igor
        Dec 8 '16 at 11:04











      • I have two vpns and I want second vpn go through first vpn instead of going to real interface, which is default gateway

        – igor
        Dec 8 '16 at 11:06











      • I don't know how a client computer to have 2 openvpn connections at the same time but it is more likely to work if you use 2 different vpn services

        – akgren_soar
        Dec 8 '16 at 12:05















      0














      Adding this two line to the Server Config File will force all traffic to go through your VPN



      push "redirect-gateway def1"
      push "dhcp-option DNS 8.8.8.8"





      share|improve this answer


















      • 1





        sorry this is not what I'm asking :)

        – igor
        Dec 8 '16 at 11:04











      • I have two vpns and I want second vpn go through first vpn instead of going to real interface, which is default gateway

        – igor
        Dec 8 '16 at 11:06











      • I don't know how a client computer to have 2 openvpn connections at the same time but it is more likely to work if you use 2 different vpn services

        – akgren_soar
        Dec 8 '16 at 12:05













      0












      0








      0







      Adding this two line to the Server Config File will force all traffic to go through your VPN



      push "redirect-gateway def1"
      push "dhcp-option DNS 8.8.8.8"





      share|improve this answer













      Adding this two line to the Server Config File will force all traffic to go through your VPN



      push "redirect-gateway def1"
      push "dhcp-option DNS 8.8.8.8"






      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Dec 8 '16 at 4:23









      akgren_soarakgren_soar

      4927




      4927







      • 1





        sorry this is not what I'm asking :)

        – igor
        Dec 8 '16 at 11:04











      • I have two vpns and I want second vpn go through first vpn instead of going to real interface, which is default gateway

        – igor
        Dec 8 '16 at 11:06











      • I don't know how a client computer to have 2 openvpn connections at the same time but it is more likely to work if you use 2 different vpn services

        – akgren_soar
        Dec 8 '16 at 12:05












      • 1





        sorry this is not what I'm asking :)

        – igor
        Dec 8 '16 at 11:04











      • I have two vpns and I want second vpn go through first vpn instead of going to real interface, which is default gateway

        – igor
        Dec 8 '16 at 11:06











      • I don't know how a client computer to have 2 openvpn connections at the same time but it is more likely to work if you use 2 different vpn services

        – akgren_soar
        Dec 8 '16 at 12:05







      1




      1





      sorry this is not what I'm asking :)

      – igor
      Dec 8 '16 at 11:04





      sorry this is not what I'm asking :)

      – igor
      Dec 8 '16 at 11:04













      I have two vpns and I want second vpn go through first vpn instead of going to real interface, which is default gateway

      – igor
      Dec 8 '16 at 11:06





      I have two vpns and I want second vpn go through first vpn instead of going to real interface, which is default gateway

      – igor
      Dec 8 '16 at 11:06













      I don't know how a client computer to have 2 openvpn connections at the same time but it is more likely to work if you use 2 different vpn services

      – akgren_soar
      Dec 8 '16 at 12:05





      I don't know how a client computer to have 2 openvpn connections at the same time but it is more likely to work if you use 2 different vpn services

      – akgren_soar
      Dec 8 '16 at 12:05













      0














      If you want to set a next-hop router for a specific subnet after both VPNs are established, use something like



      ip -4 route add $DESTINATION_SUBNET via $NEXT_HOP dev $INTERFACE_NAME


      for example



      ip -4 route add 10.0.0.0/8 via 172.16.0.1 dev eth0


      You don't need to modify either default gateway; the more specific route will be chosen over the default route.






      share|improve this answer























      • that is exactly what I don't want to do - do something manually after establishing vpn connections. I want it to be inside openvpn client config file

        – igor
        Dec 25 '16 at 22:37















      0














      If you want to set a next-hop router for a specific subnet after both VPNs are established, use something like



      ip -4 route add $DESTINATION_SUBNET via $NEXT_HOP dev $INTERFACE_NAME


      for example



      ip -4 route add 10.0.0.0/8 via 172.16.0.1 dev eth0


      You don't need to modify either default gateway; the more specific route will be chosen over the default route.






      share|improve this answer























      • that is exactly what I don't want to do - do something manually after establishing vpn connections. I want it to be inside openvpn client config file

        – igor
        Dec 25 '16 at 22:37













      0












      0








      0







      If you want to set a next-hop router for a specific subnet after both VPNs are established, use something like



      ip -4 route add $DESTINATION_SUBNET via $NEXT_HOP dev $INTERFACE_NAME


      for example



      ip -4 route add 10.0.0.0/8 via 172.16.0.1 dev eth0


      You don't need to modify either default gateway; the more specific route will be chosen over the default route.






      share|improve this answer













      If you want to set a next-hop router for a specific subnet after both VPNs are established, use something like



      ip -4 route add $DESTINATION_SUBNET via $NEXT_HOP dev $INTERFACE_NAME


      for example



      ip -4 route add 10.0.0.0/8 via 172.16.0.1 dev eth0


      You don't need to modify either default gateway; the more specific route will be chosen over the default route.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Dec 25 '16 at 14:20









      user4556274user4556274

      22315




      22315












      • that is exactly what I don't want to do - do something manually after establishing vpn connections. I want it to be inside openvpn client config file

        – igor
        Dec 25 '16 at 22:37

















      • that is exactly what I don't want to do - do something manually after establishing vpn connections. I want it to be inside openvpn client config file

        – igor
        Dec 25 '16 at 22:37
















      that is exactly what I don't want to do - do something manually after establishing vpn connections. I want it to be inside openvpn client config file

      – igor
      Dec 25 '16 at 22:37





      that is exactly what I don't want to do - do something manually after establishing vpn connections. I want it to be inside openvpn client config file

      – igor
      Dec 25 '16 at 22:37











      0














      The redirect-gateway option may or may not change the gateway for reaching the OpenVPN server, depending on the flags provided to it.



      According to man page of openvpn:




      Option flags:



      local -- Add the local flag if both OpenVPN servers are directly connected via a common subnet, such as with wireless. The local flag will cause step 1 above (Creation of a static route for the --remote address which forwards to the pre-existing default gateway) to be omitted.




      So, just add a redirect-gateway local option in client config file, to override the pushed option. This will cause openvpn to just add a new default route, and not a specific route for the server. So the current route being used to connect to ther server will continue to be used.



      If you want this behavior for all clients, edit the server config file and change the option push "redirect-gateway" to push "redirect-gateway local".






      share|improve this answer



























        0














        The redirect-gateway option may or may not change the gateway for reaching the OpenVPN server, depending on the flags provided to it.



        According to man page of openvpn:




        Option flags:



        local -- Add the local flag if both OpenVPN servers are directly connected via a common subnet, such as with wireless. The local flag will cause step 1 above (Creation of a static route for the --remote address which forwards to the pre-existing default gateway) to be omitted.




        So, just add a redirect-gateway local option in client config file, to override the pushed option. This will cause openvpn to just add a new default route, and not a specific route for the server. So the current route being used to connect to ther server will continue to be used.



        If you want this behavior for all clients, edit the server config file and change the option push "redirect-gateway" to push "redirect-gateway local".






        share|improve this answer

























          0












          0








          0







          The redirect-gateway option may or may not change the gateway for reaching the OpenVPN server, depending on the flags provided to it.



          According to man page of openvpn:




          Option flags:



          local -- Add the local flag if both OpenVPN servers are directly connected via a common subnet, such as with wireless. The local flag will cause step 1 above (Creation of a static route for the --remote address which forwards to the pre-existing default gateway) to be omitted.




          So, just add a redirect-gateway local option in client config file, to override the pushed option. This will cause openvpn to just add a new default route, and not a specific route for the server. So the current route being used to connect to ther server will continue to be used.



          If you want this behavior for all clients, edit the server config file and change the option push "redirect-gateway" to push "redirect-gateway local".






          share|improve this answer













          The redirect-gateway option may or may not change the gateway for reaching the OpenVPN server, depending on the flags provided to it.



          According to man page of openvpn:




          Option flags:



          local -- Add the local flag if both OpenVPN servers are directly connected via a common subnet, such as with wireless. The local flag will cause step 1 above (Creation of a static route for the --remote address which forwards to the pre-existing default gateway) to be omitted.




          So, just add a redirect-gateway local option in client config file, to override the pushed option. This will cause openvpn to just add a new default route, and not a specific route for the server. So the current route being used to connect to ther server will continue to be used.



          If you want this behavior for all clients, edit the server config file and change the option push "redirect-gateway" to push "redirect-gateway local".







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 1 '17 at 19:26









          TanmayTanmay

          18519




          18519





















              0















              I also don't want the first VPN to be default gateway. I just need it
              only for certain subnet.




              On the client side you can ignore any routes from vpn server with the following options



              script-security 2
              route-noexec
              route-up setup-routing.sh


              and configure your own routes with route-up script, that could be something like this



              $ cat setup-routing.sh 

              #!/bin/bash

              ip ro add 192.168.10.0/24 via $route_vpn_gateway


              Where route_vpn_gateway is environment variable that points to the default gateway used by --route options, as specified in either the --route-gateway option or the second parameter to --ifconfig when --dev tun is specified.






              share|improve this answer



























                0















                I also don't want the first VPN to be default gateway. I just need it
                only for certain subnet.




                On the client side you can ignore any routes from vpn server with the following options



                script-security 2
                route-noexec
                route-up setup-routing.sh


                and configure your own routes with route-up script, that could be something like this



                $ cat setup-routing.sh 

                #!/bin/bash

                ip ro add 192.168.10.0/24 via $route_vpn_gateway


                Where route_vpn_gateway is environment variable that points to the default gateway used by --route options, as specified in either the --route-gateway option or the second parameter to --ifconfig when --dev tun is specified.






                share|improve this answer

























                  0












                  0








                  0








                  I also don't want the first VPN to be default gateway. I just need it
                  only for certain subnet.




                  On the client side you can ignore any routes from vpn server with the following options



                  script-security 2
                  route-noexec
                  route-up setup-routing.sh


                  and configure your own routes with route-up script, that could be something like this



                  $ cat setup-routing.sh 

                  #!/bin/bash

                  ip ro add 192.168.10.0/24 via $route_vpn_gateway


                  Where route_vpn_gateway is environment variable that points to the default gateway used by --route options, as specified in either the --route-gateway option or the second parameter to --ifconfig when --dev tun is specified.






                  share|improve this answer














                  I also don't want the first VPN to be default gateway. I just need it
                  only for certain subnet.




                  On the client side you can ignore any routes from vpn server with the following options



                  script-security 2
                  route-noexec
                  route-up setup-routing.sh


                  and configure your own routes with route-up script, that could be something like this



                  $ cat setup-routing.sh 

                  #!/bin/bash

                  ip ro add 192.168.10.0/24 via $route_vpn_gateway


                  Where route_vpn_gateway is environment variable that points to the default gateway used by --route options, as specified in either the --route-gateway option or the second parameter to --ifconfig when --dev tun is specified.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 13 '18 at 18:43









                  ALex_hhaALex_hha

                  5,69011832




                  5,69011832



























                      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%2f819339%2fopenvpn-client-override-default-gateway-for-vpn-sever%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

                      Wikipedia:Vital articles Мазмуну Biography - Өмүр баян Philosophy and psychology - Философия жана психология Religion - Дин Social sciences - Коомдук илимдер Language and literature - Тил жана адабият Science - Илим Technology - Технология Arts and recreation - Искусство жана эс алуу History and geography - Тарых жана география Навигация менюсу

                      Bruxelas-Capital Índice Historia | Composición | Situación lingüística | Clima | Cidades irmandadas | Notas | Véxase tamén | Menú de navegacióneO uso das linguas en Bruxelas e a situación do neerlandés"Rexión de Bruxelas Capital"o orixinalSitio da rexiónPáxina de Bruselas no sitio da Oficina de Promoción Turística de Valonia e BruxelasMapa Interactivo da Rexión de Bruxelas-CapitaleeWorldCat332144929079854441105155190212ID28008674080552-90000 0001 0666 3698n94104302ID540940339365017018237

                      What should I write in an apology letter, since I have decided not to join a company after accepting an offer letterShould I keep looking after accepting a job offer?What should I do when I've been verbally told I would get an offer letter, but still haven't gotten one after 4 weeks?Do I accept an offer from a company that I am not likely to join?New job hasn't confirmed starting date and I want to give current employer as much notice as possibleHow should I address my manager in my resignation letter?HR delayed background verification, now jobless as resignedNo email communication after accepting a formal written offer. How should I phrase the call?What should I do if after receiving a verbal offer letter I am informed that my written job offer is put on hold due to some internal issues?Should I inform the current employer that I am about to resign within 1-2 weeks since I have signed the offer letter and waiting for visa?What company will do, if I send their offer letter to another company