depenguin-me / depenguin-run

Installer script for mfsBSD image to install FreeBSD 14.0 with zfs-on-root using qemu
MIT License
16 stars 7 forks source link

Provide the likely interface name in the installed BSD system during the mfsBSD boot step #75

Closed bretton closed 7 months ago

bretton commented 7 months ago

when the script has loaded up qemu and outputs this text

ssh -p 1022 mfsbsd@ip-address

it should also indicate the likely name of the resulting network interface in the installed system.

I don't know an easy way to do this, however I found the following

FreeBSD interface naming

The name of a FreeBSD interface starts with the name of its network driver.
It is then followed by a number starting at 0 that increases incrementally by
one for each additional interface sharing that driver. 
For example, a common driver used by Intel gigabit network interface cards is igb. 
The first such card in a firewall will be igb0, the second is igb1, and so on. 
Other common driver names include cxl (Chelsio 10G), em (Also Intel 1G), 
ix (Intel 10G), bge (various Broadcom chipsets), amongst numerous others.
If a system mixes an Intel card and a Chelsio card, the interfaces will be igb0
and cxl0 respectively.

source

It's tricky because Xneelo servers show eno0 in rescue system, em0 in mfsBSD, and igb0 when in resulting installed FreeBSD system.

However in some Hetzner server-bidding servers it would be em0 in mfsBSD and installed FreeBSD system.

Detecting the likely result in end system, and informing user, or automatically setting, would be useful.

grembo commented 7 months ago

Driver detection includes a of PCI ids, in case of intel, also some inspection of the mac potentially to decide if it's em or igb. Then there's the question of device ordering. Seems like a lot of work.

Maybe it makes more sense to provide some sort of firstboot rc script that corrects the issue automatically the first time the bare metal server boots?

bretton commented 7 months ago

It affects me for unattended install. I'm passing in an interface name in depenguin_settings.sh that has to be setup.

The value defaults to igb0 here

conf_interface="igb0"

Whatever is passed in gets renamed to untrusted as part of INSTALLERCONFIG

sysrc ifconfig_%%interface%%_name="untrusted"

My issue is some systems show em0 within mfsBSD, and then when booted, the system sees igb0 and has no network. It was the same with bsdinstall or unattended install script.

One server I had to change to em0 and the other back to igb0. So the info is useful at the mfsbsd stage.

What do you suggest on firstboot side?

grembo commented 7 months ago

My issue is some systems show em0 within mfsBSD, and then when booted, the system sees igb0 and has no network. It was the same with bsdinstall or unattended install script.

Yeah, it's em0, because that's what qemu emulates (it's not passing the actual hardware to you).

What do you suggest on firstboot side?

A script that detects the primary interface (either automatically based on a priority list or based on a stored value we passed in when running qemu [e.g., a mac address to find it]). Automatic based on priority should be fine for a start (igb0, em0, bge0...).

Once detected, it will run the proper ifconfig commands to rectify the situation and modify /etc/rc.conf to persist the change (basically removing ifconfig_whatever_name=untrusted and setting ifconfig_detected_name=untrusted).


Alternative dirty hack on install:

sysrc ifconfig_em0_name=untrusted
sysrc ifconfig_igb0_name=untrusted
sysrc ifconfig_bge0_name=untrusted

Which will work, until you encounter a system with multiple network interfaces using different drivers ;)

bretton commented 7 months ago

is ifconfig_DEFAULT always applicable to the plugged in NIC, or a DHCP thing?

grembo commented 7 months ago

is ifconfig_DEFAULT always applicable to the plugged in NIC, or a DHCP thing?

Nope, it's for everything, so not useful for this purpose.

grembo commented 7 months ago

I think the easiest way is to go the firstboot approach, should be fairly easy to accomplish. I can help you with it, just need to find a good place to test this.

bretton commented 7 months ago

just need to find a good place to test this.

I can test with a hetzner host