Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Update DNS Server w/ VPN Virtual IP

    Scheduled Pinned Locked Moved DHCP and DNS
    13 Posts 3 Posters 1.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      jrgx19
      last edited by

      I have set up my network with multiple VPNs. One of the VPN connection needs to be the DNS server for the pfsense box. Every time the VPN connection is established, I get a new "Virtual IP" from the VPN provider. How can I update my DNS server with the newly acquired Virtual IP from the VPN server?

      I currently need to update the DNS server every time the VPN reconnects. This can be a bit frustrating. it became more of an issue when I am away from home and the wife needs the internet, but there is no DNS resolution

      See attached pics.

      ![VPN Status.png](/public/imported_attachments/1/VPN Status.png)
      ![VPN Status.png_thumb](/public/imported_attachments/1/VPN Status.png_thumb)
      ![main page.png](/public/imported_attachments/1/main page.png)
      ![main page.png_thumb](/public/imported_attachments/1/main page.png_thumb)
      ![General Setup.png](/public/imported_attachments/1/General Setup.png)
      ![General Setup.png_thumb](/public/imported_attachments/1/General Setup.png_thumb)

      1 Reply Last reply Reply Quote 0
      • J Offline
        jrgx19
        last edited by

        So, I have made a bit of progress. the following connads works to retrieve the "Virtual IP" from my VPN connection

        ifconfig ovpnc2 | grep "inet " | awk '{print $2}'
        

        Note: "ovpnc2" is to be replaced with the appropriate interface.

        I also found that the DNS server information is kept in:

         /etc/resolv.conf
        

        in my case it is the 3rd/last line on that file. 
        Now I just need to figure out how to pipe the output of the first command to replace the line containing "nameserver VPN VIRTUAL IP" without affecting the other lines in that file.

        There is another line with "nameserver 127.0.0.1" which I do not want to replace.

        I also have not figured out how I want the final product to run. should I run it on a preset interval. Or is there a way to make it run only if the VPN connection is restarted?

        Any suggestions?

        1 Reply Last reply Reply Quote 0
        • DerelictD Offline
          Derelict LAYER 8 Netgate
          last edited by

          Whatever is on the other side should have a static DNS server address you can use.

          In other words, there has to be a better way.

          Chattanooga, Tennessee, USA
          A comprehensive network diagram is worth 10,000 words and 15 conference calls.
          DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
          Do Not Chat For Help! NO_WAN_EGRESS(TM)

          1 Reply Last reply Reply Quote 0
          • johnpozJ Offline
            johnpoz LAYER 8 Global Moderator
            last edited by

            Who is your vpn provider?  It makes zero sense from them to change the dns every time you connect… They at worse case have a pool of addresses they hand out... What is your VPN provider so can do a simple google to what dns should be for them..

            Why would you be pointing dns to the IP pfsense gets??

            An intelligent man is sometimes forced to be drunk to spend time with his fools
            If you get confused: Listen to the Music Play
            Please don't Chat/PM me for help, unless mod related
            SG-4860 25.07.1 | Lab VMs 2.8.1, 25.07.1

            1 Reply Last reply Reply Quote 0
            • J Offline
              jrgx19
              last edited by

              This particular setup is with vyprvpn. For what I have been able to get from them, their DNS is managed internally once clients connect. Basically i need to use the address  provided in order to route DNS.

              I am able to use any other DNS server I want. However, for media consumption i.e Netflix and Hulu, I need to use their DNS server. If I don't, I get a location mismatch / proxy server error.

              I have tried multiple workarounds. This seems to be the only way I can get it to work properly.

              1 Reply Last reply Reply Quote 0
              • johnpozJ Offline
                johnpoz LAYER 8 Global Moderator
                last edited by

                And what setup are you using - they do not list setting up openvpn with pfsense.  And their setups with dd-wrt, etc state they do not support vyperdns with them.

                Pointing dns to your IP you got from your vpn makes no sense - there will be nothing listening on this IP for dns..

                An intelligent man is sometimes forced to be drunk to spend time with his fools
                If you get confused: Listen to the Music Play
                Please don't Chat/PM me for help, unless mod related
                SG-4860 25.07.1 | Lab VMs 2.8.1, 25.07.1

                1 Reply Last reply Reply Quote 0
                • J Offline
                  jrgx19
                  last edited by

                  I used this setup https://pixelsandwidgets.com/2014/10/setup-pfsense-openvpn-client-specific-devices/. I had to play with it as it is an older guide. I realize that pointing o the IP does not make sense. However, doing so gets me DNS resolution. The odd part of it is that even thou the IP is within their network, I do not get DNS resolution if the IP changes.

                  1 Reply Last reply Reply Quote 0
                  • DerelictD Offline
                    Derelict LAYER 8 Netgate
                    last edited by

                    Some three-year-old walkthrough is peobably going to lead you to take a wrong turn.

                    Chattanooga, Tennessee, USA
                    A comprehensive network diagram is worth 10,000 words and 15 conference calls.
                    DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
                    Do Not Chat For Help! NO_WAN_EGRESS(TM)

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      jrgx19
                      last edited by

                      @Derelict:

                      Some three-year-old walkthrough is peobably going to lead you to take a wrong turn.

                      The setup seem pretty standard for what I have been able to research. I believe the biggest issue is that vypr does not provide their DNS server address

                      1 Reply Last reply Reply Quote 0
                      • DerelictD Offline
                        Derelict LAYER 8 Netgate
                        last edited by

                        Then use a different DNS server (or a different VPN provider). That configuration is completely non-standard. Your current path is dark and full or terrors.

                        Chattanooga, Tennessee, USA
                        A comprehensive network diagram is worth 10,000 words and 15 conference calls.
                        DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
                        Do Not Chat For Help! NO_WAN_EGRESS(TM)

                        1 Reply Last reply Reply Quote 0
                        • J Offline
                          jrgx19
                          last edited by

                          @Derelict:

                          Then use a different DNS server (or a different VPN provider). That configuration is completely non-standard. Your current path is dark and full or terrors.

                          I'm going to look into different VPN. I really like vypr for media consumption. They are the fastest/lowest latency provider i have tested. definitely not for privacy/security. For the time being I'm probably going to figure out how to keep the address updated.

                          p.s I like your GoT reference!

                          1 Reply Last reply Reply Quote 0
                          • johnpozJ Offline
                            johnpoz LAYER 8 Global Moderator
                            last edited by

                            Why don't you contact them… The providing you with a rfc1918 address for their dns would solve the problem, since this would only be available for sure via their vpn users, and not give anyway any sort of info of where their dns is located, etc.

                            An intelligent man is sometimes forced to be drunk to spend time with his fools
                            If you get confused: Listen to the Music Play
                            Please don't Chat/PM me for help, unless mod related
                            SG-4860 25.07.1 | Lab VMs 2.8.1, 25.07.1

                            1 Reply Last reply Reply Quote 0
                            • J Offline
                              jrgx19
                              last edited by

                              I know it has been a while. I did contact them (vyprVPN). They would not provide their DNS information. So, I guess for the time being, I am kinda have to just deal with it. I have not had any time lately to continue playing with it. One of these weekends I can resume my adventure on my current path, "dark and full of terrors"

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post
                              Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.