Configuring multiple static IP interfaces in Arch Linux (netcfg)

By , 2011-06-22 14:29

Being a long-time Ubuntu/Debian user, I’m used to editing the good ol’ /etc/network/interfaces file to configure network interfaces.

Recently, trying Arch Linux, I discovered that networking isn’t always that simple.

Most basic system parameters in Arch are configured in the /etc/rc.conf file. However, that file is limited to configuring one static wired ethernet connection.

In order to configure multiple interfaces, you need to install the netcfg package and create profiles for each NIC in /etc/network.d :

There are some examples provided, however none of them mention how to set a custom netmask or multiple DNS servers. So here are my two network profiles:

interface 1 (/etc/network.d/interface1-static)

CONNECTION='ethernet'
DESCRIPTION='Static IP WAN'
INTERFACE='eth0'
IP='static'
ADDR='172.32.24.108'
GATEWAY='172.32.24.1'
DNS=('172.16.24.1' '172.16.24.3')

interface 2

CONNECTION='ethernet'
DESCRIPTION='Static IP LAN'
INTERFACE='eth1'
IP='static'
ADDR='192.168.2.80'
NETMASK='255.255.254.0'

Once the profiles are created, go back to the /etc/rc.conf and make them activated at boot. The values for the NETWORKS array are the two files previously created in /etc/network.d:

# Enable these netcfg profiles at boot-up. These are useful if you happen to
# need more advanced network features than the simple network service
# supports, such as multiple network configurations (ie, laptop users)
#   - set to 'menu' to present a menu during boot-up (dialog package required)
#   - prefix an entry with a ! to disable it
#
# Network profiles are found in /etc/network.d
#
# This requires the netcfg package
#
NETWORKS=(interface1-static interface2-static)

# -----------------------------------------------------------------------
# DAEMONS
# -----------------------------------------------------------------------
#
# Daemons to start at boot-up (in this order)
#   - prefix a daemon with a ! to disable it
#   - prefix a daemon with a @ to start it up in the background
#
# If something other takes care of your hardware clock (ntpd, dual-boot...)
# you should disable 'hwclock' here.
#
DAEMONS=(hwclock syslog-ng net-profiles sshd netfs crond dbus @cups kdm)

Custom theme by me. Based on Panorama by Themocracy