Skip to content

Option to set static UDP port for magicsock #5175

@dklesev

Description

@dklesev

When the agent starts the magicsock port seems to be selected randomly which require a wider port range in a firewall configuration (maybe the problem is related to the public ip being present?).

2022-11-27 21:24:34.859 [DEBUG] (tailnet.wgengine)      <./tailnet/conn.go:712> Logger.func1    magicsock: endpoints changed: 123.123.123.123:48483 (local)
2022-11-27 21:24:34.872 [DEBUG] (tailnet)       <./tailnet/conn.go:209> NewConn.func3   wireguard status        {"status": "\u0026{AsOf:2022-11-27 21:24:34.872024622 +0000 UTC m=+1.317492057 Peers:[] LocalAddrs:[{Addr:123.123.123.123:48483 Type:local}] DERPs:1}", "err": null}
2022-11-27 21:24:34.875 [DEBUG] (tailnet)       <./tailnet/conn.go:209> NewConn.func3   wireguard status        {"status": "\u0026{AsOf:2022-11-27 21:24:34.875214234 +0000 UTC m=+1.320681647 Peers:[] LocalAddrs:[{Addr:123.123.123.123:48483 Type:local}] DERPs:1}", "err": null}
2022-11-27 21:24:34.905 [DEBUG] (tailnet.wgengine)      <./tailnet/conn.go:712> Logger.func1    netcheck: [v1] report: udp=true v6=false v6os=true mapvarydest= hair= portmap= v4a=123.123.123.123:48483 derp=999 derpdist=999v4:22ms
2022-11-27 21:24:34.906 [DEBUG] (tailnet.wgengine)      <./tailnet/conn.go:712> Logger.func1    magicsock: endpoints changed: 123.123.123.123:48483 (stun)
2022-11-27 21:24:34.906 [DEBUG] (tailnet)       <./tailnet/conn.go:209> NewConn.func3   wireguard status        {"status": "\u0026{AsOf:2022-11-27 21:24:34.906234275 +0000 UTC m=+1.351701690 Peers:[] LocalAddrs:[{Addr:123.123.123.123:48483 Type:stun}] DERPs:1}", "err": null}

another run

ss -tulpna
Netid     State      Recv-Q     Send-Q                 Local Address:Port               Peer Address:Port      Process                                                   
udp       UNCONN     0          0                            0.0.0.0:54900                   0.0.0.0:*          users:(("coder",pid=869,fd=15))   
...

Would be great to have some kind of config param / env var which can be used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions