playing with Alpine linux

Published on 9 Apr 2017

I saw mentions of Alpine Linux growing lately, especially within the Docker community. Instead of using Ubuntu as the base OS for Docker containers, Alpine is becoming more and more popular lately. I was thinking to run a test-drive on Alpine and I did.

First, let’s download Alpine. I chose the virtual variant because I planned to use it on VirtualBox. At first I set the connection to use bridged network because I wanted to use ssh and avahi (proper configuration was done later). The installation was straightforward as outlined on the wiki.

setup-alpine

The on-screen instruction should be self-explanatory for most parts. Then, I installed packages that I considered as crucial for a minimal working box.

setup-apkcache
apk add vim curl nano htop dbus avahi htop git sudo ufw ip6tables mc zsh

Note that ufw requires testing repo enabled in /etc/apk/repositories. Enable ufw and add it to the startup, then set it to allow for ssh connection.

ufw enable
rc-update add ufw
sudo ufw allow ssh

I prefer using zsh as my shell interface. For a more interesting zsh session, I installed sorin-ionescu/prezto through git. To clean the package cache, run apk -v cache clean. After that, start avahi and add it to startup.

rc-service avahi-daemon start
rc-update add avahi-daemon

It is a good idea to create a new user instead of using root (use the adduser command). Edit the visudo to allow our new $USER to use the sudo command.

networking

This is the interesting part. At first, the network was set to use the bridged adapter. With regard to security, bridged adapter is less secure than NAT. However, with NAT I cannot get avahi to work. So how do we do this? The solution is to use both NAT and a secondary host-only adapter.

On the VirtualBox preference itself, go to Network and then the Host-only Networks to configure vboxnet0. I set the adapter with the following values:

IPv4 Address: 192.168.56.1
IPv4 Network Mask: 255.255.255.0

The DHCP Server is disabled for this vboxnet0. The instance (Alpine linux) will ask for a static IP for the host-only network. We are done here. Close the VirtualBox preference and let’s configure the network for the Alpine instance. Right-click on the Alpine instance and click Settings…, go to Network and make sure Adapter 1 and Adapter 2 are enabled. Set Adapter 1 to NAT and Adapter 2 to Host-only Adapter via vboxnet0. For the Advanced configuration in Adapter 2, set the Promiscuous Mode to Allow All.

Now, let’s configure the Alpine linux itself to use both adapters. Now, edit the file /etc/network/interfaces. Here is my configuration:

auto lo
iface lo inet loopback

# NAT on Adapter 1
auto eth0
iface eth0 inet dhcp

# Host-only on Adapter 2
auto eth1
iface eth1 inet static
address 192.168.56.10
netmask 255.255.255.0

Reboot is required.