Manage multiple network connections in Manjaro (Wireguard VPN + Pi-hole)

Published on

Found a way to easily connect and disconnect from a network in Manjaro.

The solution is having separate connections for your Wireguard VPN or Pi-hole instance, alongside your usual network you connect to.

TLDR;

The idea is the following:

  • You have set up a network connection to your Wi-Fi network
  • for Pi-hole, you duplicate the connection and set the only DNS server as your Pi-hole instance
  • for Wireguard, you create a new VPN connection and connect to it when desired

connections

Preparation

Open your “System Settings” from the Manjaro menu, and navigate to your “Connections” under “Network”.

There you’ll find the current network connections you have set up.

Pi-hole

Create a new Wi-Fi connection.

Use the same configuration for your home network (same SSID and password).

Create a new Wi-Fi connection, enter the same SSID and password of your Wi-Fi network.

Under the tab “IPv4” and “IPv6”, select the “Automatic (Only addresses”) Method, and put the IP address of your local Pi-hole.

Preferrably, name the connection with the “Pi-hole” suffix.

configuration-pi-hole

Wireguard

Here is my guide for setting up a Wireguard VPN on Linode or DigitalOcean

To configure Wireguard it’s a bit simpler.

Add a new connection, but choose the “Import VPN connection” option at the bottom of the list.

configuration-wireguard

You’ll be prompted to select the Wireguard configuration file, select it and you’re good to go.

Now simply connect to your Wireguard connection alongside your usual Wi-Fi network.

You can verify your IP change over at ipinfo.io

Note that you can’t connect to your remote Wireguard VPN and local Pi-hole at the same time
:x

Wireguard from the command line

You can also place your configuration file under /etc/wireguard/wg0.conf and manage it with

wg-quick wg0 up|down

Both Pi-hole and Wireguard?

My current set up is the following:

  • I have a Raspberry Pi Zero with Pi-hole configured
  • a remote Wireguard instance hosted on Linode

For this reason I currently can’t connect to both my local Pi-hole and remote Wireguard at the same time.

I think you could get away with hosting both either locally or remotely.

If you chose the local option, you would though lose the ability to connect to a remote server, thus appearing from a different location.


Conclusion

This set up suits my needs very well, as it gives me the ability to choose the connection I prefer quite easily.

Previouly I was always using the command wg-quick to manage my connection with Wireguard, but it was a bit mechanical.

Perhaps in the future I’ll experiment with hosting both Pi-hole and wireguard remotely.

Here, have a slice of pizza 🍕