Where does FreeBSD store hostname once set?
-
@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 ( ? )
-
@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
-
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!
-
FYI-
uname -i
is the name of the kernel config file, not your hostname.The hostname from
config.xml
gets set viahostname
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 -
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}'
-
@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.
-
@gertjan said in Where does FreeBSD store hostname once set?:
hostname | awk -F"." '{print $1}'
Simpler:
hostname -s
(andhostname -d
gives the domain part :-D) -
@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.
-
@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 ;)
-
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.