How do you deal with multiple network interfaces?

When on the command line with multiple interfaces it can be a bit tricky nailing down the info.
ifconfig|more
Is a good solution. I should know all interface names but sometimes I get confused.

ifconfig -l does not give me enough information but ifconfig -a can be overwhelming.

Sure you can hone into a particular interface itself to minimize clutter but you have to know the name first.
ifconfig wlan0

What do you say? Many times I use the universal "ifconfig_DEFAULT=DHCP" setting on multiple interface boxes until I get things ironed out.
I am noticing on some Denverton Atom boxes they have interfaces show up as X553 Backplane that are not addressable. So I use device.hints to hide them.

Am I missing anything? ifconfig|grepping helps sometimes.

What is your ifconfig magic?

Sometimes I use pciconf -lv to see if an interface is copper or fiber.
 
I'm not really sure what you're asking here, but for me, I understand that "ifconfig" gives me information about interfaces that are at least in a specific state.
ifconfig -a gives information regardless of state.

If I've set an interface to DHCP I use ifconfig to verify state and basic information like IP address.
If I've set an interface to static I use ifconfig to verify linkup/linkdown status.
 
I guess my point is if you have to use more it gets really ugly. The lines are so long they spill over and that is not good.

I need a middle ground that shows some info but not too much. Just grepping IP's out of ifconfig can be overwhelming.

ifconfig -s
Show IP's of all interfaces. Something like this. Summary view.
 
I was thinking about the ifconfig -l list mode and add the 'inet' line if it exists for a summary..

We have already covered this topic somewhat:

I also noticed an -f flag:
ifconfig -f addr:cidr
It only changes display output.
 
With the prior solution you don't have interface names. Just a list of interfaces. Not quite a summary.

Code:
@NCA1515:# ifconfig | grep -E 'inet.[0-9]' | grep -v '127.0.0.1' | awk '{ print $2}'
192.168.1.128
192.168.1.129
192.168.1.130
192.168.1.131
 
From covacat suggestion:

This looks nice but I want interface name first.
ifconfig | egrep "inet?"
Code:
    inet 192.168.1.128 netmask 0xffffff00 broadcast 192.168.1.255
    inet 192.168.1.129 netmask 0xffffff00 broadcast 192.168.1.255
    inet 192.168.1.130 netmask 0xffffff00 broadcast 192.168.1.255
    inet 192.168.1.131 netmask 0xffffff00 broadcast 192.168.1.255
 
That looks like a summary. Thanks so much.
Code:
igb2:    inet 192.168.1.128 netmask 0xffffff00 broadcast 192.168.1.255
igb3:    inet 192.168.1.129 netmask 0xffffff00 broadcast 192.168.1.255
ix0:    inet 192.168.1.130 netmask 0xffffff00 broadcast 192.168.1.255
ix1:    inet 192.168.1.131 netmask 0xffffff00 broadcast 192.168.1.255
lo0:    inet 127.0.0.1 netmask 0xff000000
 
In my "homelab", netstat -i

Code:
Name             Mtu Network           Address                               Ipkts Ierrs Idrop      Opkts Oerrs  Coll
genet0          1500 <Link#1>          dc:a6:32:e1:60:de                 208654790     0     0  386120795     0     0
genet0             - 192.168.1.0/24    192.168.1.3                       159835001     -     -  390755280     -     -
genet0             - 192.168.22.3/32   192.168.22.3                          14488     -     -          8     -     -
genet0             - 192.168.1.41/32   192.168.1.41                        1574653     -     -    1462556     -     -
lo0            16384 <Link#2>          lo0                                 5292676     0     0    5292676     0     0
lo0                - localhost         localhost                              2047     -     -       2047     -     -
lo0                - your-net          localhost                           3617210     -     -    3828065     -     -
pflog0         33152 <Link#3>          pflog0                                    0     0     0      58756     0     0
genet0bridge    1500 <Link#4>          58:9c:fc:10:c6:2c                 108309647     0     0  628243185  4219     0
e0a_bastille5   1500 <Link#9>          02:20:9d:e1:60:de                     55923     0     0   15764624     0     0
 
I'm not sure if /sys pseudofilesystems contain the same info as under linux but all the interface info would be under a sysfs filesystem. a lot of the linux system inquiry utilities simple read the speudofiles in those directories. see sysfs(5)

You could then programmatically grab only the information you are seeking.
 
That was a theoretical option flag. Something I would like to see.

I was thinking of adding it to my user .cshrc as an alias but it is too long for my taste.
 
A thing I like to do on a laptop that has both wired ethernet and wireless NICs is to use the link aggregation device in failover mode to configure both into a single lagg interface with auto-failover between the wired ethernet and wireless NICs underneath it. You plug the ethernet cable in, you get cable; you pull the cable out, and lagg automatically switches to wireless. Its pretty nice. Then in things like routing table and firewall rules you just talk about lagg0 and you're done, it's like the machine has a single NIC. Man lagg. From memory I think the handbook tells you how to set it up.
 
In fact there's a howto here. It's very useful, and you don't need to install other software like network manager, its in the driver. It's one of the little hidden gems in freebsd networking :-)

 
Back
Top