0

let's say I installed on my local machine a dns server with port 5353 how to configure it as other dns on /etc/resolv.conf

my resolv.conf looks like this

nameserver 14.2.3.1
nameserver 14.2.3.2

How can I add entry with port ?

2 Answers 2

2

You can specify a different for DNS (for instance BIND) to LISTEN on, as that's controlled via /etc/named.conf, but the issue is getting the DNS client to connect to the DNS server on that port rather than the default port 53.

The /etc/resolv.conf config file doesn't support any form of alternative port number, so will only connect natively via port 53.

The only way to achieve what you're looking for is to have something in the middle to take the port 53 request from the client, change it to use port 5353 and then deliver that request to the server.

The way others have achieved that is to use iptables to reroute that internal request as needed. An example thread discussing it can be found here https://serverfault.com/questions/401489/redirect-traffic-from-127-0-0-1-to-127-0-0-1-on-port-53-to-port-5300-with-iptabl

But the crucial points are to 1) update your /etc/resolv.conf to include an entry for 127.0.0.1 and then add a rule in iptables to handle the redirect as :

iptables -t nat -A OUTPUT -p tcp --dport domain -j DNAT --to-destination 127.0.0.1:5300
iptables -t nat -A OUTPUT -p udp --dport domain -j DNAT --to-destination 127.0.0.1:5300
1
  • That original discussion is from 2012, and I think iptables syntax may have changed since then. I get this error: iptables v1.8.7 (nf_tables): unknown option "--dport"
    – ETL
    Commented Jul 5 at 0:15
0

In Linux, in /etc/resolv.conf you can't specify different port on which DNS listen. Just make your DNS to listen to port 53.

Based on internet searches format:

nameserver x.x.x.x:p

do not work also in Solaris and MacOS

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .