# Get active adapter name (and pass it to conky)



## pacija (Sep 28, 2012)

My problem is not pure networking, but i thought networking section would be more appropriate than ports and packages section.

I need to have one .conkyrc file which would apply to multiple workstations and display their IP address no matter which driver do their NIC use.

It is easy if all of the workstations have the same adapter:

```
${addr bge0}
```

If there are a few it is possible:

```
${if_up bge0} ${addr bge0} ${endif}
${if_up em0} ${addr em0} ${endif}
```

This is not so pretty though, because line which does not match active NIC is not skipped, just presented as blank in conky. This way if I list 10 or so common drivers (alc, bge, bce etc.) I get a lot of wasted space in conky. Also, if there are 2 or more NICs with same driver things get more complicated as I need to list also bge1, em1 etc.

So is there a way (by means of scripting perhaps) to get name of active NIC and pass it into conky configuration file?

Thank you in advance.


----------



## mamalos (Sep 28, 2012)

I think your post is perfect for the ports section of this forum. You are refering to a specific monitoring utility that is ported into FreeBSD, where one of the resources it captures is network related and you wish to clarify some of its functionalities. All the semantics you've used in your post are sysutils/conky related.


----------



## pacija (Sep 28, 2012)

mamalos said:
			
		

> ... You are refering to a specific monitoring utility ...



Well I can not agree with you completely. Although right now I need this for conky, I think the possibility to have common variable for active network adapter can have much wider usage.


----------



## mamalos (Sep 28, 2012)

So, you mean that your question is if someone can make FreeBSD act in a similar way to how most Linux distros work, and name all NICs in a unified way (something like ethx, etc.). If that's your question then I agree with your decision of posting it in this section; but from you original post you seemed like you wanted to know how to use .conkyrc semantics to achieve this.


----------



## kpa (Sep 28, 2012)

You can do this in rc.conf(5):

```
ifconfig_bge0_name="eth0"
ifconfig_eth0="SYNCDHCP"
```

Now your network interface is called eth0 instead of bge0.


----------



## break19 (Sep 28, 2012)

Why not rename the interfaces yourself?

http://forums.freebsd.org/showthread.php?t=2540


----------



## break19 (Sep 28, 2012)

kpa beat me to it


----------



## pacija (Sep 28, 2012)

While it is good to know that FreeBSD has the ability to rename network interfaces (and for gaining this knowledge I thanked kpa), it unfortunately does not solve my problem.

The thing is that I am converting a number of RAIC computers into diskless thin clients which will all boot from the same TFTP/NFS server and will hopefully be configured with the same configuration.

So far everything works great, X without xorg.conf takes care of different VGA cards, devd takes care of different keyboards and mice, and locked down xfce4 leaves user with the only option to click few terminal server shortcuts and shutdown button.

Now, in order to support thin client users, helpdesk technicians need to know IP address of the client, so they can connect over x11vnc. Thin client users are mostly blue collar factory workers who you can't ask for more than to "read the number you see on the screen". I used conky to print IP on desktop before, so I intended to use it for this purpose as well.

Now, as all thin clients use same rc.conf, renaming interface does not seem to solve my problem. Any other ideas?


----------



## kpa (Sep 28, 2012)

You could list all possible combinations of interfaces like this:


```
ifconfig_bge0_name="eth0"
ifconfig_re0_name="eth0"
ifconfig_em0_name="eth0"
...

ifconfig_vr0_name="eth0"
```

This would work as long as there's only one network interface and it's always named<driver>0.


----------



## pacija (Sep 28, 2012)

Ok, I will give it a try, thank you for the tip.


----------



## wblock@ (Sep 28, 2012)

Untested:

```
ifconfig_DEFAULT_name="eth0"
ifconfig_eth0="SYNCDHCP"
```


----------



## jrm@ (Sep 28, 2012)

What does the SYNC in SYNCDHCP do?

P.S. I checked rc.conf() and dhclient(), but didn't see anything.


----------



## wblock@ (Sep 28, 2012)

It's "sync" as in synchronous.  It makes the startup wait for dhclient(8) before continuing with the startup scripts.  Just DHCP runs asynchronously, in the background, while the startup continues.  Sometimes the startup network scripts get started before a background dhclient(8) gets a lease.  So SYNCDHCP takes a little longer, but is safer.  (And no, I don't know why the default changed.)


----------



## pacija (Oct 1, 2012)

wblock@ said:
			
		

> Untested:
> 
> ```
> ifconfig_DEFAULT_name="eth0"
> ...



Does not work in my setup.


----------

