{"action":"created","issue":{"url":"https://api.github.com/repos/opnsense/plugins/issues/866","repository_url":"https://api.github.com/repos/opnsense/plugins","labels_url":"https://api.github.com/repos/opnsense/plugins/issues/866/labels{/name}","comments_url":"https://api.github.com/repos/opnsense/plugins/issues/866/comments","events_url":"https://api.github.com/repos/opnsense/plugins/issues/866/events","html_url":"https://github.com/opnsense/plugins/issues/866","id":362915398,"node_id":"MDU6SXNzdWUzNjI5MTUzOTg=","number":866,"title":"opnsense-wireguard will not stop or restart properly","user":{"login":"belmarca","id":6055789,"node_id":"MDQ6VXNlcjYwNTU3ODk=","avatar_url":"https://avatars1.githubusercontent.com/u/6055789?v=4","gravatar_id":"","url":"https://api.github.com/users/belmarca","html_url":"https://github.com/belmarca","followers_url":"https://api.github.com/users/belmarca/followers","following_url":"https://api.github.com/users/belmarca/following{/other_user}","gists_url":"https://api.github.com/users/belmarca/gists{/gist_id}","starred_url":"https://api.github.com/users/belmarca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/belmarca/subscriptions","organizations_url":"https://api.github.com/users/belmarca/orgs","repos_url":"https://api.github.com/users/belmarca/repos","events_url":"https://api.github.com/users/belmarca/events{/privacy}","received_events_url":"https://api.github.com/users/belmarca/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-09-23T05:31:54Z","updated_at":"2018-09-23T14:47:31Z","closed_at":null,"author_association":"NONE","body":"**Versions:**\r\n```\r\nopnsense-wireguard plugin patch: 303a17d\r\nOPNsense 18.7.3-amd64\r\nFreeBSD 11.1-RELEASE-p14\r\nLibreSSL 2.6.5\r\n```\r\n\r\n**Example output:**\r\n```\r\nroot@OPNsense:~ # service opnsense-wireguard stop\r\nstopping wireguard\r\nwg-quick: `wg0' is not a WireGuard interface\r\nifconfig: SIOCIFDESTROY: Device not configured\r\n```\r\n\r\n**Problem description:**\r\n\r\nI have set up a server using NAT with two endpoints (which should actually be called \"peers\"). One for my computer and one for my Android phone. The service did not seem to work so I enabled only one of the peers and rebooted the firewall. After rebooting, the service is working properly and I can ping it from my computer. The tunnel is working and the `wg0` interface on the firewall has the following configuration:\r\n\r\n```\r\nroot@OPNsense:~ # ifconfig wg0\r\nwg0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> metric 0 mtu 1420\r\n\toptions=80000<LINKSTATE>\r\n\tinet 192.168.4.1 --> 192.168.4.1  netmask 0xffffff00 \r\n\tinet6 fe80::20d:b9ff:fe4c:50c%wg0 prefixlen 64 scopeid 0x9 \r\n\tnd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>\r\n\tgroups: tun wg \r\n\tOpened by PID 77351\r\n```\r\nThe \"List Configuration\" and \"Handshakes\" tabs work properly and show the correct information.\r\n\r\nUpon clicking the \"Save\" button in any page (with or without making changes), the service stops working. The new configuration for the `wg0` interface is the same with the exception that the `groups` line is now `groups: wg` (`tun` is missing):\r\n\r\n```\r\nroot@OPNsense:~ # ifconfig wg0\r\nwg0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> metric 0 mtu 1420\r\n\toptions=80000<LINKSTATE>\r\n\tinet 192.168.4.1 --> 192.168.4.1  netmask 0xffffff00 \r\n\tinet6 fe80::20d:b9ff:fe4c:50c%wg0 prefixlen 64 scopeid 0x9 \r\n\tnd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>\r\n\tgroups: wg \r\n\tOpened by PID 77351\r\n```\r\n\r\nTo fix this I tried to restart the service through ssh, but the following error occurs:\r\n\r\n```\r\nroot@OPNsense:~ # service opnsense-wireguard stop\r\nstopping wireguard\r\nwg-quick: `wg0' is not a WireGuard interface\r\nifconfig: SIOCIFDESTROY: Device not configured\r\n\r\nroot@OPNsense:~ # clog /var/log/system.log\r\n...\r\nSep 23 01:24:02 OPNsense kernel: ifa_maintain_loopback_route: deletion failed for interface wg0: 3\r\nSep 23 01:24:02 OPNsense kernel: wg0: link state changed to DOWN\r\n```\r\n\r\nwhich I can fix by manually deleting the interface and restarting the service:\r\n\r\n```\r\nroot@OPNsense:~ # ifconfig wg0 inet6 fe80::20d:b9ff:fe4c:50c%wg0 delete\r\nroot@OPNsense:~ # service opnsense-wireguard start\r\nstarting wireguard\r\n[#] wireguard-go wg0\r\nWARNING WARNING WARNING WARNING WARNING WARNING WARNING\r\nW                                                     G\r\nW   This is alpha software. It will very likely not   G\r\nW   do what it is supposed to do, and things may go   G\r\nW   horribly wrong. You have been warned. Proceed     G\r\nW   at your own risk.                                 G\r\nW                                                     G\r\nWARNING WARNING WARNING WARNING WARNING WARNING WARNING\r\nINFO: (wg0) 2018/09/23 01:25:41 Starting wireguard-go version 0.0.20180613\r\n[#] wg setconf wg0 /tmp/tmp.9bQVjyMz/sh-np.PYZzir\r\n[#] ifconfig wg0 inet 192.168.4.1/24 192.168.4.1 alias\r\n[#] ifconfig wg0 mtu 1420\r\n[#] ifconfig wg0 up\r\n[#] route -q -n add -inet 192.168.4.5/32 -interface wg0\r\n[+] Backgrounding route monitor\r\n\r\nroot@OPNsense:~ # clog /var/log/system.log\r\n...\r\nSep 23 01:25:41 OPNsense kernel: tun0: link state changed to UP\r\nSep 23 01:25:41 OPNsense kernel: tun0: changing name to 'wg0'\r\n```\r\n\r\nNow everything is back to normal, except that the saved changes haven't been committed. "},"comment":{"url":"https://api.github.com/repos/opnsense/plugins/issues/comments/423821845","html_url":"https://github.com/opnsense/plugins/issues/866#issuecomment-423821845","issue_url":"https://api.github.com/repos/opnsense/plugins/issues/866","id":423821845,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMzgyMTg0NQ==","user":{"login":"mimugmail","id":20438689,"node_id":"MDQ6VXNlcjIwNDM4Njg5","avatar_url":"https://avatars3.githubusercontent.com/u/20438689?v=4","gravatar_id":"","url":"https://api.github.com/users/mimugmail","html_url":"https://github.com/mimugmail","followers_url":"https://api.github.com/users/mimugmail/followers","following_url":"https://api.github.com/users/mimugmail/following{/other_user}","gists_url":"https://api.github.com/users/mimugmail/gists{/gist_id}","starred_url":"https://api.github.com/users/mimugmail/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mimugmail/subscriptions","organizations_url":"https://api.github.com/users/mimugmail/orgs","repos_url":"https://api.github.com/users/mimugmail/repos","events_url":"https://api.github.com/users/mimugmail/events{/privacy}","received_events_url":"https://api.github.com/users/mimugmail/received_events","type":"User","site_admin":false},"created_at":"2018-09-23T14:47:31Z","updated_at":"2018-09-23T14:47:31Z","author_association":"MEMBER","body":"Can you post your wg.conf please?"}}
{"actor":{"display_login":"mimugmail"}}