35. Network Devices And Configuration Flashcards
Learning Objectives
By the end of this chapter, you should be able to:
- Identify network devices and understand how the operating system names them and binds them to specific duties.
- Use the ip utility to display and control devices, routing, policy-based routing, and tunnelling.
- Use the older ifconfig to configure, control, and query network interface parameters from either the command line or from system configuration scripts.
- Understand the Predictable Network Interface Device Names scheme.
- Know the main network configuration files in /etc.
- Use Network Manager (nmtui and nmcli) to configure network interfaces in a distribution-independent manner.
- Know how to set default routes and static routes.
- Configure name resolution as well as run diagnostic utilities.
Network Devices
Unlike block and character devices, network devices are not associated with special device files, also known as device nodes. Rather than having associated entries in the /dev directory, they are known by their names.
So know this what type of network device do each of these represent?
- eth0, eth1, eno1, eno2, etc.
- wlan0, wlan1, wlan2, wlp3s0, wlp3s2, etc.
- br0, br1, br2, etc.
- vmnet0, vmnet1, vmnet2, etc.
- Ethernet devices
- wireless devices
- bridge interfaces
- virtual devices for communicating with virtual clients.
ip
What wide variety of tasks can the ip command/utility be used for.
It can be used to configure, control and query interface parameters and control devices, routing, policy-based routing, and tunneling.
ip
The ip utility is preferred to the venerable ___ utility because it is more versatile, as well as more efficient because it uses netlink sockets, rather than ioctl system calls.
ipconfig
ip
What is the basic syntx of the ip utility? It has two different forms for different purposes what are they?
- ip [OPTIONS] OBJECT { COMMAND | help }
- ip [-force] -batch filename
where the second form can read commands from a designated file.
ip is a multiplex utility; the OBJECT argument describes what kind of action is going to be performed. The possible COMMANDS depend on which OBJECT is selected.
You can see below some of the main values of OBJECT.
OBJECT - FUNCTION
address - IPv4 or IPv6 protocol device address
link - Network Devices
maddress - Multicast Address
monitor - Watch for netlink messages
route - Routing table entry
rule - Rule in the routing policy database
tunnel - Tunnel over IP
Using ip: Examples
How do you show information for all network interfaces?
$ ip link show
Using ip: Examples
How do you show information for the eth0 network interface, including statistics?
$ ip -s link show eth0
Using ip: Examples
How do you set the IP address for eth0 to the address 192.168.1.7?
$ sudo ip addr add 192.168.1.7 dev eth0
Using ip: Examples
How do you bring interface eth0 down?
$ sudo ip link set eth0 down
Using ip: Examples
How do you set MTU to 1480 bytes for interface eth0?
$ sudo ip link set eth0 mtu 1480
Using ip: Examples
How do you set route from the local 192.168.1.5 address to network 172.16.1.0/24?
$ sudo ip route add 172.16.1.0/24 via 192.168.1.5
ip
What is the OBJECT is used to perform actions on IPv4 or IPv6 protocol device address?
Command syntax:
ip [OPTIONS] OBJECT { COMMAND | help }
address
ip address …
ip
What is the OBJECT is used to perform actions on network devices?
Command syntax:
ip [OPTIONS] OBJECT { COMMAND | help }
link
ip link …
ip
What is the OBJECT is used to perform actions on multicast addresses?
Command syntax:
ip [OPTIONS] OBJECT { COMMAND | help }
maddress
ip maddress …
ip
What is the OBJECT is used to perform actions to watch for netlink messages?
Command syntax:
ip [OPTIONS] OBJECT { COMMAND | help }
monitor
ip monitor …
ip
What is the OBJECT is used to perform actions to mod
routing table entry?
Command syntax:
ip [OPTIONS] OBJECT { COMMAND | help }
route
ip route …
ip
What is the OBJECT is used to perform actions to mod Rules in the routing policy database?
Command syntax:
ip [OPTIONS] OBJECT { COMMAND | help }
rule
ip rule …
ip
What is the OBJECT is used to perform actions to tunnel over IP?
Command syntax:
ip [OPTIONS] OBJECT { COMMAND | help }
tunnel
ip tunnel …
ifconfig
There was usage info but ifconfig is not installed by default on some distros in favor of ip which is more relevant as of today. This card is just a notice for this. Don’t use ifconfig use ip utility instead.
Predictable Network Interface Device Names
Predictable Network Interface Device Names (PNIDN) is strongly correlated with the use of udev and integration with systemd. There are now 5 types of names that devices can be given:
These 5 types represent a single device but can provide different information of the device such as where it is on the motherboard or geographic location.
based on the 5 types what type device names do these examples represent?
- eno1
- ens1
- enp2s0
- enx7837d1ea46da
- eth0
- Incorporating Firmware or BIOS provided index numbers for on-board devices
- Incorporating Firmware or BIOS provided PCI Express hotplug slot index numbers
- Incorporating physical and/or geographical location of the hardware connection.
- Incorporating the MAC address
- Using the old classic method
__
EX: For a wireless device that previously would have been simply named wlan0:
$ ip link show | grep wl
3: wlp3s0: mtu 1500 qdisc mq state UP mode DORMANT qlen 1000
$ lspci | grep Centrino
03:00.0 Network controller: Intel Corporation Centrino Advanced-N 6205 [Taylor Peak] (rev 34)
It is easy to turn off the new scheme and go back to the classic names. We will leave that as a research project. In what follows, we will mostly follow the classic names for definiteness and simplicy.
Predictable Network Interface Device Names
How do you see info on a machine with two onboard PCI network interfaces that would have been eth0 and eth1 in the old classic naming method?
$ ip link show | grep enp
- 2: enp4s2: mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT qlen 1000
3: enp2s0: mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000*
__
These names are correlated with the physical locations of the hardware on the PCI system:
$ lspci | grep Ethernet
- *02:00.0** Ethernet controller: Marvell Technology Group Ltd. 88E8056 PCI-E Gigabit Ethernet Controller (rev 12)
- *04:02.0** Ethernet controller: Marvell Technology Group Ltd. 88E8001 Gigabit Ethernet Controller (rev 14)
The triplet of numbers at the beginning of each line from the lspci output is the bus, device (or slot), and function of the device; hence it reveals the physical location.
__
__
EX: We see the same pattern. For a wireless device that previously would have been simply named wlan0:
$ ip link show | grep wl
3: wlp3s0: mtu 1500 qdisc mq state UP mode DORMANT qlen 1000
$ lspci | grep Centrino
03:00.0 Network controller: Intel Corporation Centrino Advanced-N 6205 [Taylor Peak] (rev 34)
It is easy to turn off the new scheme and go back to the classic names. We will leave that as a research project. In what follows, we will mostly follow the classic names for definiteness and simplicy.
NIC Configuration Files
When using systemd (systemd is getting more standardized), it is preferable to use Network Manager.
On newer Linux distributions these configuration files are either non-existent, empty, or much smaller.
- Where are the Red Hat NIC config files?
- Where are the Debian NIC config files?
- Where are the SUSE NIC config files?
Red Hat NIC config files:
- /etc/sysconfig/network
- /etc/sysconfig/network-scripts/ifcfg-ethX
- /etc/sysconfig/network-scripts/ifcfg-ethX:Y
- /etc/sysconfig/network-scripts/route-ethX
Debian NIC config files:
- /etc/network/interfaces
SUDE NIC config files:
- /etc/sysconfig/network
Network Manager
As a system was booted, it consulted the network configuration files in the ___ directory subtree in order to establish the interface properties such as static or dynamic (DCHP) address configuration, whether the device should be started at boot, etc.
/etc
Network Manager
What is Network Manager utility good to use to manage a network vs directly modifying the network config files?
Once upon a time, network connections were almost all wired (Ethernet) and did not change unless there was a significant change to the system.
As a system was booted, it consulted the network configuration files in the /etc directory subtree in order to establish the interface properties such as static or dynamic (DCHP) address configuration, whether the device should be started at boot, etc.
If there were multiple network devices, policies had to be established as to what order they would be brought up, which networks they would connect to, what they would be called, etc.
As wireless connections became more common (as well as hotplug network devices such as on USB adapters), configuration became much more complicated, both because of the transient nature of the hardware and that of the specific networks being connected to.
However, modern systems often have dynamic configurations:
- Networks may change as a device is moved from place to place.
- Wireless devices may have a large choice of networks to hook into.
- Devices may change as hardware such as wireless devices, are plugged in or turned on and off.
The previously discussed configuration files were created to deal with more static situations and are very distribution-dependent. A step away from distribution-dependent interfaces and configuration files was a big advance.
While Network Manager still uses configuration files, it is usually best to rely on its various utilities for manipulating and updating them.