Manage Basic Networking
1. IPv4 and IPv6 Address Configuration
a. IPv4 Configuration
IPv4 addresses are 32-bit numerical labels used for communication.
Example:
# Set a static IP address nmcli connection modify conn-name ipv4.addresses "192.168.1.10/24" ipv4.gateway "192.168.1.1" ipv4.dns "8.8.8.8,8.8.4.4" ipv4.method manual # Activate the changes nmcli connection up conn-name
b. IPv6 Configuration
IPv6 addresses are 128-bit numerical labels, which allow for a larger address space.
Example:
# Set a static IPv6 address nmcli connection modify conn-name ipv6.addresses "2001:0db8:85a3:0000:0000:8a2e:0370:7334/64" ipv6.gateway "2001:0db8:85a3::1" ipv6.method manual # Activate the changes nmcli connection up conn-name
2. Configuring Hostname Resolution
Hostname resolution is the process of translating hostnames to IP addresses.
Example:
# Set the system hostname hostnamectl set-hostname myhost.example.com # Manually add an entry in /etc/hosts echo "192.168.1.11 anotherhost.example.com anotherhost" >> /etc/hosts
3. Configure Network Services at Boot
Ensuring that network services start automatically helps in maintaining the required connectivity after a system reboot.
Example:
# Ensure NetworkManager starts at boot systemctl enable NetworkManager
4. Restricting Network Access with firewall-cmd
The firewall-cmd tool manages the firewalld service, which is a dynamic daemon to manage firewall with support for networks zones.
a. Basic Commands
Example:
# List active zones firewall-cmd --get-active-zones # Add a service to the public zone permanently firewall-cmd --zone=public --add-service=http --permanent
b. Advanced Scenarios
Example:
# Block an IP firewall-cmd --add-rich-rule='rule family="ipv4" source address="192.168.1.123" reject' --permanent # Allow a specific port range firewall-cmd --zone=public --add-port=8000-8010/tcp --permanent
Practical Exercise
- Set a static IP address and hostname for your system.
- Configure the firewall to only allow HTTP and SSH traffic.
Summary
Networking is a pivotal aspect of system administration. Managing IPv4/IPv6 configurations, ensuring reliable hostname resolution, setting network services to start automatically, and securing network access with firewalld are all essential skills. Effective network management not only boosts system reliability but also enhances security.
Key Points
- Understanding IP addressing and hostname resolution is fundamental to network configuration.
- Services like NetworkManager should be enabled at boot to ensure consistent networking.
- The
firewall-cmdtool provides a robust interface for managing network access and restrictions.