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 [email protected]
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.