# bsdinstall's /etc/installerconfig networking help



## Farhan Khan (Mar 24, 2022)

Hi all,
I am trying to use etc/installerconfig to templatize the dev VM installations that I frequently do, but cannot figure out how to enable networking. I would like to enable networking during the install, so that I can download packages. The interface name with likely be em0, or vtnet0. Is there a way to say "DHCPv4 on whichever interface is available"? Can that be saved for the OS?

The end of my script shares a lot of "DEBUG" messages under a menu that says "Error", though I do not see an error, it seems to just be variable settings but I do not see an actual error message. This seems to happen immediately after the `pkg` command, which only prompts me to if I want to install `pkg`, but does not actually install.

My installation script is this:

```
DISTRIBUTIONS="kernel.txz base.txz"
export ZFSBOOT_VDEV_TYPE=stripe
export ZFSBOOT_DISKS="ada0"
export nonInteractive="YES"

#!/bin/sh

sysrc ifconfig_DEFAULT=DHCP
sysrc sshd_enable=YES
sysrc hostname=freebsddevm
sysrc sendmail_enable="NONE"

echo Install packages
pkg -y install sudo bash git gdb bat vim tmux rsync

echo Setup User
pw user add farhan -w random -m -s /usr/local/bin/bash
mkdir -m 700 /home/farhan/.ssh
echo ssh-rsa REMOVED_LONG_KEY > /home/farhan/.ssh/authorized_keys

echo Clone Repository
chown farhan:farhan /usr/src
/usr/local/bin/git clone https://github.com/freebsd/freebsd-src /usr/src
```

Please advise. Thanks!


----------



## T-Daemon (Mar 24, 2022)

Farhan Khan said:


> I would like to enable networking during the install, so that I can download packages. The interface name with likely be em0, or vtnet0. Is there a way to say "DHCPv4 on whichever interface is available"?


Boot the FreeBSD installer image into single user mode, mount the file system read/write, add `ifconfig_DEFAULT="DHCP"` to /etc/rc.config.



Farhan Khan said:


> Can that be saved for the OS?


You have the setting already in your script:


Farhan Khan said:


> #!/bin/sh
> 
> sysrc ifconfig_DEFAULT=DHCP



As a side note: Those echo(1) commands in the script don't do any good. The installation process is to fast to notice them. If you want them to be visible  implicitly, suspend the installation process after their execution with the sleep(1) command.


----------



## T-Daemon (Mar 24, 2022)

Farhan Khan said:


> This seems to happen immediately after the `pkg` command, which only *prompts me to if I want to install* `pkg`, but does not actually install.


To avoid prompting for confirmation add `pkg bootstrap -y` before the other package installations to the script.


----------



## Farhan Khan (Mar 24, 2022)

Hi T-Daemon, thanks for the reply!

Unfortunately, this results in the same "crash" shortly after installing the two distributions. Typically when I run `dhclient em0` I expect to see a short delay where the connection happens, but here no such delay is happens.

This leads me to suspect that dhclient is not being run? Or is erroring out immediately? I have no idea. But, I know that other VMs on the same virtual LAN have NAT connectivity.


----------



## T-Daemon (Mar 24, 2022)

Boot into single user mode, edit the /etc/rc.conf as shown in my post #2, and disable (rename) /etc/installerconfig. Continue booting into multi user mode, at the FreeBSD installer "Welcome" dialog menu drop to "Shell", check ifconfig(8) and ping(8) 8.8.8.8.

If there is no internet connection check your LAN setup.

If there is internet connection check the script for errors. To locate the error I suggest to comment all the lines beginning with the package installation section of the script, then un-comment them one by one.

You didn't mention dhclient(8) before. It isn't necessary to call it. To get the network interface configured automatically to scripted install those packages and clone the FreeBSD source repository, all it takes is to edit the /etc/rc.conf file as mentioned before and add a name server to the newly installed system:

/etc/installerconfig

```
...
echo nameserver 8.8.8.8 > /etc/resolv.conf
pkg bootstrap -y
pkg install -y install sudo bash git gdb bat vim tmux rsync
...
```


----------

