Free Linux+ Network Interface Configuration Questions and Answers — Questions and Answers
Question 1: A system administrator needs to assign a temporary IP address 192.168.10.50/24 to the `eth1` interface, which is currently down. Which sequence of commands will accomplish this and make the interface active?
- sudo ip addr add 192.168.10.50/24 dev eth1; sudo ip link set eth1 up (Correct answer)
- sudo ifconfig eth1 192.168.10.50 netmask 255.255.255.0; sudo ifup eth1
- sudo nmcli con add ifname eth1 type ethernet ip4 192.168.10.50/24
- sudo ip route add 192.168.10.50/24 dev eth1; sudo ip link set eth1 on
Correct answer: sudo ip addr add 192.168.10.50/24 dev eth1; sudo ip link set eth1 up
The `ip addr add` command is used to add an IP address to an interface, and `ip link set [device] up` is used to enable or activate the interface. This combination correctly assigns the temporary IP and brings the interface online. The changes made with the `ip` command are not persistent and will be lost after a reboot.
Question 2: On a modern Ubuntu server, a junior administrator needs to configure a static IP address that persists after a reboot. In which directory should they create or edit a YAML configuration file to accomplish this using the default network management tool?
- /etc/sysconfig/network-scripts/
- /etc/network/
- /etc/netplan/ (Correct answer)
- /etc/NetworkManager/system-connections/
Correct answer: /etc/netplan/
Modern Ubuntu systems, starting from version 17.10, use Netplan as the default network configuration tool. Netplan uses YAML files located in the `/etc/netplan/` directory to configure network interfaces. These configurations are then applied to a backend renderer like systemd-networkd or NetworkManager.
Question 3: A network administrator is working on a server managed by NetworkManager and wants to view all available network device statuses and their connections using the command-line. Which of the following commands provides the most comprehensive overview for this purpose?
- ip addr show
- nmcli device status (Correct answer)
- ifconfig -a
- netstat -i
Correct answer: nmcli device status
The `nmcli device status` command is the specific tool for interacting with NetworkManager to display a list of network devices and their current state, type, and associated connection profile. While `ip addr show` and `ifconfig -a` list interfaces, they don't show the connection status from NetworkManager's perspective.
Question 4: An administrator observes that the output of `ip a` shows an interface named `enp3s0` in the `DOWN` state. Which command should be used to activate this interface?
- ifup enp3s0
- nmcli device connect enp3s0
- ip link set enp3s0 up (Correct answer)
- ip addr add dev enp3s0
Correct answer: ip link set enp3s0 up
The `ip link set [device] up` command is the standard way to change the state of a network interface to 'up' or active using the iproute2 utility. This brings the physical layer of the interface online, allowing it to send and receive traffic. The other commands either belong to different toolsets or serve different purposes.
Question 5: When examining the output of the `ip addr show` command, what does the `scope global` attribute signify for an IPv4 address?
- The address is only valid for communication on the local link (subnet).
- The address is valid for communication only within the local host.
- The address is a broadcast address for the local network.
- The address is routable and valid for communication beyond the local network. (Correct answer)
Correct answer: The address is routable and valid for communication beyond the local network.
In the output of the `ip addr` command, `scope global` indicates that the address is globally valid. This means it is routable across networks and can be used for communication with hosts outside of the local subnet. In contrast, `scope link` is for addresses only valid on the local link, and `scope host` is for internal communication (like 127.0.0.1).
Question 6: A system administrator has just made changes to a NetworkManager connection profile file located in `/etc/NetworkManager/system-connections/`. The changes are not taking effect immediately. Which `nmcli` command should be run to apply the new configuration without restarting the entire networking service?
- nmcli connection reload (Correct answer)
- nmcli networking off && nmcli networking on
- nmcli device reapply
- nmcli general reload
Correct answer: nmcli connection reload
`nmcli connection reload` forces NetworkManager to re-read all connection profiles from disk. After reloading, you typically need to bring the specific connection down and then up again (`nmcli con down <name>` followed by `nmcli con up <name>`) for the changes to a specific active connection to apply. `nmcli general reload` is for reloading the NetworkManager daemon configuration, not connection profiles.
A system administrator needs to assign a temporary IP address 192.168.10.50/24 to the `eth1` interface, which is currently down.
Which sequence of commands will accomplish this and make the interface active?