Tutorial

How To Upgrade Arch from Netcfg to Netctl on a DigitalOcean VPS

Published on August 2, 2013
author

Trevor Bergeron

How To Upgrade Arch from Netcfg to Netctl on a DigitalOcean VPS

Introduction

On April 10, 2013, it was announced that netctl would replace netcfg. The netcfg package is now considered legacy and unsupported, and all future developments will be on the netctl package. This tutorial will guide you through transitioning your droplet (VPS) to the new package.

Preparing

First, make a snapshot of your current, working droplet through the control panel. This will require first powering the VPS off from SSH or VNC.Once the snapshot is finished, connect to your VPS using the VNC function in the control panel. Sign in as root or sign in as your user and open a root shell with:

su -

Alternatively, if you have sudo configured, use:

sudo -i

You should then have a prompt that looks similar to:

[root@www] #

Updating

First, remove netcfg:

pacman -R netcfg

Update the package databases and install netctl:

pacman -Sy netctl

Use your editor of choice to open /etc/netctl/eth0:

nano /etc/netctl/eth0

Paste or enter the following, replacing YOUR.IP with your droplet's assigned static address (IMPORTANT: Note the /24 on the end!) and YOUR.GATEWAY with your droplet's assigned gateway address. These addresses can be found in the control panel:

Interface=eth0
Connection=ethernet
IP=static
Address=('YOUR.IP/24')
Gateway='YOUR.GATEWAY'
DNS=('8.8.4.4')

Information about netctl profiles can be found here. The above fields are as follows:

  • Interface: The name of the network interface this profile is associated with.
  • Connection: The connection type of this profile, eg. ethernet, wireless, bridge, tunnel
  • IP: The method of assigning an IPv4 address to the interface.
  • Address: The IPv4 address(es) and subnet to assign to the interface.
  • Gateway: A default gateway to use when this profile is active and IP=static.
  • DNS: A set of DNS servers to use when this profile is active.

Additional DNS servers can be specified in the format:

DNS=('8.8.4.4' '8.8.8.8')

Enable the profile at startup:

netctl enable eth0

Reboot the VPS:

systemctl reboot

Cleanup

After your VPS has rebooted, try to SSH it to:

ssh you@YOUR.IP

If this succeeds, ensure your VPS can resolve addresses:

dig +short google.com

If an IP address is returned, everything should be working, and you can remove the old netcfg files:

rm -r /etc/network.d/

Recovering

If something went wrong, first try repairing it from VNC in the control panel.

If you cannot fix the problem from VNC, you can set up the network temporarily. First, "up" (turn on) the interface:

ip link set dev eth0 up

Then, assign your IP address to the interface:

ip addr add YOUR.IP/24 dev eth0

Set the route to the internet:

ip route add default via YOUR.GATEWAY

Finally, set a DNS server for resolving addresses:

echo "nameserver 8.8.4.4" >/etc/resolv.conf

Your droplet should now be back on the internet.

If you need to reinstall netcfg, you will need to compile it from the Arch User Repository, where it now lives. First, make a temporary directory and change it to:

mkdir /tmp/netcfg
cd /tmp/netcfg

Then, download the PKGBUILD file, which tells makepkg where to find the source and how to create the package:

curl https://aur.archlinux.org/packages/ne/netcfg/PKGBUILD -o PKGBUILD

Finally, use makepkg to install dependencies (-s), download the sources, build the package, and install it (-i):

makepkg -si

The netcfg configuration files were left in place when it was uninstalled, so simply rebooting should restore the system to a working state.

Submitted by: Trevor Bergeron

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors
Default avatar
Trevor Bergeron

author

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
8 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Thanks joerg,

I had to do a quick google search on writing systemd services, found a few examples and now my network works great!!!

This is the examples I used: https://wiki.archlinux.org/index.php/Systemd/Services

Make sure you check your interface name with ip link as the old (eth0) interface convention is not followed by netctl. This took me about an hour of frustration to deal with. Also check that your subnet mask is ACTUALLY /24. Mine was a different number.

Overall not a very good tutorial, but it helped me stagger across the finish line of getting my droplet up and running. Now if only the DO staff would update their image once in a while…

Step 1: remove network (netcfg) Step 2: download stuff (netctl)

Uhm…

Building netcfg from AUR is not necessary unless you’ve cleared your package cache directory. You should be able to find the netcfg package file in /var/cache/pacman/pkg/ and then you can install it with pacman -U

@Joerg : i find your solution very elegant. I am messing for many days now with a bridge br0 for a linux container. Do you think I can write such a file for a container. If yes, how ?

Thank you for helo

Actually netctl is an unnecessary abstraction for such simple task. I use as systemd service to set a static ip:

$ cat network.service[Unit] Description=Wireless Static IP Connectivity Wants=network.target Before=network.target BindsTo=sys-subsystem-net-devices-eth0.device After=sys-subsystem-net-devices-eth0.device

[Service] Type=oneshot RemainAfterExit=yes ExecStart=/sbin/ip link set dev eth0 up ExecStart=/sbin/ip addr add 82.196.5.246/24 dev eth0 ExecStart=/sbin/ip route add default via 82.196.5.1

ExecStop=/sbin/ip addr flush dev eth0 ExecStop=/sbin/ip link set dev eth0 down

[Install] WantedBy=multi-user.target

Kamal Nasser
DigitalOcean Employee
DigitalOcean Employee badge
January 30, 2014

@Thomas: You can create a bash script to update and add it to rc.local so that it is executed on boot and then deletes itself and its entry from the rc.local file.

After i successfully upgraded to netctl and i make a snapshot afterwards, so i can use it as an image for all my future droplets, the IP gets not automatically set. I have to update it via the VNC console manually. Is there a way i can update the network file generation for myself? Or do we have to wait for a new arch image?

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.