Topic 714: Basic BSD Network Administration
This topic covers network fundamentals and configuration on BSD systems. You will learn about IPv4 and IPv6 addressing, subnetting, and the roles of TCP, UDP, and ICMP. In addition, you'll see how to configure network interfaces (both statically and via DHCP), troubleshoot network issues, and set up client-side DNS. Detailed explanations and examples are provided below.
714.1: Basic BSD Network Administration
IPv4 Addressing
-
Concepts:
- Network address: The base address of a subnet (e.g., 192.168.1.0 in 192.168.1.0/24).
- Broadcast address: The address used to send data to all hosts on a subnet (e.g., 192.168.1.255 for 192.168.1.0/24).
- Subnetting: Dividing an IP network into smaller segments. With a /24 subnet mask (255.255.255.0), you have 256 addresses, typically 254 usable.
-
Example:
-
For the network 192.168.1.0/24:
- Network address: 192.168.1.0
- Usable host range: 192.168.1.1 to 192.168.1.254
- Broadcast address: 192.168.1.255
-
For the network 192.168.1.0/24:
IPv6 Addressing
-
Concepts:
-
Global address: Routable on the Internet (e.g.,
2001:0db8:85a3::8a2e:0370:7334). -
Link-local address: Used for communication on the local network segment (typically starting with
fe80::). - Subnetting: Most IPv6 networks use a /64 subnet, which is standard.
-
Global address: Routable on the Internet (e.g.,
-
Example:
- Global IPv6:
2001:0db8:85a3::8a2e:0370:7334 - Link-local:
fe80::1
- Global IPv6:
- Note: IPv6 may use SLAAC or DHCPv6 for address assignment.
Network Protocols
-
TCP (Transmission Control Protocol):
Connection-oriented; ensures reliable, ordered delivery of data (e.g., HTTP, FTP).
-
UDP (User Datagram Protocol):
Connectionless; offers faster transmission with less overhead but no guarantee of delivery (e.g., DNS, streaming).
-
ICMP (Internet Control Message Protocol):
Used for sending error messages and operational information (e.g.,
pingfor connectivity testing).
714.2: Basic Network Configuration
Static IP Assignment (FreeBSD Example)
-
Commands:
ifconfig em0 192.168.1.100 netmask 255.255.255.0 route add default 192.168.1.1 -
Explanation:
Sets the network interface
em0with a static IP (192.168.1.100) and a subnet mask of 255.255.255.0. The default gateway is set to 192.168.1.1 to enable external network access.
DHCP Configuration
-
Command:
dhclient em0 -
Explanation:
Requests an IP address from a DHCP server for the interface
em0.
Persistent Configuration (FreeBSD)
-
File:
/etc/rc.confifconfig_em0="inet 192.168.1.100 netmask 255.255.255.0" defaultrouter="192.168.1.1" -
Explanation:
These settings ensure the static IP and default gateway are applied automatically at boot.
OpenBSD Configuration
-
Interface Configuration:
Edit
/etc/hostname.em0with:inet 192.168.1.100 255.255.255.0 -
Default Gateway:
Edit
/etc/mygatewith:192.168.1.1
714.3: Basic Network Troubleshooting
Checking Interfaces and Routing
-
Check interface status:
ifconfigDisplays status and configuration of all network interfaces.
-
View routing table:
netstat -rnShows the routing table in numeric format.
Testing Connectivity
-
Ping a host:
ping 8.8.8.8Sends ICMP echo requests to test connectivity.
-
Traceroute:
traceroute 8.8.8.8Traces the route packets take to reach the destination.
Checking Open Ports and Sockets
-
Nmap scan:
nmap localhostScans for open ports on the local system.
-
Netcat example:
nc -vz localhost 80Checks if port 80 is open.
-
List listening sockets (FreeBSD/NetBSD):
sockstat -4Lists all open IPv4 sockets.
-
IPv6 router solicitation:
rtsol em0Sends an ICMPv6 Router Solicitation on interface
em0to discover routers.
Additional Troubleshooting
-
/etc/services file:
Contains mappings of port numbers to service names.
-
Router Solicitation Daemon (
rtsol):Automatically sends Router Solicitation messages to discover IPv6 routers.
714.4: Configure Client-Side DNS
DNS Resolver Configuration
-
Example
/etc/resolv.conf:nameserver 8.8.8.8 search example.com -
Explanation:
Specifies the DNS server (8.8.8.8) and the default search domain (example.com).
Testing DNS Resolution
-
Using host:
host www.example.comResolves the IP address for
www.example.com. -
Using dig:
dig A www.example.comRetrieves A records for
www.example.com. -
Using nslookup:
nslookup www.example.comAnother tool to query DNS records.
NSSwitch Configuration
-
Example
/etc/nsswitch.conf:hosts: files dns -
Explanation:
Directs the system to first check local files (like
/etc/hosts) then DNS for hostname resolution.
FreeBSD-Specific DNS Tools
-
drill:
A DNS lookup utility on FreeBSD that offers detailed output similar to
dig.