ifconfig_x0="DHCP" and ifconfig_x0_alias0="a.b.c.d"

Teske, Devin Devin.Teske at fisglobal.com
Fri Dec 6 22:34:19 UTC 2013

On Dec 6, 2013, at 9:16 AM, Nikos Vassiliadis wrote:

> Hi,
> I am looking for a rc friendly way to set up an IP alias and DHCP
> on an interface. I am after this:
> ifconfig_net0="DHCP"
> ifconfig_net0_alias0="inet"
> I ve tried some combinations found in the manual but nothing worked
> so far...

What release are you on?

If you're on 9.2-R or higher... there are multiple ways...

First way... Use sysrc(8)...

	sysrc ifconfig_net0="DHCP"
	sysrc ifconfig_net0_alias0="inet"

	NOTE: See "man sysrc" for more info

Need more control? Use a shell API library...

	# At the top of your rc...
	. /usr/share/bsdconfig/sysrc.subr

	# Then wherever you want...
	f_sysrc_set ifconfig_net0 DHCP
	f_sysrc_set ifconfig_net0_alias0 "inet"

	NOTE: Works on 9.2-R+
	NOTE: If you're on 11.0-C or higher, there's an API reference...
		see "bsdconfig includes -d sysrc" for sysrc API references

However, you'll need to be aware, that if you intend to change these
values *during* the boot process... the newly modified values may
not take effect for the current boot, as the values are aggressively
cached (for which there is a patch by Sir Percival to address -- see
SVN r258894 for additional information on that).

The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you.

More information about the freebsd-questions mailing list