Change Pihole listening port from 53 to 7502

Is there a way to change pihole from listing to dns port 53? I want to use my custom port 7502 instead.

I tried to use IPTABLES, but it did not work.

iptables -t nat -A PREROUTING -p tcp --dport 7502 -j REDIRECT --to-port 53
iptables -t nat -A PREROUTING -p udp --dport 7502 -j REDIRECT --to-port 53

Set the port option in /etc/dnsmasq.conf:

port=7502

Why do you want to change the port? The client devices might not support listening on a port different than 53.

I made the change in dnsmasq.conf, but every time I put in a custom port, pihole dns service wont start up, status shows red circle. Put it back to 53, then it starts ok again. Wont take in custom port.

I want to do the opposite. I have it in 9053 and I want to pass it to 53

I dont have /etc/dnsmasq.conf on pi running pihole.

No worries, changing the ports will break everything anyways.

2 Likes

Nothing Breaks ,

I have setup like this:

CoreDNS ---> Pihole --> dnscrypt-proxy <-- Internet

Coredns on port 53 gives in internal domain access
Pihole on port 5333 gives me ad blocking
dnscrypt-proxy on port 5335 gives me DoH

Is anything on a port other than 53? If not then your comment added nothing of value to this thread.

I have updated my reply

Thanks, but your comment doesn't relate to this topic. You still have the DNS that clients access as port 53.

its only internal on LAN, but yea I am not listeing to pihole directly, everydevices first hits coredns coredns forwards to pihole.

Screenshot 2020-12-05 at 19.09.36

Great, has nothing to do with the topic.

1 Like