Network Interface Configuration

From Funtoo
Jump to navigation Jump to search

Introduction

One of the most important devices is the network card. One should figure out which driver must be enabled so that networking works properly. This howto will show you how to retrieve information from the virtual file system known as sysfs. We will use different commands to achieve configuration of the network interface card.

Finding the Network Card

Usually we launch the lspci command to discover network devices. Sometimes, this command will miss things. For example, lspci won't inform about a USB device. We then have to use lsusb and the output is not very user-friendly. So let's look at virtual file system. Data is stored in the sys folder or repository. Because we are searching for network interface cards, we have to scan sys/class/net:

root # ls /sys/class/net
enp32s0  eth1  lo  wlan0

The output shows lo, which is a loopback device. We don't have to deal with this device. Let's go further by getting information about the others:

root # ifconfig -a
enp32s0   Lien encap:Ethernet  HWaddr 00:26:b9:b2:23:ee  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 lg file transmission:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eth1      Lien encap:Ethernet  HWaddr 00:0e:c6:89:72:03  
          inet adr:192.168.1.103  Bcast:192.168.1.255  Masque:255.255.255.0
          adr inet6: fe80::20e:c6ff:fe89:7203/64 Scope:Lien
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9615 errors:0 dropped:1 overruns:0 frame:0
          TX packets:9097 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 lg file transmission:1000 
          RX bytes:7088484 (6.7 MiB)  TX bytes:1710731 (1.6 MiB)

lo        Lien encap:Boucle locale  
          inet adr:127.0.0.1  Masque:255.0.0.0
          adr inet6: ::1/128 Scope:Hôte
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 lg file transmission:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Lien encap:Ethernet  HWaddr 00:16:ea:02:c9:5c  
          inet adr:192.168.1.104  Bcast:192.168.1.255  Masque:255.255.255.0
          adr inet6: fe80::216:eaff:fe02:c95c/64 Scope:Lien
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4032 errors:0 dropped:5 overruns:0 frame:0
          TX packets:19 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 lg file transmission:1000 
          RX bytes:1360474 (1.2 MiB)  TX bytes:2241 (2.1 KiB)

From this list, we can tell that the eth1 device and the wlan0 device are active and working. That can be seen by the following lines:

eth1      Lien encap:Ethernet  HWaddr 00:0e:c6:89:72:03  
          inet adr:192.168.1.103  Bcast:192.168.1.255  Masque:255.255.255.0

wlan0     Lien encap:Ethernet  HWaddr 00:16:ea:02:c9:5c  
          inet adr:192.168.1.104  Bcast:192.168.1.255  Masque:255.255.255.0

Finding the drivers

Now that we have determined that eth1 and wlan0 are the working network devices, we need to compile them into our kernel. Let's find which driver is controlling each device. We will go through different links in the sysfs filesystem.

eth1 driver

root # basename `readlink /sys/class/net/eth1/device/driver/module`
smsc75xx

We now know that we have to enable smsc75xx in order to have our wired network interface card working in our kernel.

wlan0 driver

root #  basename `readlink /sys/class/net/wlan0/device/driver/module`
iwlwifi

We now know that we have to enable iwlwifi in order to have our wireless network interface card working in our kernel.

Configure Kernel

Here we are using thenconfig module of make. We can achieve the same with menuconfig:

root # cd /usr/src/linux
root # make nconfig
make nconfig main menu

Press F8 and type in the name of the module. For example : smsc75xx. This will tell you where the network interface configuration files are located in the kernel:

Symbol: USB_NET_SMSC75XX [=y]                                           
Type  : tristate                                                        
Prompt: SMSC LAN75XX based USB 2.0 gigabit ethernet devices             
  Location:                                                             
    -> Device Drivers                                                   
      -> Network device support (NETDEVICES [=y])                       
        -> USB Network Adapters                                         
          -> Multi-purpose USB Networking Framework (USB_USBNET [=y])   
  Defined at drivers/net/usb/Kconfig:294                                
  Depends on: NETDEVICES [=y] && USB [=y] && NET [=y] && USB_USBNET [=y]
   Selects: BITREVERSE [=y] && CRC16 [=y] && CRC32 [=y]


Follow the path indicated by Location:

Under Device drivers:

[*] Network device support  --->
  USB Network Adapters  --->
    <*> Multi-purpose USB Networking Framework
    <*>   SMSC LAN75XX based USB 2.0 gigabit ethernet devices

Credit

Written by: Guy Fontaine (User:Aramis_qc)