Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNS & disconnect #10

Open
hydrafi opened this issue Nov 16, 2021 · 4 comments
Open

DNS & disconnect #10

hydrafi opened this issue Nov 16, 2021 · 4 comments

Comments

@hydrafi
Copy link

hydrafi commented Nov 16, 2021

Hi, thanks for WireGuard Implementation on esp32.
I am trying and it runs well.
I noticed that all traffic goes through the VPN. It would be helpful if at least DNS requests used the local STA connection.
Also a "disconnect" function would be useful.
Thanks

MaxT

@emonindonesia
Copy link

emonindonesia commented Dec 3, 2021

I second that to be actually set "allowed IP addresses". There is allowed_ip in the code, but I don't see a clean way to set that.
Wireguard configs usually have something like
AllowedIPs = 10.0.1.0/24

@ciniml
Copy link
Owner

ciniml commented Dec 6, 2021

According to the lwIP implementation, traffics are routed based on the interface netmask by default.
So I think DNS traffics go through the underlying interface if the DNS server is at the same network of the underlying interface.

Forwarding via a gateway in the non-default interface is not supported by lwIP, since the lwIP does not have any routing table.
The routing of the lwIP is done based on the netmask of the interfaces.

I think a "disconnection" could be implemented by restoring the default interface to the default one and shutdown the Wire Guard interface.

https://github.com/ciniml/WireGuard-ESP32-Arduino/blob/main/src/WireGuard.cpp#L100

To restore the default interface before Wire Guard connection, we must save the default interface before updating it by calling netif_set_default.
It seems to be done by just storing netif_default global variable which lwIP exposes, but I haven't tried it yet.

@ciniml
Copy link
Owner

ciniml commented Dec 8, 2021

I've implemented WireGuard::end() function to shutdown the WireGuard interface.

https://github.com/ciniml/WireGuard-ESP32-Arduino/blob/10-disconnect/src/WireGuard.cpp#L122

There is an example of the end() function.

https://github.com/ciniml/WireGuard-ESP32-Arduino/blob/10-disconnect/examples/disconnect/disconnect.ino

@ciniml
Copy link
Owner

ciniml commented Dec 11, 2021

I've released WireGuard for ESP32 Arduino Library 0.1.5.

This version supports shutting down the WireGuard interface by calling end() function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants