how to resolve local hostname to ip in pfSense
-
@JKnott said in how to resolve local hostname to ip in pfSense:
I hope you didn't directly edit the hosts file, instead of doing it in the GUI.
Sounds like he was directly editing the /etc/hosts file. That will work for DNS lookups on the local firewall (although it is still bad practice), but external clients asking a DNS server on the firewall for addresses won't get those host entries. They will instead get whatever the DNS server has it in its own internal databases.
-
thank both jknott and bmeeks.
We use dns forwarder in pfsense, not dns resolver. I edit /etc/hosts in pfsense and added record like "10.0.10.251 host1 host1.mydomain.com". And the pfsesne is our LAN DNS server.We cannot make "# ping host1" works in our LAN.
Maybe I have to switch to DNS resolver?
-
The solution has already been provided. Don't edit /etc/hosts directly. Create the records on the forwarder page. That way, you can use pfSense as your DNS server. It will return the address for anything that you've added and, failing that, get the info from whatever DNS server it points to.
-
@caigeliu said in how to resolve local hostname to ip in pfSense:
thank both jknott and bmeeks.
We use dns forwarder in pfsense, not dns resolver. I edit /etc/hosts in pfsense and added record like "10.0.10.251 host1 host1.mydomain.com". And the pfsesne is our LAN DNS server.We cannot make "# ping host1" works in our LAN.
Maybe I have to switch to DNS resolver?
No, if you are still using the old DNS Forwarder in pfSense, then go to SERVICES > DNS FORWARDER and then scroll down that page until you see the section for Host Overrides. Create new host entries there and you should be good to go (assuming that all of your LAN clients are pointed to the pfSense firewall for their DNS services).
-
"No, if you are still using the old DNS Forwarder in pfSense, then go to SERVICES > DNS FORWARDER and then scroll down that page until you see the section for Host Overrides. Create new host entries there and you should be good to go (assuming that all of your LAN clients are pointed to the pfSense firewall for their DNS services)."
I have done exactly too. But it only works for "# ping host1.mydomain.com", not work for "#ping host1".
We want "# ping host1" work in our LAN. pfSense is our dns server. we use dns forwarder.
-
@caigeliu said in how to resolve local hostname to ip in pfSense:
But it only works for "# ping host1.mydomain.com", not work for "#ping host1"
That's a function of the client, not the server. In the client, there should be a place where the local domain is specified. With that, when you only specify the host, the domain is automagically appended. This is why I earlier said to use the same domain name as the network already uses. So, if the LAN is part of mydomain.com, then you would use that in configuring the DNS records, as you were trying to do earlier. That is, in the forwarder host overrides, you would create a record for host1 with host1 in the host box and mydomain.com in the domain box.
-
"That's a function of the client, not the server. ".
I think it should be a function of DNS server. Is there a function in pfsense DNS forwarder that when query of "host1" is received by the dns forwarder, the dns forwarder automatically search host1.mydomain.com and return that IP to user?
-
No, it's a client function as I described above. Configure the domain name in the client as I described, so that it matches the domain name in the DNS record.
Here's some info on it from my Linux system:
"Search domain is the domain name where hostname searching starts. The primary search domain is usually the same as the domain name of your computer (for example, suse.de). There may be additional search domains (such as suse.com). Separate the domains with commas or white space. "
You can have one or more domains that can be searched without specifying the fully qualified domain name. So, for host1, it would look in mydomain.com and any other domains you specified.
-
Thank jknott.
Then is it possible to enable this function in the pfsense dns forwarder? In a LAN, there are many different types of devices. It is difficult to make such a change in each device. -
The way it's typically done is in the DHCP server, where you can configure a variety of parameters, including domain name. You haven't said much about the network where you're doing this, but you have to configure somethings in the DHCP server and others in the DNS. Also, since you've provided so little info, it's hard to determine exactly what you're trying to do. Do you have access to the DHCP server? Can you ask whoever is responsible to do things? It's really hard to advise, when we don't know what you have. This brings up another point. With DHCP, you'll be given the DNS server address to use, which is unlikely to be your pfSense box. This means you'll have to override it on whatever devices you're using. I'm also wondering what the role of pfSense is, other than DNS server.
-
@JKnott Thanks. But here's the question. I want devices on a specific vlan to access a host by name. I have provided an internal domain. I can ping the host and ssh into it, but I cant access the http server through the name, but I can through the ip address. Do you have any suggestions that could help, ahem, resolve this issue ?
-
Again, you need a DNS server, somewhere, that contains the address and host name. Do you have one somewhere? Hostname to IP doesn't just work automagically.
-
@JKnott Thanks a lot for your replies. Like an idiot, I had not noticed that the server on my lan was not running when I started to try to access the http service. In pfsense it appears to need a xxx.yyy domain rather than xxx in my DNS resolver setings so another mistake I made was to omit yyy in my later tests where I was trying to see exactly how that domain needed to be represented. In any case, with pfsense 2.4.5, I can now go to host overrides in DNS resolver, set the name of my server thus 'thiservername' and point it to a LAN address adding xxx.yyy in the parent domain entry and all is well. Additionally in /etc/hosts it shows up as 192.68.abc.def thiservername.