35. Network Devices And Configuration Flashcards

1
Q

Learning Objectives

By the end of this chapter, you should be able to:

A
  • 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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?

  1. eth0, eth1, eno1, eno2, etc.
  2. wlan0, wlan1, wlan2, wlp3s0, wlp3s2, etc.
  3. br0, br1, br2, etc.
  4. vmnet0, vmnet1, vmnet2, etc.
A
  1. Ethernet devices
  2. wireless devices
  3. bridge interfaces
  4. virtual devices for communicating with virtual clients.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

ip

What wide variety of tasks can the ip command/utility be used for.

A

It can be used to configure, control and query interface parameters and control devices, routing, policy-based routing, and tunneling.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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.

A

ipconfig

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

ip

What is the basic syntx of the ip utility? It has two different forms for different purposes what are they?

A
  • 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Using ip: Examples

How do you show information for all network interfaces?

A

$ ip link show

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Using ip: Examples

How do you show information for the eth0 network interface, including statistics?

A

$ ip -s link show eth0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Using ip: Examples

How do you set the IP address for eth0 to the address 192.168.1.7?

A

$ sudo ip addr add 192.168.1.7 dev eth0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Using ip: Examples

How do you bring interface eth0 down?

A

$ sudo ip link set eth0 down

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Using ip: Examples

How do you set MTU to 1480 bytes for interface eth0?

A

$ sudo ip link set eth0 mtu 1480

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Using ip: Examples

How do you set route from the local 192.168.1.5 address to network 172.16.1.0/24?

A

$ sudo ip route add 172.16.1.0/24 via 192.168.1.5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

ip

What is the OBJECT is used to perform actions on IPv4 or IPv6 protocol device address?

Command syntax:

ip [OPTIONS] OBJECT { COMMAND | help }

A

address

ip address …

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

ip

What is the OBJECT is used to perform actions on network devices?

Command syntax:

ip [OPTIONS] OBJECT { COMMAND | help }

A

link

ip link …

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

ip

What is the OBJECT is used to perform actions on multicast addresses?

Command syntax:

ip [OPTIONS] OBJECT { COMMAND | help }

A

maddress

ip maddress …

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

ip

What is the OBJECT is used to perform actions to watch for netlink messages?

Command syntax:

ip [OPTIONS] OBJECT { COMMAND | help }

A

monitor

ip monitor …

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

ip

What is the OBJECT is used to perform actions to mod

routing table entry?

Command syntax:

ip [OPTIONS] OBJECT { COMMAND | help }

A

route

ip route …

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

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 }

A

rule

ip rule …

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

ip

What is the OBJECT is used to perform actions to tunnel over IP?

Command syntax:

ip [OPTIONS] OBJECT { COMMAND | help }

A

tunnel

ip tunnel …

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

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.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

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?

  1. eno1
  2. ens1
  3. enp2s0
  4. enx7837d1ea46da
  5. eth0
A
  1. Incorporating Firmware or BIOS provided index numbers for on-board devices
  2. Incorporating Firmware or BIOS provided PCI Express hotplug slot index numbers
  3. Incorporating physical and/or geographical location of the hardware connection.
  4. Incorporating the MAC address
  5. 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

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?

A

$ 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

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.

  1. Where are the Red Hat NIC config files?
  2. Where are the Debian NIC config files?
  3. Where are the SUSE NIC config files?
A

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
23
Q

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.

A

/etc

24
Q

Network Manager

What is Network Manager utility good to use to manage a network vs directly modifying the network config files?

A

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.

25
Q

Network Manager Interfaces

What are 3 different Network manager interfaces that accomplish the same task at different difficulty levels? What the are different situation you would want to use the different tools that accomplish the same thing?

A
  1. if you are using your laptop in a hotel room or a coffee shop, you are probably going to use whatever graphical interface your Linux distribution’s desktop offers. You can use this to select between different networks, configure security and passwords, turn devices off and on, etc.
  2. If you are making a configuration change on your system that is likely to last for a while, you are likely to use nmtui as it has almost no learning curve and will edit the underlying configuration files for you.
  3. If you need to run scripts that change the network configuration, you will want to use nmcli. Or, if you are a command line junkie, you may want to use this instead of nmtui.

If the GUI is properly done, you should be able to accomplish any task using any of these three methods. However, we will focus on nmtui and nmcli because they are essentially distribution-independent and hide any differences in underlying configuration files.

26
Q

Network Manager

What is the distro agnostic utility used to manage a network via a command line ui?

A

nmtui

27
Q

Network Manager

What is the distro agnostic utility to manage a network via the command line?

A

nmcli

28
Q

Network Manager

What is the command to see examples of nmcli usages?

A

man nmcli-examples

29
Q

Routing

Network routing is the process of?

A

selecting paths in a network along which to send network traffic.

30
Q

Routing

The routing table is?

A

a list of routes to other networks managed by the system. It defines paths to all networks and hosts, sending remote traffic to routers.

31
Q

Routing

The ___ is a list of routes to other networks managed by the system. It defines paths to all networks and hosts, sending remote traffic to routers.

A

routing table

32
Q

To see the current routing table, you can use these 2 utilities ___ or ___.

What options for the command/utilities would you use to view the current routing table?

A

Utilities:

  • route
  • ip

​Usage:

  • route -n
  • ip route
33
Q

Default Route

The default route is?

A

the way packets are sent when there is no other match in the routing table for reaching the specified network.

34
Q

Default Route

The default route can be setup dynamically via DHCP. But how do you configure it manually (static address setup) with the nmcli utility?

Note: This isn’t the only way to manually configure the default route. You can modify configuration files directly.

A

via nmcli:

$ sudo nmcli con mod virbr0 ipv4.routes 192.168.10.0/24 +ipv4.gateway 192.168.122.0

$ sudo nmcli con up virbr0

via config file mod:

On Red Hat-based systems, you can modify /etc/sysconfig/network putting in the line:

GATEWAY=x.x.x.x

or alternatively in /etc/sysconfig/network-scripts/ifcfg-ethX on a device-specific basis in the configuration file for the individual NIC.

On Debian-based systems, the equivalent is putting:

gateway=x.x.x.x

in /etc/network/interfaces.

On either system, you can set the default gateway at runtime with:

$ sudo route add default gw 192.168.1.10 enp2s0
$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.1.10 0.0.0.0 UG 0 0 0 enp2s0
default 192.168.1.1 0.0.0.0 UG 1024 0 0 enp2s0
172.16.132. 0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 enp2s0
192.168.113.0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet8

Note that this might wipe out your network connection! You can restore either by resetting the network, or in the above example by doing:

$ sudo route add default gw 192.168.1.1 enp2s0

These changes are not persistent and will not survive a system restart.

35
Q

Static Routes

Static routes are used to?

A

control packet flow when there is more than one router or route. They are defined for each interface and can be either persistent or non-persistent.

When the system can access more than one router, or perhaps there are multiple interfaces, it is useful to selectively control which packets go to which router.

Either the route or ip command can be used to set a non-persistent route.

$ sudo ip route add 10.5.0.0/16 via 192.168.1.100

36
Q

Static Routes

What is the command to add a non-persistent route using the ip command? route 192.168.1.100 traffic to 10.5.0.0/16

How do you make it a persisten route?

A

$ sudo ip route add 10.5.0.0/16 via 192.168.1.100

On a Red Hat-based system, a persistent route can be set by editing /etc/sysconfig/network-scripts/route-ethX as shown by:

$ cat /etc/sysconfig/network-scripts/route-eth0
10.5.0.0/16 via 172.17.9.1

On a Debian-based system you need to add lines to /etc/network/interfaces, such as:

iface eth1 inet dhcp
post-up route add -host 10.1.2.51 eth1
post-up route add -host 10.1.2.52 eth1

On a SUSE-based system you need to add to or create a file such as /etc/sysconfig/network/ifroute-eth0 with lines like:

  • *# Destination Gateway Netmask Interface [Type] [Options]
    192. 168.1.150 192.168.1.1 255.255.255.255 eth0
    10. 1.1.150 192.168.233.1.1 eth0
    10. 1.1.0/24 192.168.1.1 - eth0**

where each field is separated by tabs.

37
Q

Name Resolution

Name resolution is?

A

the act of translating hostnames to the IP addresses of their hosts. For example, a browser or email client will take training.linuxfoundation.org and resolve the name to the IP address of the server (or servers) that serve training.linuxfoundation.org in order to transmit to and from that location.

38
Q

Name Resolution

There are two facilities for doing this name resolution translation. What are they?

A
  • Static name resolution (using /etc/hosts).
  • Dynamic name resolution (using DNS servers).
39
Q

Name Resolution

There are 3 command line tools that can be used to resolve the IP address of a hostname. What are they and why are there 3?

A

$ [dig | host | nslookup] linuxfoundation.org

  • dig: generates the most information and has many options
  • host: more compact
  • nslookup: older.

dig is the newest and the others are sometimes considered deprecated, but the output for host is the easiest to read and contains the basic information.

One sometimes also requires reverse resolution: converting an IP address to a host name. Try feeding these three utilities a known IP address instead of a hostname, and examine the output.

40
Q

/etc/hosts

/etc/hosts holds/contains?

A

a local database of hostnames and IP addresses.

41
Q

/etc/hosts

/etc/hosts contains a set of records (each taking one line) which map?

A

IP addresses with corresponding hostnames and aliases.

42
Q

/etc/hosts

A typical /etc/hosts file looks like?

A

$ cat /etc/host
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.100 hans hans7 hans64
192.168.1.150 bethe bethe7 bethe64
192.168.1.2 hp-printer
192.168.1.10 test32 test64 oldpc

Such static name resolution is primarily used for local, small, isolated networks. It is generally checked before DNS is attempted to resolve an address; however, this priority can be controlled by /etc/nsswitch.conf (not often used today).

43
Q

/etc/hosts

/etc/hosts usage for static name resolution is primarily used for?

A

local, small, isolated networks. It is generally checked before DNS is attempted to resolve an address; however, this priority can be controlled by /etc/nsswitch.conf (not often used today).

44
Q

/etc/hosts

student@ubuntu:/etc$ ls -l host*

  • -rw-r–r– 1 root root 92 Oct 22 2015 host.conf
  • rw-r–r– 1 root root 7 Apr 21 08:46 hostname
  • rw-r–r– 1 root root 221 Apr 21 08:46 hosts
  • rw-r–r– 1 root root 411 Apr 20 17:14 hosts.allow
  • rw-r–r– 1 root root 711 Apr 20 17:14 hosts.deny*

Explain these other host-related files and their purposes.

A

The other host-related files in /etc are /etc/hosts.deny and /etc/hosts.allow. These are self-documenting and their purpose is obvious from their names. The allow file is searched first and the deny file is only searched if the query is not found there.

/etc/host.conf contains general configuration information; it is rarely used.

45
Q

DNS

If name resolution cannot be done locally using /etc/hosts, then the system will query a ___ server.

A

DNS (Domain Name Server)

46
Q

DNS

DNS is dynamic and consists of a network of servers which a client uses to look up names. The service is ___; any one DNS server has only information about its ___ of authority; however, all of them together can cooperate to resolve any name

A
  • distributed
  • zone
47
Q

DNS

The machine’s usage of DNS is configured in ___.

A
  • /etc/resolv.conf

which historically has looked like:

search example.com aps.org
nameserver 192.168.1.1
nameserver 8.8.8.8

48
Q

DNS

What does the /etc/resolv.conf contain?

A

The machines DNS configuration.

49
Q

DNS

What does the /etc/resolv.conf contents look like?

A

search example.com aps.org
nameserver 192.168.1.1
nameserver 8.8.8.8

which:

  • Can specify particular domains to search
  • Defines a strict order of nameservers to query
  • May be manually configured or updated from a service such as DHCP (Dynamic Host Configuration Protocol).

Most modern systems will have an /etc/hosts.resolv file generated automatically, such as:

Generated by NetworkManager
192.168.1.1

which was generated by NetworkManager invoking DHCP on the primary network interface.

50
Q

Network Diagnostics

A number of basic network utilities are in every system administrator’s toolbox name them?

A
  • ping
  • traceroute
  • mtr
  • dig

Examples:

  • $ ping -c 10 linuxfoundation.org
  • $ traceroute linuxfoundation.org
  • $ mtr linuxfoundation.org
51
Q

Network Diagnostics

What does the ping network utility do?

A

Sends 64-byte test packets to designated network hosts and (if it finds them) tries to report back on the time required to reach it (in milliseconds), any lost packets, and some other parameters. Note that the exact output will vary according to the host being targeted, but you can at least see that the network is working and the host is reachable.

52
Q

Network Diagnostics

What does the traceroute network utility do?

A

This utility is used to display a network path to a destination. It shows the routers packets flow through to get to a host, as well as the time it takes for each hop.

53
Q

Network Diagnostics

What does the mtr network utility do?

A

It combines the functionality of ping and traceroute, and creates a continuously updated display, like top.

54
Q

Network Diagnostics

What does the dig network utility do?

A

It is useful for testing DNS functionality. Note that one can also use host or nslookup, older programs that also try to return DNS information about a host.