openwisp / netjsonconfig

Network configuration management library based on NetJSON DeviceConfiguration
https://netjsonconfig.openwisp.org/
Other
359 stars 71 forks source link

[bug] Wireguard auto client template method does not take in consideration port #279

Closed nemesifier closed 1 year ago

nemesifier commented 1 year ago

I created a wireguard server on a different port and the template was created using the default port anyway.

pandafy commented 1 year ago

@nemesifier The server port is only used for adding the server as wireguard peer.

package network

config interface 'wg0'
    list addresses '{{ip_address_0533f6120a184df29a1d3cc320fd16cd}}/32'
    option listen_port '51820'
    option mtu '1420'
    option nohostroute '0'
    option private_key '{{pvt_key_0533f6120a184df29a1d3cc320fd16cd}}'
    option proto 'wireguard'

config wireguard_wg0 'wgpeer_wg0'
    list allowed_ips '172.16.0.2/32'
    option endpoint_host 'localhost'
    option endpoint_port '51821' # <-------------- custom server port
    option persistent_keepalive '60'
    option public_key '4BRvvEpi/uP5+dATY6/7sX2TxUZleyT0B0x3JPxRvjE='
    option route_allowed_ips '1'

The wireguard port on device and the server can be different.