Alpine Linux is a lightweight and efficient operating system ideal for server and container deployments. Network configuration is crucial for these environments.
Step 1: Verify Network Interface
Run the command:
ifconfig -a
This will show all available network interfaces. Common interface names include eth0
, wlan0
, or enp0s3
.
Step 2: Set a Static IP Address
Edit /etc/network/interfaces
:
vi /etc/network/interfaces
Add the following configuration:
auto eth0
iface eth0 inet static
address 192.168.0.105
netmask 255.255.255.0
gateway 192.168.0.1
Replace the values with your network settings.
Step 3: Restart Network
Apply the changes:
/etc/init.d/networking restart
Or alternatively:
rc-service networking restart
Step 4: Verify Network Settings
Check your network configuration:
ifconfig
You should see your static IP address assigned to the interface.
Step 5: Test Network Connection
Test connectivity:
ping 8.8.8.8
Test DNS resolution:
ping google.com
Advanced Configuration Options
DNS Configuration
Edit /etc/resolv.conf
:
nameserver 8.8.8.8
nameserver 8.8.4.4
Network Bonding
For redundancy, you can bond multiple interfaces:
auto bond0
iface bond0 inet static
address 192.168.0.105
netmask 255.255.255.0
gateway 192.168.0.1
bond-slaves eth0 eth1
bond-mode 802.3ad
bond-miimon 100
VLAN Configuration
To configure VLANs:
auto eth0.100
iface eth0.100 inet static
address 192.168.100.10
netmask 255.255.255.0
vlan-raw-device eth0
Firewall Setup
Alpine Linux uses iptables for firewall configuration:
apk add iptables
rc-update add iptables
Troubleshooting
If network doesn’t work:
- Check cable connections
- Verify interface status:
ip link show
- Check routing table:
ip route show
- Review system logs:
dmesg | grep eth0
Conclusion
Proper network configuration ensures smooth and reliable Alpine Linux deployments. Always test your configuration thoroughly before deploying to production.