Skip to content

Raspberry Pi VPN client

Nadeem Lughmani edited this page Jul 26, 2021 · 6 revisions

Building Raspberry Pi as WireGuard VPN client

Raspberry Pi was installed with Ubuntu 20.04 LTS Server.

Configure DHCP server

  • Raspberry Pi will act as a DHCP server for local segment
  • install package isc-dhcp-server
#/etc/dhcp/dhcpd.conf
subnet 192.168.10.0 netmask 255.255.255.0 {
  range 192.168.10.101 192.168.10.110;
  option broadcast-address 192.168.10.255;
  option routers 192.168.10.11;
  option domain-name-servers 8.8.8.8;
}

systemctl enable  isc-dhcp-server.service --now

DHCP leases are available in following file.
/var/lib/dhcp/dhcpd.leases

WireGuard Configuration

WireGuard server is installed in the cloud. The server generates the client side configuration. wg-quick script/tool is used to do client side configuration

root@ubuntu:~# cat /etc/wireguard/wg0.conf
[Interface]
PrivateKey = 
Address = 10.66.66.5/32
DNS = 8.8.8.8
PostUp = iptables -t nat -A POSTROUTING -o wg0 -j MASQUERADE
PostDown = iptables -t nat -D POSTROUTING -o wg0 -j MASQUERADE

[Peer]
PublicKey = 
PresharedKey = 
Endpoint = AWS-Public-IP:Port
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 10

wg-quick up wg0

systemctl enable wg-quick@wg0 --now

wg show
Clone this wiki locally