# 13.0-p4 losing static IP during boot



## Father Grigori (Nov 1, 2021)

Hello all.

I am having an issue with both my desktop and notebook not keeping their statically assigned (/etc/rc.conf)
network interface cards IP addresses.

If I recall correctly, this started after doing update to 13.0-RELEASE-p4 (freebsd-update fetch install).

AFAIK, both machines used to work perfectly with the same configurations before that.

Here´s my notebook /etc/rc.conf interface config as example:


```
ifconfig_alc0="inet 192.168.0.113 netmask 255.255.255.0"
```

The boot process goes fine, with messages showing alc0 getting the IP, but then it shows:


```
kenv: unable to get rc_system
Stopping network: alc0.
```

The same happens on my desktop computer, no matter if using bge0 or re0, etc. network cards.

If I manually apply: 
	
	



```
service netif restart
```

it assigns the IPs correctly, but after some traffic, the interfaces lose their static IPs again.
By the way, if getting IP via DHCP, it works fine.

Am I doing something wrong or did I forget to apply something? 
Any help is appreciated. Thank you.


----------



## SirDice (Nov 1, 2021)

Father Grigori said:


> ```
> kenv: unable to get rc_system
> ```


I think you might have a typo or something wrong in /etc/rc.conf. Maybe a missing quote somewhere?

Static IPs work just fine on 13.0. I have a whole bunch of 13.0 systems with static addresses.


----------



## zirias@ (Nov 1, 2021)

Or maybe the update isn't complete? I really wonder how `kenv` fits into the picture here…


----------



## covacat (Nov 1, 2021)

have you used ghostbsd before on the same boxes ?
it seems it set rc_system kenv var to openrc


----------



## Father Grigori (Nov 1, 2021)

SirDice said:


> I think you might have a typo or something wrong in /etc/rc.conf. Maybe a missing quote somewhere?
> 
> Static IPs work just fine on 13.0. I have a whole bunch of 13.0 systems with static addresses.


Hello SirDice.

The syntax of /etc/rc.conf is OK on both machines. I checked that.

When manually executing 
	
	



```
service netif restart
```
 or 
	
	



```
/etc/netstart
```
the interfaces come up with correct static IPs, although after some traffic they reset and lose IP again.

I really don't know what's wrong, but the problem seems to be something during boot time.


----------



## Father Grigori (Nov 1, 2021)

covacat said:


> have you used ghostbsd before on the same boxes ?
> it seems it set rc_system kenv var to openrc


Hello covacat.

No, I have never used GhostBSD on these boxes.

It is the first time I caught this 
	
	



```
kenv: unable to get rc_system
```
 error. 

And both PCs are plain FreeBSD.


```
uname -opr
FreeBSD 13.0-RELEASE-p4 amd64
```

I am clueless...


----------



## Father Grigori (Nov 1, 2021)

Zirias said:


> Or maybe the update isn't complete? I really wonder how `kenv` fits into the picture here…


Hello Zirias.

The update went fine and complete, as far as I can see.


----------



## SirDice (Nov 1, 2021)

Are you booting with EFI or CSM? You can check by looking at `sysctl machdep.bootmethod`. Maybe it's something that's been set in efivar(8).


----------



## covacat (Nov 1, 2021)

try grep -rl rc_system /etc/ /usr/local/etc


----------



## Father Grigori (Nov 1, 2021)

SirDice said:


> Are you booting with EFI or CSM? You can check by looking at `sysctl machdep.bootmethod`. Maybe it's something that's been set in efivar(8).


Hi...


```
# sysctl machdep.bootmethod
machdep.bootmethod: BIOS
```


----------



## Father Grigori (Nov 1, 2021)

covacat said:


> try grep -rl rc_system /etc/ /usr/local/etc


Hi.

The command above returned nothing.


----------



## SirDice (Nov 1, 2021)

What's in /boot/loader.conf?


----------



## Father Grigori (Nov 1, 2021)

SirDice said:


> What's in /boot/loader.conf?


Here is the entire content of my notebook´s /boot/loader.conf


```
kern.smb.disabled=1
autoboot_delay="2"
wlan_acl_load="YES"
cuse4bsd_load="YES"
vboxdrv_load="YES"
hw.psm.synaptics_support="1"
```


----------



## covacat (Nov 1, 2021)

put 
rc_system="bsdrc"
 in loader.conf see if it has any effect


----------



## SirDice (Nov 1, 2021)

Father Grigori said:


> kern.smb.disabled=1


Doesn't exist on 12 or 13? Why set this?


```
wlan_acl_load="YES"
```
Why are you loading this?


----------



## Father Grigori (Nov 1, 2021)

covacat said:


> put
> rc_system="bsdrc"
> in loader.conf see if it has any effect


Ok, I did it, but it had no effect.


----------



## Father Grigori (Nov 1, 2021)

SirDice said:


> Doesn't exist on 12 or 13? Why set this?
> 
> 
> ```
> ...


Oh, both lines were "leftovers" from some tests I did in the past. 
I removed them now, whithout any effect.


----------



## SirDice (Nov 1, 2021)

Father Grigori said:


> Oh, both lines were "leftovers" from some tests I did in the past.
> I removed them now, whithout any effect.


I didn't expect them to interfere but it's best to rule it out. Might want to go through your rc.conf the same way, if it's not needed/required remove it. That'll narrow down the possible places where things _could_ go wrong.


----------



## covacat (Nov 1, 2021)

did you reboot after adding rc_system="bsdrc" ?

```
kern.geom.label.gptid.enable="0"
ipfw_load="YES"
zfs_load="YES"
rc_system="bsdrc"
$ kenv rc_system
bsdrc
```


----------



## Father Grigori (Nov 1, 2021)

covacat said:


> put
> rc_system="bsdrc"
> in loader.conf see if it has any effect


Actually 
	
	



```
rc_system="bsdrc"
```
 in /boot/loader.conf supressed the

```
kenv: unable to get rc_system
```
message, but apparently did not influence other things.


----------



## Father Grigori (Nov 1, 2021)

SirDice said:


> I didn't expect them to interfere but it's best to rule it out. Might want to go through your rc.conf the same way, if it's not needed/required remove it. That'll narrow down the possible places where things _could_ go wrong.


I´m going to review the whole file... just a moment.


covacat said:


> did you reboot after adding rc_system="bsdrc" ?
> 
> ```
> kern.geom.label.gptid.enable="0"
> ...


Yes, I rebooted the system after adding that line.


----------



## covacat (Nov 1, 2021)

is the kenv msg showing up during boot, before the login prompt is shown ?
you can hack /etc/rc like this
add 
set -x at the top before the stty line
...
set -x
stty status '^T' 2> /dev/null
....
enable console.log in /etc/syslog.conf
....
# uncomment this to log all writes to /dev/console to /var/log/console.log
# touch /var/log/console.log and chmod it to mode 600 before it will work
console.info                    /var/log/console.log
.....

remove the rc_system line from loader.conf
reboot
grep the rc_system line in console.log


----------



## Father Grigori (Nov 1, 2021)

SirDice said:


> I didn't expect them to interfere but it's best to rule it out. Might want to go through your rc.conf the same way, if it's not needed/required remove it. That'll narrow down the possible places where things _could_ go wrong.


Here it is in entirity:


```
kld_list="i915kms"
hostname="note01"
keymap="br.noacc.kbd"
dbus_enable="YES"
devd_enable="YES"

ifconfig_alc0="inet 192.168.0.111 netmask 255.255.255.0"

wlans_ath0="wlan0"
ifconfig_wlan0="WPA DHCP"
sshd_enable="YES"
linux_enable="YES"
ntpdate_enable="YES"
powerd_enable="YES"
inetd_enable="YES"
inetd_flags="-Ww"
sshd_enable="YES"
dumpdev="NO"
dsbmd_enable="YES"
#slim_enable="YES"
moused_enable="YES"
smartd_enable="YES"
cupsd_enable="YES"
webcamd_enable="YES"
vboxnet_enable="YES"
vboxguest_enable="YES"
vboxservice_enable="YES"
devfs_system_ruleset="system"
```


----------



## cmoerz (Nov 1, 2021)

If everything else fails, you could attempt a `freebsd-update IDS` to check for unexpected changes or even reinstall your rc scripts by doing a `make installworld`. If you want to avoid compiling world, you could also just download the txz files and extract them over your existing base files.

Obviously, the latter is the nuclear option and not necessarily the best choice since it won't help you find the root cause for your issue.


----------



## SirDice (Nov 1, 2021)

Father Grigori said:


> ```
> devd_enable="YES"
> ```


One of the few services that are enabled by default. Don't need to set this.


```
inetd_enable="YES"
inetd_flags="-Ww"
```
Who uses inetd(8) in this day and age?


```
dsbmd_enable="YES"
```
I don't recognize that one. What does it do?


```
vboxnet_enable="YES"
vboxguest_enable="YES"
vboxservice_enable="YES"
```
It's a guest _and_ a host?


----------



## Father Grigori (Nov 1, 2021)

covacat said:


> is the kenv msg showing up during boot, before the login prompt is shown ?
> you can hack /etc/rc like this
> add
> set -x at the top before the stty line
> ...



Hello there...

I did exactly as you instructed, but again, there is no line refering to "rc_system" inside the dump of /var/log/console.log


----------



## Emrion (Nov 1, 2021)

> vboxnet_enable="YES"


Do you use VirtualBox?

Anyway, if you use real hardware for FreeBSD (and I think it's the case, reading your posts), these lines have nothing to do in your rc.conf.


> vboxguest_enable="YES"
> vboxservice_enable="YES"


This is used when FreeBSD is running inside a host.


----------



## zirias@ (Nov 1, 2021)

SirDice said:


> Who uses inetd(8) in this day and age?


Here! At least on one machine. It has this nice builtin auth/ident service that can be allowed for IRC services you use  


SirDice said:


> I don't recognize that one. What does it do?


That's just a nice little automounter…


----------



## Father Grigori (Nov 1, 2021)

SirDice said:


> One of the few services that are enabled by default. Don't need to set this.
> 
> 
> ```
> ...



I removed the other unnecessary lines. As for the 
	
	



```
dsbmd_enable="YES
```
 it is a system for automatic mounting of external drives, 
I took from here: Configuration – Automount Removable Media


----------



## covacat (Nov 1, 2021)

i suspect one of the services has support for ghostbsd because the rc_system kenv thing is a ghostbsd setting and that service does some weird shit


----------



## Father Grigori (Nov 1, 2021)

Emrion said:


> Do you use VirtualBox?
> 
> Anyway, if you use real hardware for FreeBSD (and I think it's the case, reading your posts), these lines are nothing to do in your rc.conf.
> 
> This is used when FreeBSD is running inside a host.


Yes I use it occasionally.

Removed the other useless lines. Thank you for helping in the cleanup.


----------



## Father Grigori (Nov 1, 2021)

covacat said:


> i suspect one of the services has support for ghostbsd because the rc_system kenv thing is a ghostbsd setting and that service does some weird shit


Ah... the only thing related to GhostBSD here is this:


```
# pkg info | grep GhostBSD
networkmgr-6.1                 FreeBSD/GhostBSD network connection manager
```

but I have been using this software for quite some time now, without any issue. 
I don´t think it may be related...


----------



## covacat (Nov 1, 2021)

well the problem is network related , ghostbsd related so it must be a duck


----------



## Father Grigori (Nov 1, 2021)

cmoerz said:


> If everything else fails, you could attempt a `freebsd-update IDS` to check for unexpected changes or even reinstall your rc scripts by doing a `make installworld`. If you want to avoid compiling world, you could also just download the txz files and extract them over your existing base files.
> 
> Obviously, the latter is the nuclear option and not necessarily the best choice since it won't help you find the root cause for your issue.


Hello cmoerz.

I performed a `make buildworld` and `make installworld` after the update, just in case, but it didn´t work either.


----------



## Father Grigori (Nov 1, 2021)

covacat said:


> well the problem is network related , ghostbsd related so it must be a duck


Great news!

I deleted the networkmgr-6.1 package, rebooted and voilà... static IP assigned correctly after boot, again.

So, it seems that package and rc_system stuff is really the culprit. 

Maybe a bug report on this should be filled?

Thank you very much covacat, and all the others, you guys are really something!

How not to love FreeBSD?!


----------

