Linux Networking 2 — Questions and Answers
Question 1: Which command displays the routing table on a Linux system?
- netstat -r (Correct answer)
- ifconfig -r
- arp -n
- ip link show
Correct answer: netstat -r
The `netstat -r` command (or `ip route show`) displays the kernel IP routing table.
Question 2: What does the `ss` command replace in modern Linux distributions?
- netstat (Correct answer)
- ifconfig
- route
- arp
Correct answer: netstat
`ss` (socket statistics) is the modern replacement for `netstat` and provides faster, more detailed socket information.
Question 3: Which file on a Linux system maps hostnames to IP addresses locally before DNS is queried?
- /etc/hosts (Correct answer)
- /etc/resolv.conf
- /etc/hostname
- /etc/networks
Correct answer: /etc/hosts
The `/etc/hosts` file provides static hostname-to-IP mappings that are checked before DNS resolution.
Question 4: What is the purpose of the `/etc/resolv.conf` file?
- Specifies DNS server addresses for name resolution (Correct answer)
- Lists static IP-to-hostname mappings
- Defines network interface configurations
- Stores ARP cache entries
Correct answer: Specifies DNS server addresses for name resolution
`/etc/resolv.conf` configures the DNS resolver by specifying nameserver addresses and search domains.
Question 5: Which port does SSH use by default?
- 22 (Correct answer)
- 23
- 443
- 80
Correct answer: 22
SSH (Secure Shell) listens on TCP port 22 by default for encrypted remote connections.
Question 6: What does the `traceroute` command do?
- Shows the path packets take to reach a destination (Correct answer)
- Tests DNS resolution speed
- Displays open TCP connections
- Scans for open ports on a host
Correct answer: Shows the path packets take to reach a destination
`traceroute` sends packets with incrementing TTL values to reveal each hop between source and destination.
Question 7: Which `ip` command subcommand would you use to add a new IP address to an interface?
- ip addr add (Correct answer)
- ip link set
- ip route add
- ip neigh add
Correct answer: ip addr add
`ip addr add <address>/<prefix> dev <interface>` adds an IP address to a specified network interface.
Which command displays the routing table on a Linux system?