Solved Hostname resolution when installing FreeBSD

I'm attempting to do an unattended installation of FreeBSD from a memstick image using bsdinstall() and a script (/etc/installerconfig). The installation of FreeBSD works fine, but I'm trying to install some pkgs at the same time and that involves accessing pkg.FreeBSD.org, but hostname resolution fails.

I addedd 'ifconfig_em0='DHCP' to /etc/rc.conf, which provides an IP address although I assumed that it would configure /etc/resolv.conf, but this file is just a symbolic link to /tmp/bsdinstall_etc/resolv.conf which is a non-existent file in a non-existent directory.

Anyone know how hostname resolution is supposed to work in this scenario?
 
Anyone know how hostname resolution is supposed to work in this scenario?
There shouldn't be any file creation needed. That file will be created automatically after the DHCP server has been contacted. From /etc/rc.local:

Code:
# resolv.conf from DHCP ends up in here, so make sure the directory exists
mkdir /tmp/bsdinstall_etc
I suggest to remove Ifconfig_em0='DHCP' from /etc/rc.conf, boot the installation media, enter "Shell" and check ifconfig and ping -c3 pkg.freebsd.org.

I've check on my system, a re(4), the device interface is created, the DHCP server (router) contacted, IP optained and /tmp/bsdinstall_etc/resolv.conf created if absent , populated, without any configuration.
 
There shouldn't be any file creation needed. That file will be created automatically after the DHCP server has been contacted. From /etc/rc.local:

Code:
# resolv.conf from DHCP ends up in here, so make sure the directory exists
mkdir /tmp/bsdinstall_etc
I suggest to remove Ifconfig_em0='DHCP' from /etc/rc.conf, boot the installation media, enter "Shell" and check ifconfig and ping -c3 pkg.freebsd.org.

I've check on my system, a re(4), the device interface is created, the DHCP server (router) contacted, IP optained and /tmp/bsdinstall_etc/resolv.conf created if absent , populated, without any configuration.
ifconfig did not have an IP address assigned. At what point is one supposed to get assigned? Looks like I'm missing something...

the directory /tmp/bsdinstall_etc did already exist. Think I will get another copy of the memstick image and start again.

Just wondered which installation image you used.
 
Spent most of the day on this, and reckon you are the only person who understands how the whole thing works :)...

After amending /etc/rc.local as you said, plus adding a couple of diagnotics statements, I can confirm that IP assignment *and* host name resolution works when dropping into the shell in interactive mode. ***However*** when using /etc/installerconfig the IP address is assigned but host name is *NOT* resolved. It's as if resolv.conf gets deleted somewhere along the way :(.
 
Yes, resolvconf(8) updates/controls that file. It was created to solve the issue that different network interfaces @different networks want to change resolv.conf(5). E.g. it's common to have WLAN & LAN interface. resolvconf(8) handles that. But frankly, it's by far not perfect... I'm dialing in via ppp on WWAN (like a stupidPhone), I had to add that to /etc/ppp/ppp.linkup script, and often when I have WLAN @friends or in a café I have to manually adjust...
 
Dunno if it helps...

Before I reconfigured my router to use static IPs instead of DHCP a few years ago, I remember setting up my /etc/resolv.conf manually and remove all write permissions on it to avoid DHCP clobbering it. DHCP gave a warning about not being able to modify the file, but worked. This was a few FreeBSD versions ago, so this might no longer work.

Thus, maybe removing the link and placing an actual, write-protected file into /etc/resolv.conf might be worth a try?
 
... reckon you are the only person who understands how the whole thing works
Thanks for the confidence but I made a mistake here.
I've check on my system, a re(4), the device interface is created, the DHCP server (router) contacted, IP optained and /tmp/bsdinstall_etc/resolv.conf created if absent , populated, without any configuration.
That statement is incorrect. I compared a mounted fresh installation image file with the image on the USB stick and found a configuration I set but forgot about it. In /etc/rc.conf I've set:

Code:
ifconfig_DEFAULT="DHCP"
Seeing the settings there earlier I assumed all of them come default with the installation image. This explains the automatic configuration of the network interface and creation of resolv.conf. Please set the above configuration, and remove from /etc/rc.local dhclient em0.

I would like to offer my apologies for my negligence not to document the modifications I made, leading you to lose time.

Also it might be a good idea to merge this thread with the other one to ensure a continuity of that thread:
 
Yes, that's the idea of the "mini" versions, they don't contain anything and will download the installation files from the internet (or whatever repository you set).

mini-memstick

This can be written to a USB memory stick (flash drive) and used to boot a machine, but does not contain the installation distribution sets on the medium itself, similar to the bootonly image. It also supports booting into a "livefs" based rescue mode. There are no pre-built packages.
 
That statement is incorrect. I compared a mounted fresh installation image file with the image on the USB stick and found a configuration I set but forgot about it. In /etc/rc.conf I've set: [...]
I use oldie but goldie devel/rcs to keep track of changes I make to config files. In contrast to it's "add-on" devel/cvs, it can be used directly by root & it's functionality is fully sufficient. Still didn't add a script into ~/.logout to ci -l all files that I edited, though...
 
Yes, that's the idea of the "mini" versions, they don't contain anything and will download the installation files from the internet (or whatever repository you set).
That's what I was querying... ie did T-Daemon have a /etc/installerconfig which actually fetched the required files..
 
I use oldie but goldie devel/rcs to keep track of changes I make to config files. In contrast to it's "add-on" devel/cvs, it can be used directly by root & it's functionality is fully sufficient. Still didn't add a script into ~/.logout to ci -l all files that I edited, though...
Thanks for the tip, but in this case it would be overkill . There are only a few lines of settings to record, a simple text file would have sufficed.
 
Just noticed the mini-memstick image does not contain kernel.txzand base.txz, so does installerconfig fetch them for you?

/etc/installerconfig won't fetch the distribution files. That part needs to be scripted in /etc/rc.local. Also space for the downloaded files needs to be created, an extra partition or tmpfs(5), haven't tried growfs(8) but it's not worth the effort, it's easier to download an image which has the files already inside. However, if you are interested I can provide the script.

When I downloaded the installation image when 12.2-RELEASE came out I had a limited mobile data plan (I'm using my smartphone as a mobile hotspot). A xz mini memstick image, kernel and base package have less than half the size of an xz memstick image. On the installation USB stick I've created an extra partition containing the files, mounted from /etc/fstab.

Now I could have downloaded a new image but I had that stick already ready for use and it's fun to experiment with different scenarios. At the moment I'm simulating a download of the dist files into a created tmpfs from a partition on the same USB disk.

Back then when the release came out I managed to figured out how to install from that USB stick in VirtualBox, which saved me from downloading installer images as .iso files, going easy on the mobile data volume.

Apropos, had you any progress with the hostname resolution?
 
Did you read the following reply, too? Of course you can, but SirDice calls that "better work with the system, not against it".
When I did back then, either the nohook option wasn't there yet or I missed it in the documentation pile, or I didn't manage getting it to work, so I had to figure out some means to protect the original /etc/resolv.conf file.

This apparently happens to many people. So maybe it is a documentation problem of some essential information that should be mentioned prominently on the first page actually being hidden in some appended document referenced only by footnote.
 
RTFM dhcpcd.conf(5) option nohook please, so it does not touch resolv.conf(5).

Are you going to tell me to RTFM, too?

When I hit the network screen during build of the base system I leave it blank and click on through. DCHP is established, machinename jigoku appears on the router tables and here I am. Hell on Earth. Live and in person with no editing of any file whatsoever mentioned above and I read them all. I've never even used /etc/fstab the whole time I've used FreeBSD.

"Now you'll configure your network interface. Choose your Ethernet card for starters. FreeBSD is not Linux, so it will have a different designation but you should be able to pick it out from a wireless card.

Now choose Yes when asked if you'd like to configure IPv4.

Choose Yes to configure DHCP. It will scan and pick up your router interface, go with it."

Read My Friendly Tutorial

Because I taught myself to use FreeBSD from becoming a PC-BSD beta tester, and for some reason didn't think the Handbook applied and never consulted it once. Though I would not recommend doing so to others I learned though trial, error and google-fu to use FreeBSD and taught myself ports, too.

And how to use ports-mgmt/portmaster.
 
If you want install package in /etc/installconfig, remember script part of it is running in chroot mode.

So what would I need to do to add pkgs? As far I can see my 'resolv.conf' is not accessible so am unable to contacts pkg.freebsd.org'. Is this because 'pkg add xyz' is running in chroot?
 
/etc/installerconfig won't fetch the distribution files. That part needs to be scripted in /etc/rc.local. Also space for the downloaded files needs to be created, an extra partition or tmpfs(5), haven't tried growfs(8) but it's not worth the effort, it's easier to download an image which has the files already inside. However, if you are interested I can provide the script.

When I downloaded the installation image when 12.2-RELEASE came out I had a limited mobile data plan (I'm using my smartphone as a mobile hotspot). A xz mini memstick image, kernel and base package have less than half the size of an xz memstick image. On the installation USB stick I've created an extra partition containing the files, mounted from /etc/fstab.

Now I could have downloaded a new image but I had that stick already ready for use and it's fun to experiment with different scenarios. At the moment I'm simulating a download of the dist files into a created tmpfs from a partition on the same USB disk.

Back then when the release came out I managed to figured out how to install from that USB stick in VirtualBox, which saved me from downloading installer images as .iso files, going easy on the mobile data volume.

Apropos, had you any progress with the hostname resolution?
I'm lucky enough at the moment to have 300Mb connection so don't suffer an access limit.

As for hostname resolution, I can't get this working via installerconfig. If I don't have an installerconfig and jump into the shell I can access the required hosts by name. I did include 'dhclient em0' in /etc/rc.local to achieve this. I even tried a call to include /etc/rc.local in the script but it couldn't be found.

Not sure if Thread 51972 provides me with an insight into what I should do...
 
Back
Top