Linux+ Network Interface Configuration Questions and Answers — Questions and Answers
Question 1: A system administrator needs to add a secondary IP address, 10.0.1.150/24, to an existing network interface named `ens192` which is managed by NetworkManager. The change must be applied without deactivating the interface. Which of the following commands correctly accomplishes this?
- nmcli con modify ens192 ipv4.addresses 10.0.1.150/24
- nmcli con modify ens192 +ipv4.addresses 10.0.1.150/24 (Correct answer)
- ip addr add 10.0.1.150/24 dev ens192:1
- nmcli con add type ethernet ifname ens192 ip4 10.0.1.150/24
Correct answer: nmcli con modify ens192 +ipv4.addresses 10.0.1.150/24
The `nmcli con modify` command is used to alter an existing NetworkManager connection profile. The key is using the `+` prefix before `ipv4.addresses` to append a new address to the list of existing addresses. Without the `+`, the command would replace all existing IP addresses with the new one.
Question 2: An administrator is configuring a new Ubuntu server that uses Netplan for network configuration. To assign a static IP address, which file would they MOST likely create or edit?
- /etc/sysconfig/network-scripts/ifcfg-eth0
- /etc/network/interfaces
- /etc/netplan/01-netcfg.yaml (Correct answer)
- /etc/systemd/network/10-static.network
Correct answer: /etc/netplan/01-netcfg.yaml
Modern Ubuntu systems use Netplan for network configuration, with YAML files located in `/etc/netplan/`. A file like `/etc/netplan/01-netcfg.yaml` is the standard location for defining network interfaces, including static IP addresses.
Question 3: A network interface `enp0s8` on a Linux server is currently in a 'DOWN' state. Which of the following commands is the modern and direct way to bring the interface to an 'UP' state?
- ifup enp0s8
- ip link set enp0s8 up (Correct answer)
- nmcli device connect enp0s8
- systemctl restart networking
Correct answer: ip link set enp0s8 up
The `ip link set <interface> up` command is the standard and modern utility from the iproute2 suite used to change the state of a network device, specifically to bring it online. While other commands might work in certain contexts, this is the most direct and fundamental command for the task.
Question 4: A server is unable to resolve any external domain names (e.g., www.google.com), but it can ping IP addresses on the internet (e.g., 8.8.8.8). Which file should the administrator check FIRST to troubleshoot this name resolution issue?
- /etc/hosts
- /etc/nsswitch.conf
- /etc/hostname
- /etc/resolv.conf (Correct answer)
Correct answer: /etc/resolv.conf
The `/etc/resolv.conf` file contains the IP addresses of the DNS nameservers the system uses to resolve domain names. If this file is empty, misconfigured, or points to non-functional nameservers, the system will be unable to resolve domain names, matching the symptoms described.
Question 5: A Linux server needs a persistent static route added. All traffic destined for the `172.16.50.0/24` network must be sent through the gateway at `10.1.1.254`. On a RHEL/CentOS system using traditional network scripts, what is the proper way to add this route permanently?
- Add `GATEWAY=10.1.1.254` to `/etc/sysconfig/network`
- Create a file `/etc/sysconfig/network-scripts/route-eth0` with the content `172.16.50.0/24 via 10.1.1.254` (Correct answer)
- Run the command `ip route add 172.16.50.0/24 via 10.1.1.254` and then run `service network save`
- Add the line `route add -net 172.16.50.0/24 gw 10.1.1.254` to `/etc/rc.local`
Correct answer: Create a file `/etc/sysconfig/network-scripts/route-eth0` with the content `172.16.50.0/24 via 10.1.1.254`
On RHEL-family systems using traditional network scripts, persistent static routes are defined in a `route-<interface>` file located in `/etc/sysconfig/network-scripts/`. The format `ADDRESS/PREFIX via GATEWAY` within this file ensures the route is applied when the interface is brought up.
Question 6: A system administrator is examining a legacy Linux system and needs to quickly display the IP address, MAC address, and traffic statistics for all network interfaces, including those that are down. Which command, though now deprecated, is traditionally used for this purpose?
- netstat -i
- ip addr show
- ifconfig -a (Correct answer)
- route -n
Correct answer: ifconfig -a
The `ifconfig` command was the standard tool for network interface configuration on older Linux systems. Using the `-a` flag ensures that it displays information for all interfaces, including those that are currently inactive or 'down'. While `ip addr show` is the modern replacement, `ifconfig` is the correct answer for a legacy context.
A system administrator needs to add a secondary IP address, 10.0.1.150/24, to an existing network interface named `ens192` which is managed by NetworkManager.
The change must be applied without deactivating the interface.
Which of the following commands correctly accomplishes this?