Use of network_interfaces in rc.conf

Brooks Davis brooks at freebsd.org
Fri Mar 16 15:39:59 UTC 2012


On Thu, Mar 15, 2012 at 08:49:55PM -0400, Eric W. Bates wrote:
> On 3/15/2012 7:27 PM, Kevin Oberman wrote:
> > 2012/3/14 Eugene Grosbein<egrosbein at rdtc.ru>:
> >> 15.03.2012 06:33, hiren panchasara ?????:
> >>
> >>>      network_interfaces is basically historic rudiment
> >>>      used in 2.2.x FreeBSD version and alike.
> >>>
> >>>      In general, you should not use it in modern version at all.
> >>>
> >>>
> >>> Thanks Eugene.
> >>>
> >>> So, the only way to specify boottime configuration (that survives reboots) for an interface in rc.conf is:
> >>> ifconfig_em0="dhcp" ?
> >>
> >> Yes, thats what man rc.conf says.
> >
> > Minor correction, but the man page says 'ifconfig_em0="DHCP". It may
> > not be case sensitive, but I have always uded CAPS like the man page
> > specifies. Also, I usually end up specifying SYNCDHCP to avoid having
> > something else that requires network starting before the interface is
> > configured.
> >
> > Of course, ifconfig_* may have any valid ifconfig argument in it, but
> > remember the rc.conf is shell, so you must put all of the definition
> > in a single statement. You can't do:
> > ifconfig_em0="DHCP"
> > ifconfig_em0="mediaopt half-duplex"
> > That will not do DHCP, so hte interface will not come up. Of course,
> > you can concatinate a second entry to the first using normal sh
> > syntax.
> 
> FreeBSD rc has a clever way around this. In /etc/network.subr 
> ifscript_up(), if the file /etc/start_if.em0 is readable, it will be dot 
> executed. So you can put as much multi-line config info in there as you 
> would like. e.g.:
> 
> ifconfig em0 mediaopt half-duplex
> dhclient em0
> 
> As long as network_interfaces includes em0 (and it will be automatically 
> included by default), then start_if.em0 will be run. Conversely, 
> stop_if.em0 will also run when rc runs at shutdown.

On many cases you can simply use:

ifconfig_em0="DHCP mediaopt half-duplex"

While DHCP is not an actual ifconfig option we strip it from the list
(along with several other psuedo-arguments) and pass the remainder to
ifconfig.  Not all option will work this way, but I believe mediaopt
does.

-- Brooks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-net/attachments/20120316/51dbd2bd/attachment.pgp


More information about the freebsd-net mailing list