English | Русский
Single executable file only requiring standard WireGuard config file to work.
-
Firmware with WireGuard support.
E.g. padavan-ng from Alexey, on your router up and running. -
Ability to run commands on your router.
Preferably via SSH, but you could also use router web UI.More info
Enable SSH access in router's web UI: Administration → Services → Enable SSH Server? → Yes
SSH connection credentials are the same that you use for web UI.
Linux, Mac OS and Windows 10+ usually have SSH client preinstalled, just launch terminal and connect:
On older Windows versions you could use PuTTY, Tabby or other SSH clients.
When you have SSH client installed, you can often connect just by following this link:
ssh://[email protected]
Paste it into your browser's address bar manually and hit Enter, since GitHub doees not allow active links with non-standard protocols.
-
Ability to copy files to your router.
SFTP is usually used for this, which is based on SSH.More info
On Windows you could use WinSCP, for Mac OS there is Cyberduck. Linux file managers usually support SFTP out of the box, look for "Network" or "Other places" section.
You can connect just by following this link:
sftp://[email protected]/etc/storage/
Paste it into your browser's address bar manually and hit Enter, since GitHub doees not allow active links with non-standard protocols.
I will mostly use CLI commands here to remove risk of misinterpretation, but file / directory operations might be as well performed via SFTP, or course.
-
If you have previous version of this WireGuard client installed (the one that consisted of several
.sh
files), you need to disable / remove it. Let's rename its directory for now without deleting anything:mv /etc/storage/wireguard /etc/storage/wireguard.bak
-
Create
wireguard
directory in/etc/storage
:mkdir /etc/storage/wireguard
-
Copy
client.sh
to it:wget https://github.com/shvchk/padavan-wireguard-client/raw/main/client.sh -O /etc/storage/wireguard/client.sh
[!WARNING]
I recommend inspecting the client.sh script before running it. It's a good practice before running any code on your device, especially remote code. -
Make it executable:
chmod +x /etc/storage/wireguard/client.sh
-
Copy WireGuard client config file to
/etc/storage/wireguard
Config file name will be used as a WireGuard interface name. E.g. for
wg0.conf
client createwg0
interface.[!IMPORTANT]
File name should only consist of letters, numbers and_
=
+
.
-
characters, be less than 16 characters long and end with.conf
. If directory has multiple config files, first one in alphabetic order will be used. -
Start WireGuard client:
/etc/storage/wireguard/client.sh start
-
Check if internet is working fine on your devices:
ping -c 3 -W 1 1.1.1.1
-
In case of problems, stop WireGuard client:
/etc/storage/wireguard/client.sh stop
-
After you made sure everything is working fine, enable autostart:
/etc/storage/wireguard/client.sh autostart enable
-
Save changes:
mtd_storage.sh save
-
Restart router
/etc/storage/wireguard/client.sh stop
/etc/storage/wireguard/client.sh autostart disable
rm -rf /etc/storage/wireguard
mtd_storage.sh save
You can add exceptions in one of these files:
-
/etc/storage/started_script.sh
(web UI: Customization → Scripts → Run After Router Started) -
/etc/storage/post_iptables_script.sh
(web UI: Customization → Scripts → Run After Firewall Rules Restarted)
First add a tiny helper function:
direct() {
ip rule del $1 $2 || :
ip rule add $1 $2 table main pref 30
}
You can then use it like this: direct <to|from> <IP-address|subnet>
. Examples:
-
Route traffic to IP 9.9.9.9 directly:
direct to 9.9.9.9
-
Route traffic to subnet 1.2.0.0/16 directly:
direct to 1.2.0.0/16
-
Route traffic from IP 192.168.1.11 directly:
direct from 192.168.1.11
-
Route traffic from subnet 10.11.12.0/24 directly:
direct to 10.11.12.0/24
You can add as many of these rules as you like, one per line.
If you changed files via SSH, don't forget to save changes:
mtd_storage.sh save