How to set interface description containing space in 8.x

Jeremy Chadwick freebsd at jdc.parodius.com
Sat Oct 22 12:55:33 UTC 2011


On Sat, Oct 22, 2011 at 02:11:17PM +0200, sthaug at nethelp.no wrote:
> FreeBSD 8.x (well, at least 8.2) has the very nice feature of letting
> you set an interface *description* (just like you can on any Juniper/
> Cisco/whatever router). This decription can contain spaces - so I can
> do for instance:
> 
> xxx# ifconfig bge1 descr "abc def"
> 
> xxx# ifconfig bge1
> bge1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
>         description: abc def
>         options=8009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,LINKSTATE>
>         ether 00:13:72:20:b4:6f
>         media: Ethernet autoselect (1000baseT <full-duplex,flowcontrol,rxpause,txpause>)
>         status: active
> 
> and we see that the decription includes a space. The question is - how
> can I include a description containing one or more spaces in rc.conf?
> 
> The straighforward attempt,
> 
> ifconfig_bge1="up descr abc def"
> 
> doesn't work - "abc" and "def" are given as separate parameters to the
> ifconfig command, resulting in "abc" being used and "def" regarded as
> an extra parameter:
> 
> xxx# /etc/rc.d/netif start bge1
> ifconfig: def: bad value
> 
> I have tried several variants,
> 
> ifconfig_bge1="up descr abc\ def"
> ifconfig_bge1="up descr abc\\ def"
> ifconfig_bge1="up descr 'abc def'"
> ifconfig_bge1="up descr \"abc def\""
> ifconfig_bge1="up descr abc_def"
> 
> but none have the desired result. Can anybody shed a light on this?

I have 100% success using apostrophes, as so:

ifconfig_em1="... descr 'snakes and crumpets'"

The "..." part of the string is just to indicate other stuff can go
there, presumably.  My em1 interface isn't actually in use (no IP
configured, etc.).

Result after running /etc/rc.d/netif start:

em1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        description: snakes and crumpets
        options=219b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,WOL_MAGIC>
        ether 00:30:48:d2:22:d1
        media: Ethernet autoselect
        status: no carrier

This is on RELENG_8 dated 2011/09/28.

If you want me to test it on my em0 interface (which is what actually has
an IP configured, etc.) and do a full reboot, I can do that.  Let me
know.

So there may have been some rc.d framework changes that address your
problem.  Are you running -RELEASE?  If so those fixes probably aren't
available.

In an ideal world, we should really have ifconfig_XXX_descr rc.conf
bits to make for an easier-to-read rc.conf file.

-- 
| Jeremy Chadwick                                jdc at parodius.com |
| Parodius Networking                       http://www.parodius.com/ |
| UNIX Systems Administrator                   Mountain View, CA, US |
| Making life hard for others since 1977.               PGP 4BD6C0CB |



More information about the freebsd-stable mailing list