Adverts

Generally the network sub-system is an area where things just work out of the box. Occasionly though it is necessary to go digging around to either find or change settings. This article gives you a few points on ways to find out about your connections to the outside world.

Using ifconfig

The fist port of call when determining information about your network connections is "ifconfig" this handly little utility will often provide you with enough information to make a diagnosis of any problems. Typical output from this application is shown below (figures have been changed to protect the innocent):

server:/etc/bind# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:00:00:00:00:00
          inet addr:123.123.123.123  Bcast:123.123.123.255  Mask:255.255.255.0
          inet6 addr: ffff::fff:fff:ffff:ffff/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:12022254 errors:1 dropped:0 overruns:0 frame:0
          TX packets:13243461 errors:52 dropped:0 overruns:2 carrier:50
          collisions:0 txqueuelen:1000
          RX bytes:3535929725 (3.2 GiB)  TX bytes:2638495088 (2.4 GiB)
          Interrupt:12 Base address:0xe800
eth0:1    Link encap:Ethernet  HWaddr 00:00:00:00:00:00
          inet addr:123.123.123.124  Bcast:123.123.123.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:12 Base address:0xe800
eth1      Link encap:Ethernet  HWaddr 00:00:00:00:00:00
          inet addr:192.168.0.1  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::240:5ff:fea2:ddd8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:19857412 errors:1 dropped:0 overruns:0 frame:0
          TX packets:17819066 errors:5 dropped:0 overruns:2 carrier:3
          collisions:0 txqueuelen:1000
          RX bytes:3182170112 (2.9 GiB)  TX bytes:1959492910 (1.8 GiB)
          Interrupt:10 Base address:0xec00
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:1344195 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1344195 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:354475286 (338.0 MiB)  TX bytes:354475286 (338.0 MiB)

Here we can see the there are two physical ethernet interface and one virtual interface as well as the local loopback. The physical interfaces have hardware addresses (called MAC addresses) and an assigned interrupt. The virtual interface (eth0:1) allows a single card to bind more than one IP address. This is useful if you want to run multiple servers from the same machine but also have them on separate IP addresses (although you should probably use virtual hosts considering the shortage of IPv4 addresses). 

Using dmesg and grep

Another way to find out about an interface is to use dmesg combined with grep to find out how a given interface was started. For example:

server:/etc/bacula# dmesg | grep eth1
TLAN: eth1 irq= 9, io=3800, Compaq Netelligent Integrated 10/100 TX UTP, Rev. 16
TLAN: eth1: Starting autonegotiation.
TLAN: eth1: Autonegotiation complete.
TLAN: eth1: Link active with AutoNegotiation enabled, at 100Mbps Full-Duplex
eth1: no IPv6 routers present

This gives us more intformation about the card that is running the eth1 interface. We can see what type of card it is as well as what speed it is currently running at (100Mbps Full Duplex) and that it auto-negotiated that speed with the switch. This technique is useful if nothing else works but if the machine has been up a long time this information may no longer be held by dmesg. This is especially true if you are collecting firewall logs.

Using mii-tool 

The mii-tool utility is used to manipulate that way an ethernet interface advertises its capabilities but it is also useful for getting information about the card. Some old hubs and other devices struggle (or even fail) to correctly negotiate a speed - mii-tool can then be used to force the correct speed on the card or tell it to only advertise some speeds. Running mii-tool as an information gathering tool shows the following:

sprocket:/etc/bacula# mii-tool -v eth1
eth1: negotiated 100baseTx-FD, link ok
  product info: National DP83840A rev 1
  basic mode:   autonegotiation enabled
  basic status: autonegotiation complete, link ok
  capabilities: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
  advertising:  100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
  link partner: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control

Using ethtool

The ethtool program is the best tool for manipulating ethernet cards but doesn't come bundled with a default install of Debian. It is used for querying an interface card and can manipulate its settings. Typical output when used as an information gathering tool is shown below:

server:/etc/bacula# ethtool eth0
Settings for eth0:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
        Advertised auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 24
        Transceiver: internal
        Auto-negotiation: on
        Current message level: 0x00000001 (1)
        Link detected: yes

Generally ethtool is pretty good at detecting and configuring network cards but I have discovered a couple that ethtool simply refuses to have anything to do with. This is generally because the drivers for the card don't support ethtool. 

Adverts

Donate and Help

Please support this site and
Bandwidth doesn't grow on trees y' know :o)

Adverts

Get Adsense