OPNsense Forum

English Forums => General Discussion => Topic started by: pankaj on November 18, 2021, 03:18:40 AM

Title: Define hostnames to IP Address [Solved]
Post by: pankaj on November 18, 2021, 03:18:40 AM
Hi,

If I've a Synology NAS on home network called "NAS", is there any configuration within OPNSense that allows http://NAS to resolve to the specified IP address?

The home LAN is configured to use OPNSense for DNS service.
Thanks,
Title: Re: Define hostnames to IP Address
Post by: Morta on November 18, 2021, 06:31:29 AM
You can use dnsmasq instead of unbound dns then add the ip and hostanme as shortname to /etc/hosts.
Title: Re: Define hostnames to IP Address
Post by: chemlud on November 18, 2021, 08:19:02 AM
Quote from: Morta on November 18, 2021, 06:31:29 AM
You can use dnsmasq instead of unbound dns then add the ip and hostanme as shortname to /etc/hosts.

The same can be done in unbound on "Overrides"...
Title: Re: Define hostnames to IP Address
Post by: Morta on November 18, 2021, 08:55:46 PM
Quote from: chemlud on November 18, 2021, 08:19:02 AM
Quote from: Morta on November 18, 2021, 06:31:29 AM
You can use dnsmasq instead of unbound dns then add the ip and hostanme as shortname to /etc/hosts.

The same can be done in unbound on "Overrides"...

Are they only affected after a reboot? Entries seems not work?!
Title: Re: Define hostnames to IP Address
Post by: pankaj on November 21, 2021, 02:48:14 AM
So I tried using Unbound override option(see screenshot).

- The command "ping NAS" returns positively
- But trying "ping NAS" gets an error "ping: NAS2: Temporary failure in name resolution"

Did I not use override options correctly?
Title: Re: Define hostnames to IP Address
Post by: Patrick M. Hausen on November 21, 2021, 06:44:43 AM
The "domain" field content is obviously broken. Should match your OPNsense domain.
Title: Re: Define hostnames to IP Address
Post by: pankaj on November 21, 2021, 07:17:52 AM
Yes domain name was broken due to shoddy copy & paste. I fixed it but the result is still the same.

One question, the "host" field at the very start. What value gets specified here - the hostname as it currently registers with DHCP lease or the one that I want to be associated with this IP address? I've tried both options but neither works!
Title: Re: Define hostnames to IP Address
Post by: pankaj on November 21, 2021, 08:08:11 AM
I got it to work and had to make two tweaks:

1. Leave the host name at the top of the screen blank
2. While testing I had to ping using NAS2.OPNSense.localdomain

And it worked  8)
Title: Re: Define hostnames to IP Address [Solved]
Post by: Patrick M. Hausen on November 21, 2021, 08:19:20 AM
If you send the opnsense.localdomain as the search domain to your clients via DHCP, then `ping nas2` should also work.
Title: Re: Define hostnames to IP Address [Solved]
Post by: pankaj on November 21, 2021, 08:30:10 AM
@pmhausen
@Morta
@chemlud

Thanks for your inputs and pointing me in the right direction  :)