Jak nastavit AdGuard VPN pro Linux na routeru OpenWRT
AdGuard VPN pro Linux, známý také jako AdGuard VPN CLI, vyžaduje po instalaci potřebných balíčků alespoň 22 MB volného místa v integrované paměti routeru nebo na externím USB.
1. Ujistěte, že je na routeru povoleno SSH
Toto nastavení se obvykle nachází ve webovém rozhraní routeru.
Pro OpenWRT:
-
Přihlaste se do webového rozhraní. Obvykle je přístupné prostřednictvím webového prohlížeče na adrese
http://192.168.1.1. -
Přejděte na Systém → Administrace.
-
Ujistěte se, že je povolen přístup SSH.
Ve výchozím nastavení OpenWrt umožňuje SSH přístup k routeru.
2. Zjistěte IP adresu vašeho routeru
Výchozí IP adresa pro většinu routerů je 192.168.1.1 nebo 192.168.0.1. Pokud jste IP adresu změnili nebo si nejste jisti, můžete ji zjistit kontrolou konfigurace IP v připojeném zařízení.
Ve Windows
-
Otevřete příkazový řádek:
ipconfig -
Pod aktivním síťovým připojením vyhledejte položku Výchozí brána. Jedná se o IP adresu vašeho routeru.
V macOS a Linux
-
Otevřete Terminal a spusťte tento příkaz pro Linux:
ip route | grep defaultNebo tento pro macOS:
route -n get default -
Vyhledejte položku výchozí. IP adresa vedle ní je IP adresa vašeho routeru.
3. Připojte se k routeru pomocí klienta SSH
Většina systémů Linux a macOS je dodávána s předinstalovaným klientem SSH. V systému Windows můžete použít prostředí PowerShell, integrovaného klienta SSH v systému Windows 10/11 nebo aplikaci třetí strany, například PuTTY.
Vestavěný klient SSH (Linux, macOS a Windows 10/11)
-
Otevřete Terminal nebo PowerShell.
-
Spusťte příkaz SSH:
ssh root@192.168.1.1Nahraďte
192.168.1.1IP adresou vašeho routeru. -
Pokud se k routeru připojujete přes SSH poprvé, zobrazí se tato zpráva:
The authenticity of host '192.168.1.1 (192.168.1.1)' can't be established.ECDSA key fingerprint is SHA256: ...Are you sure you want to continue connecting? (Yes/No/[Fingerprint])Zadejte
yesa stiskněte Enter. -
Na výzvu zadejte heslo routeru. Výchozí heslo pro OpenWrt je obvykle prázdné (stačí stisknout Enter), ale heslo byste měli nastavit během počátečního nastavení.
PuTTY (Windows)
-
Stáhněte a nainstalujte PuTTY z oficiální stránky.
-
Otevřete PuTTY.
-
Do pole Název hostitele (nebo IP adresa) zadejte IP adresu vašeho routeru (např.
192.168.1.1). -
Ujistěte se, že Typ připojení je nastaven na SSH.
-
Klikněte na Otevřít.
-
Po otevření okna Terminalu se přihlaste. The default username is
rootand the default password is typically empty (just press Enter), but you should have set a password during the initial setup.
4. Základní příkazy SSH
Po přihlášení můžete pomocí různých příkazů komunikovat s operačním systémem routeru založeným na Linuxu.
OpenWrt 25.12 and later use the apk package manager, while OpenWrt 24.10 and earlier use opkg. To check your OpenWrt version, run cat /etc/openwrt_release.
OpenWrt 25.12 and later
Update package lists:
apk update
Install required packages:
apk add curl kmod-tun ca-certificates
OpenWrt 24.10 and earlier
Update package lists:
opkg update
Install required packages:
opkg install curl kmod-tun ca-certificates
Run the AdGuard VPN CLI installation script:
curl -fsSL https://raw.githubusercontent.com/AdguardTeam/AdGuardVPNCLI/master/scripts/release/install.sh | sh -s -- -v
5. Set up AdGuard VPN CLI
-
Log in to your account
To use AdGuard VPN for Linux, you need an AdGuard account.
You can sign up or log in on our website or in the Terminal.
To sign up or log in, type:
adguardvpn-cli loginNote: If failed to link the binary to
/usr/local/bin, use full file path to run all commands. For example,/opt/adguardvpn_cli/adguardvpn-cli login -
Connect to VPN
Select a VPN server location that best suits your needs.
In general, the closer the server is to you, the faster the connection.
To view available locations, type:
adguardvpn-cli list-locationsTo connect to a specific location, type:
adguardvpn-cli connect -l LOCATION_NAMEReplace LOCATION_NAME with the city, country, or ISO code of the location you want to connect to.
For quick connect, type:
adguardvpn-cli connectAdGuard VPN will choose the fastest location available and remember it for future quick connections.
-
Adjust your settings
Get a list of all available AdGuard VPN commands and customize the VPN client to your needs.
To view all commands, type:
adguardvpn-cli --help-allAdGuard VPN CLI will create a tun0 interface for VPN tunneling.
6. Set up firewall rules
You can do it in the web interface or in the command line. Steps below describe setup via SSH command line.
-
Add a new unmanaged interface via SSH
ssh root@router_ipuci set network.tun0='interface'uci set network.tun0.proto='none'uci set network.tun0.device='tun0'uci commit network/etc/init.d/network reload -
Add tun0 to WAN zone
For traffic to go through VPN, add tun0 to WAN zone. The WAN interface which connects to the Internet will typically be in a zone named
wanor something similar. Check your router’s configuration files or firewall settings to find out which zone is associated with the WAN interface.To do so, list the existing firewall zones:
uci show firewallThis will show a config file with all zones listed. Look for a section like
firewall.@zone[1]or similar whereoption name 'wan'is defined. The number[1]could be different depending on your configuration.Run this SSH command, replace
zone[1]with correctwanzone identified before:uci show firewall | grep "=zone"uci add_list firewall.@zone[1].network='tun0'uci commit firewall/etc/init.d/firewall reloadIf you want to disable all traffic that is not protected by VPN, run the following command. This way you won’t have an Internet connection at all if VPN disconnects. If you choose not to do this step, your real IP will be exposed if the VPN disconnects.
uci del_list firewall.@zone[1].network='wan'uci del_list firewall.@zone[1].network='wan6'uci commit firewall/etc/init.d/firewall reloadIf you’ve changed your mind and want to allow direct traffic, run the following command:
uci add_list firewall.@zone[1].network='wan'uci add_list firewall.@zone[1].network='wan6'uci commit firewall/etc/init.d/firewall reload
7. Set up automatic launch for AdGuard VPN CLI
To automatically launch AdGuard VPN CLI after rebooting the router, create a file at …/etc/init.d/adguardvpn.
Paste this into the file:
#!/bin/sh /etc/rc.common
# Example script
# Copyright (C) 2007 OpenWrt.org
START=99
STOP=99
HOME=/root
start() {
/opt/adguardvpn_cli/adguardvpn-cli connect
}
stop() {
/opt/adguardvpn_cli/adguardvpn-cli disconnect
}
Run this to grant access to and enable auto-launch:
chmod +x /etc/init.d/adguardvpn
/etc/init.d/adguardvpn enable