I have the following connectionString for my db:


I want to resolve someIpAdress to the DNS name instead. By running nslookup on the ip I get the name for that address. But replacing the Ip with the DNS name results in a failing connection for the jdbc connection.

I have tried modifying the file /etc/resolv.conf which now allows me to ping the DNS name, but it seems like the configuration should be done with netplan for Ubuntu 18.04LTS. Changes to interfaces in /etc/network didn't work either.

Some of the guides I've looked at so far: https://www.cyberciti.biz/faq/howto-set-dns-search-list-for-host-name-lookup/

Any help is much appreciated

up vote 1 down vote accepted

If you use 18.04 there is some bug of auto generate resolv.conf file. Create symlink which following command fixs this problem.

sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

But if you don't have DNS server you can edit /etc/hosts   localhost   com01

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters  lab01

From above configuration com01 is your computer name is your server IP address and lab01 is your server name.

Hope this help.

  • I already have that configuration in /etc/hosts and the ln command failed since /etc/resolv.conf already exists – Øystein Seel Nov 13 at 10:47
  • Your answer tunred out to be correct. I had only provided the IP for the parent DNS, but had to manually add thoose i needed – Øystein Seel Nov 13 at 11:41
  • Just make sure that resolv.conf is linked to path /run/systemd/resolve/resolv.conf if you use 18.04. It's always not getting right DNS if it isn't linked to the path and you can remove /etc/resolv.conf in case it already exist and run command to link file again. – eetsurt Nov 13 at 11:49

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.