1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice

Welcome To SNBForums

SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.

If you'd like to post a question, simply register and have at it!

While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!

Changing Port for upstream DNS Server

Discussion in 'Asuswrt-Merlin' started by Alfsu, Jan 23, 2020.

Tags:
  1. Alfsu

    Alfsu Regular Contributor

    Joined:
    Sep 13, 2013
    Messages:
    161
    I've searched in this forum and on the web about this topic but, could not find clear explanation on how to accomplish this task, mainly due to my very limited knowledge on the subject.

    The final goal is to set up an RT-AC68P router (384.14-2) to connect to the upstream dns servers using an alternate port (1512), servers which are already set in the WAN DNS setting page for both: DNS Server1 and DNS Server2; these servers also respond on port 53, but that port is being intercepted by the ISP.

    How do I go about to instructing the Asus router to use the alternate port (1512) instead of port 53?

    I did a successful test run on the alternative ports by way of running pihole on another device, but I am sure there is a better solution within the router itself.

    Thank you in advance for your help!
     
  2. dave14305

    dave14305 Part of the Furniture

    Joined:
    May 19, 2018
    Messages:
    2,137
    Location:
    USA
    I would do it by enabling JFFS scripts and custom configs in the GUI. Then create the file /jffs/scripts/dnsmasq.postconf with this content:
    Code:
    #!/bin/sh
    
    CONFIG="$1"
    . /usr/sbin/helper.sh
    
    pc_delete "servers-file" "$CONFIG"
    pc_append "server=1.1.1.1#1512" "$CONFIG"
    pc_append "server=9.9.9.9#1512" "$CONFIG"
    Replace 1.1.1.1 and 9.9.9.9 with the 2 DNS servers you actually want to use.

    Refer to the wiki for the details of how these scripts work: https://github.com/RMerl/asuswrt-merlin/wiki/Custom-config-files
     
    Twiglets likes this.
  3. Alfsu

    Alfsu Regular Contributor

    Joined:
    Sep 13, 2013
    Messages:
    161
    Thank you so much for your reply, I will give it a try!

    Thanks again.
     
  4. Alfsu

    Alfsu Regular Contributor

    Joined:
    Sep 13, 2013
    Messages:
    161
    @dave14305 this is how it worked in the end:
    Code:
    #!/bin/sh
    CONFIG=$1
    source /usr/sbin/helper.sh
    pc_delete "servers-file" $CONFIG
    pc_append "server=xxx.xxx.xxx.xxx#1512" $CONFIG
    pc_append "server=xxx.xxx.xxx.xxx#1512" $CONFIG
    logger "Changed to DNS Servers on port 1512"
    Thank you for pointing me in the right direction.

    Cheers!
     
    dave14305 likes this.