<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Anianz</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Anianz"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Anianz"/>
	<updated>2026-05-06T13:17:04Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Talk:Configure_a_Wireguard_interface_(wg)&amp;diff=18752</id>
		<title>Talk:Configure a Wireguard interface (wg)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Talk:Configure_a_Wireguard_interface_(wg)&amp;diff=18752"/>
		<updated>2021-04-05T13:11:48Z</updated>

		<summary type="html">&lt;p&gt;Anianz: Created page with &amp;quot;== Bringing up an interface using wg-tools ==  &amp;#039;&amp;#039;Then load the module&amp;#039;&amp;#039;   modprobe wireguard  &amp;#039;&amp;#039;Add it to &amp;lt;code&amp;gt;/etc/modules&amp;lt;/code&amp;gt; to automatically load it on boot.&amp;#039;&amp;#039;  This d...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Bringing up an interface using wg-tools ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Then load the module&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 modprobe wireguard&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Add it to &amp;lt;code&amp;gt;/etc/modules&amp;lt;/code&amp;gt; to automatically load it on boot.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This does not seem to be necessary (any more)?&lt;br /&gt;
&lt;br /&gt;
[[User:Anianz|Anianz]] ([[User talk:Anianz|talk]])&lt;/div&gt;</summary>
		<author><name>Anianz</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Configure_a_Wireguard_interface_(wg)&amp;diff=18751</id>
		<title>Configure a Wireguard interface (wg)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Configure_a_Wireguard_interface_(wg)&amp;diff=18751"/>
		<updated>2021-04-05T12:49:46Z</updated>

		<summary type="html">&lt;p&gt;Anianz: The example for the ifupdown section caused a RTNETLINK answers: File exists an could be simplified since the introduction of ifupdown-ng in alpine 3.13.0 which has a wireguard executor&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;WireGuard is a very promising VPN technology and available since Alpine 3.10 in the community repository.&lt;br /&gt;
&lt;br /&gt;
There are several ways to install and configure an interface.&lt;br /&gt;
&lt;br /&gt;
In order to load the wireguard kernel module, you need a compatible kernel:&lt;br /&gt;
&lt;br /&gt;
* linux-lts&lt;br /&gt;
* linux-virt&lt;br /&gt;
&lt;br /&gt;
== Bringing up an interface using wg-tools ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward method, and the one recommended in WireGuard documentation, is to use &amp;lt;code&amp;gt;wg-quick&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Install wireguard-tools&lt;br /&gt;
&lt;br /&gt;
 apk add wireguard-tools&lt;br /&gt;
&lt;br /&gt;
Then load the module&lt;br /&gt;
&lt;br /&gt;
 modprobe wireguard&lt;br /&gt;
&lt;br /&gt;
Add it to &amp;lt;code&amp;gt;/etc/modules&amp;lt;/code&amp;gt; to automatically load it on boot.&lt;br /&gt;
&lt;br /&gt;
Then we need to create a private and public key&lt;br /&gt;
&lt;br /&gt;
 wg genkey | tee privatekey | wg pubkey &amp;gt; publickey&lt;br /&gt;
&lt;br /&gt;
Then we create a new config file &amp;lt;code&amp;gt;/etc/wireguard/wg0.conf&amp;lt;/code&amp;gt; using those keys&lt;br /&gt;
&lt;br /&gt;
 [Interface]&lt;br /&gt;
 Address = 10.123.0.1/24&lt;br /&gt;
 ListenPort = 45340&lt;br /&gt;
 PrivateKey = SG1nXk2+kAAKnMkL5aX3NSFPaGjf9SQI/wWwFj9l9U4= # the key from the previously generated privatekey file&lt;br /&gt;
 PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;iptables -A FORWARD -o %i -j ACCEPT&lt;br /&gt;
 PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE;iptables -D FORWARD -o %i -j ACCEPT&lt;br /&gt;
&lt;br /&gt;
The PostUp and PostDown steps are there to ensure the interface wg0 will accept and forward traffic to eth0. The postrouting and forward to %i is not required but it will enable &amp;quot;VPN mode&amp;quot; where users can access the internet through this server if desired. Reference this WireGuard documentation for information on adding Peers to the config file.&lt;br /&gt;
&lt;br /&gt;
To bring up the new interface we can just use &lt;br /&gt;
&lt;br /&gt;
 wg-quick up wg0&lt;br /&gt;
&lt;br /&gt;
To bring it down we can use &amp;lt;code&amp;gt;wg-quick down wg0&amp;lt;/code&amp;gt; which will clean up the interface and remove the ip table rules. &lt;br /&gt;
Note that if running in a Docker container, you will need to run with &amp;lt;code&amp;gt;--cap-add=NET_ADMIN&amp;lt;/code&amp;gt; to modify interfaces.&lt;br /&gt;
&lt;br /&gt;
== Bringing up an interface using ifupdown-ng ==&lt;br /&gt;
&lt;br /&gt;
The official documents from wireguard will show examples of how to setup an interface with the use of wg-quick.&lt;br /&gt;
In this howto we are not going to use this utility but are going to use plain wg command and [https://github.com/ifupdown-ng/ifupdown-ng/blob/master/doc/interfaces-wireguard.scd ifupdown-ng].&lt;br /&gt;
&lt;br /&gt;
 apk add wireguard-tools-wg&lt;br /&gt;
&lt;br /&gt;
Now that you have all the tools installed we can setup the interface.&lt;br /&gt;
The setup of your interface config is out of the scope of this document, you should consult the [https://git.zx2c4.com/WireGuard/about/src/tools/man/wg.8 manual page of wg].&lt;br /&gt;
&lt;br /&gt;
After you have finished setting up your wgX interface config you can add it to your /etc/network/interfaces:&lt;br /&gt;
&lt;br /&gt;
 auto wg0&lt;br /&gt;
 iface wg0 inet static&lt;br /&gt;
        requires eth0&lt;br /&gt;
        use wireguard&lt;br /&gt;
        address 192.168.42.1&lt;br /&gt;
&lt;br /&gt;
This config automatically will:&lt;br /&gt;
 &lt;br /&gt;
* bring the wireguard interface up after the eth0 interface&lt;br /&gt;
* assign a config to this interface (which you have previously created)&lt;br /&gt;
* setup the interface address and netmask&lt;br /&gt;
* add the route ones the interface is up&lt;br /&gt;
* remove the interface when it goes down&lt;br /&gt;
&lt;br /&gt;
To start the interface and stop it you can execute:&lt;br /&gt;
&lt;br /&gt;
 ifup wg0&lt;br /&gt;
 ifdown wg0&lt;br /&gt;
&lt;br /&gt;
If your interface config is not stored under &amp;lt;code&amp;gt;/etc/wireguard&amp;lt;/code&amp;gt; you need to specify a &amp;lt;code&amp;gt;wireguard-config-path&amp;lt;/code&amp;gt; as well.&lt;br /&gt;
&lt;br /&gt;
== Running with modloop ==&lt;br /&gt;
If you are running from a RAM disk you can&#039;t modify the modloop.&lt;br /&gt;
&lt;br /&gt;
You can get around it by unpacking the modloop, mount the unpacked modules folder and then installing wireguard.&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 apk add squashfs-tools # install squashfs tools to unpack modloop&lt;br /&gt;
 unsquashfs -d /root/squash /lib/modloop-lts # unpack modloop to root dir&lt;br /&gt;
 umount /.modloop # unmount existing modloop&lt;br /&gt;
 mount /root/squash/ /.modloop/ # mount unpacked modloop&lt;br /&gt;
 apk del wireguard-lts # uninstall previous wireguard install&lt;br /&gt;
 apk add wireguard-lts&lt;br /&gt;
 apk add wireguard-tools&lt;br /&gt;
&lt;br /&gt;
Now you could repack the squash filesystem or put this script in the /etc/local.d/ path so it runs on boot.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;/div&gt;</summary>
		<author><name>Anianz</name></author>
	</entry>
</feed>