1
23.1 Legacy Series / OpnSense Wireguard API using
« on: March 23, 2023, 09:02:58 am »
Hi
I wanna automate peer creation in Wireguard plugin. For this I use api.
1. I can create new peer with API call "/api/wireguard/client/addClient" with JSON
{"client":
{"enabled": "1",
"name": "WR_Master",
"pubkey": "user_pubkey",
"tunneladdress": "10.0.11.50/32",
"persistentkeepalive": "25"
}
}
It is ok. Peer is created with uuid "xxxx-xxxx-xxxx"
2. Now I need to enable new peer in VPN -> Wireguard -> Local -> Peers (Endpoints)
I try to call API "/api/wireguard/server/set" with JSON
{
"server": {
"enabled": "1",
"peers": {
"xxxx-xxxx-xxxx": {
"selected": "1"
}
},
"uuid": "yyyy-yyyy-yyyy"
}
}
where "yyyy-yyyy-yyyy" is Wireguard server's uuid.
The call ends successfully with message
"Ok. Saved"
Then I make a API call "/api/wireguard/service/reconfigure"
Result - "Ok"
But unfortunally new peer is uncheked in GUI VPN -> Wireguard -> Local -> Peers (Endpoints)
What i doing wrong?
I wanna automate peer creation in Wireguard plugin. For this I use api.
1. I can create new peer with API call "/api/wireguard/client/addClient" with JSON
{"client":
{"enabled": "1",
"name": "WR_Master",
"pubkey": "user_pubkey",
"tunneladdress": "10.0.11.50/32",
"persistentkeepalive": "25"
}
}
It is ok. Peer is created with uuid "xxxx-xxxx-xxxx"
2. Now I need to enable new peer in VPN -> Wireguard -> Local -> Peers (Endpoints)
I try to call API "/api/wireguard/server/set" with JSON
{
"server": {
"enabled": "1",
"peers": {
"xxxx-xxxx-xxxx": {
"selected": "1"
}
},
"uuid": "yyyy-yyyy-yyyy"
}
}
where "yyyy-yyyy-yyyy" is Wireguard server's uuid.
The call ends successfully with message
"Ok. Saved"
Then I make a API call "/api/wireguard/service/reconfigure"
Result - "Ok"
But unfortunally new peer is uncheked in GUI VPN -> Wireguard -> Local -> Peers (Endpoints)
What i doing wrong?