• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

Where does FreeBSD store hostname once set?

Scheduled Pinned Locked Moved General pfSense Questions
13 Posts 4 Posters 1.6k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M
    MrPete
    last edited by Apr 17, 2023, 11:49 PM

    Or maybe I should ask, is it stored anywhere? :)

    I sure can't find it in the supposedly normal places (/etc/hostname, /etc/rc.conf)

    R 1 Reply Last reply Apr 18, 2023, 12:34 AM Reply Quote 0
    • R
      rcoleman-netgate Netgate @MrPete
      last edited by Apr 18, 2023, 12:34 AM

      @mrpete it is set from your XML file by a script - there is no stored file in pfSense but configured using the /bin/hostname binary.

      Set the hostname in the GUI: System->General Setup

      Screenshot 2023-04-17 at 7.34.18 PM.png

      Ryan
      Repeat, after me: MESH IS THE DEVIL! MESH IS THE DEVIL!
      Requesting firmware for your Netgate device? https://go.netgate.com
      Switching: Mikrotik, Netgear, Extreme
      Wireless: Aruba, Ubiquiti

      M 1 Reply Last reply Apr 18, 2023, 1:57 AM Reply Quote 0
      • M
        MrPete @rcoleman-netgate
        last edited by Apr 18, 2023, 1:57 AM

        @rcoleman-netgate
        I know about config.xml...

        So my guess was correct: it's not necessarily stored anywhere, just set dynamically. Interesting!

        G R 2 Replies Last reply Apr 18, 2023, 8:11 AM Reply Quote 0
        • G
          Gertjan @MrPete
          last edited by Gertjan Apr 18, 2023, 8:11 AM Apr 18, 2023, 8:11 AM

          @mrpete said in Where does FreeBSD store hostname once set?:

          anywhere

          Try this :

          I presume your LAN interface has the default IP 192.168.1.1

          Ok go for :

          host 192.168.1.1
          

          if you've set a host override for the other LAN or WAN interface IPs, you'll get that host.domain back.

          Btw : a firewall / router has multiple interfaces, so, what is the host name ?
          Depends.
          What interface ?

          Btw :

          uname -i
          

          returns what you've set in System > General Setup > Hostname ( ? )

          No "help me" PM's please. Use the forum, the community will thank you.
          Edit : and where are the logs ??

          1 Reply Last reply Reply Quote 0
          • R
            rcoleman-netgate Netgate @MrPete
            last edited by Apr 18, 2023, 4:12 PM

            @mrpete said in Where does FreeBSD store hostname once set?:

            it's not necessarily stored anywhere

            It is stored... it is in /conf/config.xml

            Ryan
            Repeat, after me: MESH IS THE DEVIL! MESH IS THE DEVIL!
            Requesting firmware for your Netgate device? https://go.netgate.com
            Switching: Mikrotik, Netgear, Extreme
            Wireless: Aruba, Ubiquiti

            1 Reply Last reply Reply Quote 0
            • M
              MrPete
              last edited by Apr 19, 2023, 6:52 PM

              Wow!
              @Gertjan, nope.

              • uname -i returns "pfSense" which I have not configured anywhere. (My general settings host is "jasmine" ;) )
              • rDNS for each interface of course could be anything... or several things. That's why I wasn't asking about that.

              @rcoleman-netgate /conf/config.xml is where pfSense keeps the configuration info, yes.

              I am asking about FreeBSD because various systems, apps, tools, security monitors etc want to know about system names.

              Apparently the answer, for a pfSense setup, is:

              • We don't use the typical FreeBSD config files
              • But hostname will give the needed information

              I'm good with that!

              G 1 Reply Last reply Apr 20, 2023, 12:50 PM Reply Quote 0
              • J
                jimp Rebel Alliance Developer Netgate
                last edited by Apr 20, 2023, 12:33 PM

                FYI- uname -i is the name of the kernel config file, not your hostname.

                The hostname from config.xml gets set via hostname so it's set in the kernel, plus added to /etc/hosts, the unbound config, dnsmasq config, etc.

                See also:
                https://github.com/pfsense/pfsense/blob/master/src/etc/inc/system.inc#L880

                Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                Need help fast? Netgate Global Support!

                Do not Chat/PM for help!

                M 1 Reply Last reply Apr 22, 2023, 12:27 PM Reply Quote 2
                • G
                  Gertjan @MrPete
                  last edited by Apr 20, 2023, 12:50 PM

                  @mrpete

                  Indeed, I stand corrected.
                  Stupid me, as my pfSense was called pfSense when I got it, and I found that, back then, a good device name.
                  I'm not sure why I was checking out all the "uname" options, abd stopped at the -i option. Should have fact check that one first.
                  Worse : I forgot about 'hostname', as that command name gives right away the answer to the question.

                  Btw :

                  hostname | awk -F"." '{print $1}'
                  

                  No "help me" PM's please. Use the forum, the community will thank you.
                  Edit : and where are the logs ??

                  M 1 Reply Last reply Apr 22, 2023, 12:30 PM Reply Quote 1
                  • M
                    MrPete @jimp
                    last edited by Apr 22, 2023, 12:27 PM

                    @jimp Thanks, Jim!
                    The Code always FTW :)

                    I do have a question, now that I see this picture:

                    Although the hostname IS listed as local-data in /var/unbound/host_entries.conf ... hostname is NOT used as the rDNS (local-data-ptr in the same file)!

                    Instead, whatever entry happens to be first in the list of host overrides is used.

                    Is that expected? Seems kinda random and unintuitive to me.

                    J 1 Reply Last reply Apr 24, 2023, 12:34 PM Reply Quote 0
                    • M
                      MrPete @Gertjan
                      last edited by Apr 22, 2023, 12:30 PM

                      @gertjan said in Where does FreeBSD store hostname once set?:

                      hostname | awk -F"." '{print $1}'

                      Simpler: hostname -s (and hostname -d gives the domain part :-D)

                      1 Reply Last reply Reply Quote 2
                      • J
                        jimp Rebel Alliance Developer Netgate @MrPete
                        last edited by Apr 24, 2023, 12:34 PM

                        @mrpete said in Where does FreeBSD store hostname once set?:

                        @jimp Thanks, Jim!
                        The Code always FTW :)

                        I do have a question, now that I see this picture:

                        Although the hostname IS listed as local-data in /var/unbound/host_entries.conf ... hostname is NOT used as the rDNS (local-data-ptr in the same file)!

                        Instead, whatever entry happens to be first in the list of host overrides is used.

                        Is that expected? Seems kinda random and unintuitive to me.

                        I don't see what you mean there on my systems here. I have an unrelated host override defined and yet the firewall's own hostname is there in forward/reverse:

                        local-data-ptr: "10.34.0.1 pfSense.home.arpa"
                        local-data: "pfSense.home.arpa. A 10.34.0.1"
                        

                        You're probably misreading the file, or have something else in your config that's overriding the expected behavior.

                        Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                        Need help fast? Netgate Global Support!

                        Do not Chat/PM for help!

                        M 1 Reply Last reply Apr 24, 2023, 5:51 PM Reply Quote 0
                        • M
                          MrPete @jimp
                          last edited by MrPete Apr 24, 2023, 5:53 PM Apr 24, 2023, 5:51 PM

                          @jimp I think this is a real bug.

                          First, some context, most of which probably doesn't matter at all ;)

                          • My actual pfSense hostname is in the middle of the alphabet (jasmine.ds.org)
                          • I have a number of subnets, but primary is 192.168.1.0/24 with pfSense at .1.1 (and .1.2 , .1.3 for CARP)
                          • I do have a host override for the hostname to .1.1 (changing or removing this has no impact)
                          • (This may be crucial) I have a number of host overrides that all point to .1.1 for HAproxy use

                          I just proved my conjecture

                          • Clearly rDNS for a given IP can and must only point to one name
                          • I would hope that hostname takes priority over all others in that regard
                          • Instead, what I suggested above is true: the local rDNS name given to the local hostname IP, will be: whatever name is alphabetically first in the host override list.

                          You can test this yourself:

                          • Add an override to the top of the list, pointing to your LAN pfSense IP (in my case: aa-test.ds.org -> 192.168.1.1)
                          • The local rDNS became: local-data-ptr: "192.168.1.1 aa-test.ds.org"
                          • Changing other things has no impact

                          I guess we could say that use of HAproxy overrides the expected behavior?

                          Are you thinking that as long as NO other override points to .1.1, pfSense will configure a local-data-ptr entry for the hostname?

                          I also note: names (hostname or otherwise) are also not auto-assigned to any other local subnet gateway IP's (from DHCP, interface IP, or otherwise.)

                          At this point, my expectations are low: I'm fine with no names for most of those... I would just hope that whatever local IP is/are assigned to hostname, would take precedence for the reverse, period (whether or not other overrides are present.) It would avoid quite a bit of name confusion ;)

                          1 Reply Last reply Reply Quote 0
                          • J
                            jimp Rebel Alliance Developer Netgate
                            last edited by Apr 25, 2023, 12:20 PM

                            You can open a Redmine for that, will get addressed eventually. Seems like it will be quite a bit trickier to solve than it appears on the surface, though.

                            Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                            Need help fast? Netgate Global Support!

                            Do not Chat/PM for help!

                            1 Reply Last reply Reply Quote 1
                            13 out of 13
                            • First post
                              13/13
                              Last post
                            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
                              This community forum collects and processes your personal information.
                              consent.not_received