I have a dynamic public IPv4 address configured on my router. There is a TCP based service running somewhere behind that router at With a dynamic DNS I can access this service using a hostname:port without problems.

However, when I'm in that network, I want to connect to this same service with the same hostname. I can't connect by other means, as the service's client relies on SRV records. If the address would be static, I could put an iptables rule like

-t nat -A OUTPUT -d publicip -s local/net -j DNAT --to-destination=

However this obviously doesn't work with dynamic addresses; how could I solve this? (Creating local DNS zone is not an option, I'm not an admin there)

  • I am doing something like that here iptables -t nat -A POSTROUTING -o eth0.101 ! -p esp -j SNAT --to-source `ip addr show eth0.101 | grep inet | awk ' { print $2 } ' | cut -f1 -d "/"` – Rui F Ribeiro Dec 8 '15 at 21:17
  • This won't work if the interface gets reconfigured by the DHCP daemon. – Gergely Polonkai Dec 8 '15 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.