ifconfig_x0="DHCP" and ifconfig_x0_alias0="a.b.c.d"
Nikos Vassiliadis
nvass at gmx.com
Tue Dec 10 09:58:21 UTC 2013
On 06.12.2013 23:34, Teske, Devin wrote:
>
> 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 1.2.3.4/24"
>>
>> 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 1.2.3.4/24"
>
> 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 1.2.3.4/24"
>
> 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).
>
Yes, it works great. Good to know about sysrc, I didn't know about it...
Sorry for the delayed answer, I was offline.
Nikos
More information about the freebsd-questions
mailing list