Gentoo + Wireguard

Ronald Farrer
3 min readMar 27, 2023
Photo by Petter Lagson on Unsplash

In recent years, there has been an increasing demand for privacy and security on the internet. One solution that has gained popularity is using a VPN (Virtual Private Network) to encrypt your internet traffic and protect your online privacy. However, setting up a VPN can be a daunting task, especially if you want to use the latest protocols like WireGuard and take advantage of IPv6. In this article, we’ll guide you through setting up WireGuard and using Hurricane Electric’s IPv6 service on a Gentoo system with both OpenRC and systemd.

What is WireGuard?

WireGuard is a modern VPN protocol that was designed to be simple, secure, and fast. Unlike other VPN protocols like OpenVPN and IPSec, WireGuard is easy to set up and uses the latest cryptographic algorithms to provide strong security. WireGuard is also designed to be lightweight and efficient, making it ideal for use on mobile devices and low-power devices like routers.

Setting up WireGuard with OpenRC:

  1. Update the system: Run the following command to update the system:
sudo emerge --sync && sudo emerge -uDN --with-bdeps=y --backtrack=200 @world

2. Install WireGuard: Run the following command to install WireGuard:

sudo emerge net-vpn/wireguard-tools

3. Generate keys: Generate the public and private keys for the server and the clients. Run the following commands to generate the keys:

umask 077
wg genkey | tee privatekey | wg pubkey > publickey

4. Configure WireGuard: Create a configuration file for WireGuard. Run the following command to create a new configuration file:

sudo nano /etc/conf.d/wireguard

5. Start the WireGuard service: Run the following command to start the WireGuard service:

sudo rc-service wireguard start

Setting up WireGuard with systemd:

  1. Update the system: Run the following command to update the system:
sudo emerge --sync && sudo emerge -uDN --with-bdeps=y --backtrack=200 @world

2. Install WireGuard: Run the following command to install WireGuard:

sudo emerge net-vpn/wireguard-tools

3. Generate keys: Generate the public and private keys for the server and the clients. Run the following commands to generate the keys:

umask 077
wg genkey | tee privatekey | wg pubkey > publickey

4. Configure WireGuard: Create a configuration file for WireGuard. Run the following command to create a new configuration file:

sudo nano /etc/wireguard/wg0.conf

5. Start the WireGuard service: Run the following command to start the WireGuard service:

sudo systemctl enable wg-quick@wg0.service
sudo systemctl start wg-quick@wg0.service

Using Hurricane Electric's IPv6 service:

  1. Install the required packages: Run the following command to install the required packages:
sudo emerge net-misc/sipcalc net-analyzer/traceroute6

2. Configure the tunnel: Go to the Hurricane Electric website and log in to your account. Click on "Create Regular Tunnel" and enter your server's IPv4 address and your desired IPv6 prefix. Follow the instructions to configure the tunnel on your server.

3. Configure the network interface:

For OpenRC: Run the following command to configure the network interface:

sudo nano /etc/conf.d/net

For systemd: Run the following command to configure the network interface:

sudo nano /etc/systemd/network/99-he-ipv6.network

Add the following configuration to the file:

[Match] Name=he-ipv6
[Network] Description=Hurricane Electric IPv6 tunnel Address=YOUR_IPV6_ADDRESS/64 Gateway=YOUR_IPV6_GATEWAY DNS=YOUR_DNS_SERVER

Replace YOUR_IPV6_ADDRESS with the IPv6 address you received from Hurricane Electric, YOUR_IPV6_GATEWAY with the IPv6 gateway address you received from Hurricane Electric, and YOUR_DNS_SERVER with the DNS server address of your choice.

4. Configure the routing: Run the following command to configure the routing:

sudo nano /etc/sysctl.conf

Add the following configuration to the file:

net.ipv6.conf.all.forwarding = 1

5. Start the networking service:

For OpenRC:
Run the following command to start the networking service:

sudo rc-service net.eth0 restart

For systemd:
Run the following command to start the networking service:

sudo systemctl restart systemd-networkd.service

Now you should be able to access the internet using IPv6 through your WireGuard VPN connection.

Setting up WireGuard and using Hurricane Electric's IPv6 service on a Gentoo system can seem daunting at first, but it's not too difficult once you know the steps. Whether you use OpenRC or systemd, you can easily set up WireGuard and take advantage of IPv6 to secure your internet traffic and protect your online privacy. By following the steps outlined in this article, you can create a fast, secure, and efficient VPN that will keep you safe online.

I Love Coffee! https://ko-fi.com/canutethegreat

--

--