DNS multiple hostnames for IP (like /etc/hosts)



  • Hello Experts,

    I'm considering to by a netgate appliance (SG-1100) in order to start my "learning curve" with pfsense and to place it behind by ISP's router at home.

    One thing I miss from the current setup (with ISP's router) is to assign multiple hosts names to a DHCP provided IP address. I had this working some decades ago but sadly don't remember how.

    To phrase it another way, I'd like to have the functionality of /etc/hosts (but with DHCP assigned IP addresses):

    from "man hosts"


    This  manual page describes the format of the /etc/hosts file.  This file is a simple text file that associates IP addresses with hostnames, one line
           per IP address.  For each host a single line should be present with the following information:
    
                  IP_address canonical_hostname [aliases...]
    

    Is there any way to do this with pfsense (web-ui or console, as long as it is persistant)?

    Thanks in advance!

    Cheers,
    Soc



  • It's very easy to do. On the DNS resolver page, create as many host overrides as you wish.



  • Hi JKnott,
    thank you very much for your fast response.

    Glad to hear, that "it works (TM)" ;-)

    I just installed pfsense in a test VM and the host override settings in

    Services / DNS Resolver / General Settings / Edit Host Override

    requires to specify an IP Address.

    So it seems to me that this approach does only work with static IP addresses but not DHCP?

    Thanks,
    Soc


  • LAYER 8 Global Moderator

    Set a reservation for this device so it always gets the same IP... Not understanding issue..



  • Hi johnpoz,

    I'm sorry if I appear "NOOBish" ... but I was "of of practise" for 15 years :-(

    But your post made me remember "static leases" ... I think I'm good now :-)

    kind regards,
    Soc



  • @socrates324 said in DNS multiple hostnames for IP (like /etc/hosts):

    So it seems to me that this approach does only work with static IP addresses but not DHCP?

    That depends on whether there's a static mapping for the address. With static mappings, the addresses are the same as static. Otherwise, they could change, which means there's no consistent address to point to. One thing some DNS servers can do is create an alias, where one name refers to another. I do this with my IPv4 WAN address, where my host name is long and based on the firewall and modem MAC addresses. I just create an alias, in my own domain, that points to the long host name. I don't know if that's supported with pfSense.


Log in to reply