Select Wireguard server commad line

I wanted to select vpn connection command line from the below wireguard configuration. Default option works commandline without issues. but how can i select peer?

root@GL-SFT1200:~# cat /etc/config/wireguard

config proxy
option access ‘ACCEPT’
option main_server ‘vakkad-piwg1-5clients’
option enable ‘1’
option host ‘59.8.22.24’

config peers ‘wg_peer_461’
option name ‘omv2’
option address ‘10.13.13.3’
option listen_port ‘51820’
option private_key ‘ghfddhg’
option dns ‘10.13.13.1’
option end_point ‘ailwire.ddns.net:51820
option public_key ‘idafd=’
option allowed_ips ‘0.0.0.0/0’
option persistent_keepalive ‘25’
option preshared_key ‘fgsfdgd’

config peers ‘wg_peer_1794’
option name ‘vpnunlimited’
option listen_port ‘51820’
option dns ‘10.100.0.1’
option allowed_ips ‘0.0.0.0/0’
option persistent_keepalive ‘25’
option address ‘10.100.253.116/32’
option private_key ‘2dafdsfadafc=’
option end_point ‘162.218.95.14:15266’
option public_key ‘adfasfdsafdasf’
option preshared_key 'afdasf

hi,
You can select peer by replacing the main_server with the name of peer that you want to select.
for exampple:

   uci set wireguard.@proxy[0].main_server=vpnunlimited''
   uci commit wireguard
   /etc/init.d/wireguard restart
2 Likes

I’m not seeing a /etc/init.d/wireguard on firmware 4.4.6-release1 or 4.3.7-release4. Am I missing a script?

1 Like

/etc/init.d/wireguard has been deleted on version 4.x.You can select peer with following commands.

uci set network.wgclient.config='peer_2002'
uci commit network
/etc/init.d/network restart
2 Likes

hello, in my case the command lines works, however it`s not the result I was expecting, I need to restart the wireguard connection by command (in order to set a cronjob) but it does not work...why I need to do it? cos I set a daily restart to my router, but every new restart the wireguard connection does not work, so I found that from GUI I restart it and it starts to work, do I need to do anything else?