- 1 – Prepare Hardware and Flash Alpine Linux
- 2 – System Update and Required Package Installation
- 3 – Enable Tunnels and IP Forwarding
- 4 – Configure Static IP (Required for SMB Access)
- 5 – Run the PiVPN Installer
- 6 – Configure WireGuard Service to Start on Boot
- 7 – Create a VPN Client Profile
- 8 – Configure Router Port Forwarding
- 9 – Test Your VPN Connection
- 10 – Disable DLNA on the Router
- 11 – Accessing the Router’s SMB Share
#1 – Prepare Hardware and Flash Alpine Linux
- Gather a Raspberry Pi 3B+, a microSD card (≥8 GB), and a reliable power supply (5 V, 2.5 A).
- Download the official Alpine Linux image for Raspberry Pi from the Alpine Linux website (select the
armv7
version, e.g.,alpine-rpi-3.22.1-armv7.tar.gz
). - Flash the image onto the microSD card. On a Linux host, use
dd
:umount /dev/sdX*
dd if=alpine-rpi-3.22.1-armv7.tar.gz of=/dev/sdX bs=4M status=progress && sync
(Replace/dev/sdX
with your actual device name.) - Insert the card into the Pi 3B+ and power it on.
- Log in as
root
and run the initial setup script:setup-alpine
Follow the prompts. For disk mode, select “sys” to install Alpine directly to the SD card.
#2 – System Update and Required Package Installation
- Update Alpine’s package repositories and upgrade existing packages:
apk update && apk upgrade
- Install the necessary packages for PiVPN and WireGuard operation:
apk add bash curl git nano iptables wireguard-tools wireguard-tools-wg-quick
- Install
haveged
to ensure sufficient entropy for cryptographic key generation:apk add haveged
- Start and enable the
haveged
service to run on boot:rc-service haveged start
rc-update add haveged default
#3 – Enable Tunnels and IP Forwarding
- Ensure the
tun
module is loaded on boot:echo "tun" > /etc/modules-load.d/tun.conf
modprobe tun
- Enable kernel IP forwarding to allow VPN traffic to be routed to your LAN. To make this setting persistent across reboots, execute the following:
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
sysctl -p
#4 – Configure Static IP (Required for SMB Access)
- Assign a static IP address to the Raspberry Pi 3B+. This is mandatory for port forwarding and reliable DNS resolution. Edit the network interfaces file:
nano /etc/network/interfaces
- Configure the
eth0
interface with a static IP outside your router’s DHCP range. The Sagemcom router’s default subnet is192.168.1.0/24
.auto eth0 iface eth0 inet static address 192.168.1.2 netmask 255.255.255.0 gateway 192.168.1.1
- Restart the networking service to apply the changes:
service networking restart
#5 – Run the PiVPN Installer
- Switch to the Bash shell:
bash
- Download and execute the PiVPN installation script:
curl -L https://install.pivpn.io | bash
- Follow the interactive prompts with the specific choices required for remote SMB access:
- Acknowledge the static IP requirement.
- Select a local user to manage profiles (e.g.,
root
). - Choose “WireGuard” as your VPN protocol.
- Accept the default UDP port: 51820.
- CRITICAL STEP: When prompted to pick a DNS Provider, select the “Custom” option.
- Enter the IP address of your Sagemcom router as the custom DNS server:
192.168.1.1
. This enables connected VPN clients to resolve local device names. - For public access, select “DNS Entry” and provide your dynamic DNS hostname (e.g.,
your-hostname.duckdns.org
). - Allow PiVPN to manage firewall rules and enable unattended upgrades.
#6 – Configure WireGuard Service to Start on Boot
- Enable the
wg-quick
service for thewg0
interface created by PiVPN:rc-update add wg-quick.wg0 default
- Start the WireGuard service immediately:
rc-service wg-quick.wg0 start
#7 – Create a VPN Client Profile
- Add a client profile using the
pivpn
command (e.g., for a client namedlaptop
):pivpn add -n laptop
- This will generate a
laptop.conf
file in the/root/configs/
directory (or the selected user’s home directory). - Transfer this file securely to your client device (e.g., via SCP or a USB drive).
#8 – Configure Router Port Forwarding
- Log in to your Sagemcom F@st 5670 router’s web interface (typically at
http://192.168.1.1
). - Navigate to the “Access Control” -> “Port Forwarding” section.
- Create a new port forwarding rule with the following parameters:
- Service Name:
WireGuard
- Protocol:
UDP
- External Port:
51820
- Internal IP:
192.168.1.2
(The static IP you assigned to the Raspberry Pi). - Internal Port:
51820
- Service Name:
- Save and apply the rule. Reboot the router if required.
#9 – Test Your VPN Connection
- On your remote client device (e.g., laptop or phone), install the official WireGuard client.
- Import the
laptop.conf
configuration file into the client. - Activate the VPN tunnel.
- Verify connectivity by browsing to an external website. Your public IP address should now be that of your home network.
#10 – Disable DLNA on the Router
- Log in to your Sagemcom F@st 5670 router’s web interface.
- Navigate to the “My Media” section.
- Locate the “DLNA” settings and disable the service.
- Save and apply the changes.
#11 – Accessing the Router’s SMB Share
Once connected to the VPN from a remote location, you can access the SMB share on your Sagemcom router as if you were on your local home network.
- On Windows:
- Open File Explorer.
- In the address bar, type
\\192.168.1.1
and press Enter. - When prompted, enter the SMB username and password configured on your router.
- On macOS:
- Open Finder.
- From the “Go” menu, select “Connect to Server…” (or press
Cmd+K
). - In the “Server Address” field, type
smb://192.168.1.1
and click “Connect”. - Enter your SMB credentials when prompted.
- On Linux (GUI File Manager):
- Open your file manager (e.g., Nautilus, Dolphin).
- In the location or address bar, type
smb://192.168.1.1
and press Enter. - Provide your SMB credentials when prompted.