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

    Where does FreeBSD store hostname once set?

    General pfSense Questions
    4
    13
    1.5k
    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.
    • MrPeteM
      MrPete
      last edited by

      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 Reply Quote 0
      • R
        rcoleman-netgate Netgate @MrPete
        last edited by

        @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

        MrPeteM 1 Reply Last reply Reply Quote 0
        • MrPeteM
          MrPete @rcoleman-netgate
          last edited by

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

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

          GertjanG R 2 Replies Last reply Reply Quote 0
          • GertjanG
            Gertjan @MrPete
            last edited by Gertjan

            @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

              @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
              • MrPeteM
                MrPete
                last edited by

                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!

                GertjanG 1 Reply Last reply Reply Quote 0
                • jimpJ
                  jimp Rebel Alliance Developer Netgate
                  last edited by

                  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!

                  MrPeteM 1 Reply Last reply Reply Quote 2
                  • GertjanG
                    Gertjan @MrPete
                    last edited by

                    @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 ??

                    MrPeteM 1 Reply Last reply Reply Quote 1
                    • MrPeteM
                      MrPete @jimp
                      last edited by

                      @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.

                      jimpJ 1 Reply Last reply Reply Quote 0
                      • MrPeteM
                        MrPete @Gertjan
                        last edited by

                        @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
                        • jimpJ
                          jimp Rebel Alliance Developer Netgate @MrPete
                          last edited by

                          @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!

                          MrPeteM 1 Reply Last reply Reply Quote 0
                          • MrPeteM
                            MrPete @jimp
                            last edited by MrPete

                            @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
                            • jimpJ
                              jimp Rebel Alliance Developer Netgate
                              last edited by

                              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
                              • First post
                                Last post
                              Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.