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.