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
No DNS servers are queried and passed to updown script with dns_handler option enabled #1320
Comments
I guess, for this to work, you have to change the order of the plugins. That is, you want to increase the priority of the updown plugin so it's loaded before the resolve plugin and will process the received DNS servers before the latter. Note that when this feature of the updown plugin was added 10 years ago, it was most likely meant to be used with disabled resolve plugin but in combination with the stroke plugin's feature to request, but not process, DNS servers per config ( |
I compiled it again with just logging enhancements of updown plugin, I gave it priority 2 while the resolve plugin had priority 1. Grep for DNS in logs:
The updown script sees 2 out of 3 DNS servers. |
Interesting. Yeah, I guess the first is assigned directly because it was explicitly requested by the resolve plugin. The stroke plugin avoided that by not implementing the |
I am using swanctl, is there a workaround for this? I just want to get all DNS servers when the updown script is called. Also the
The |
Just to describe my goals, not the solution. Simply speaking - I need to connect two VPN endpoints. I have one fixed VPN connection (always on) and one for roadwarrior. The part of solution is to write custom updown scripts to (1) configure DNS for roadwarrior from the fixed VPN (the fixed VPN updown script), (2) setup routes to fixed VPN when roadwarrior connects (the roadwarrior updown script). |
Perhaps via
What do you do with them?
Hm, no idea why that would be the case (unless it somehow fails to read the original contents from the file to copy it - the plugin opens the old file, unlinks it and creates a new one it its place, then writes the new server and copies all content from the old file).
Might work better. I guess you could also write your own script that handles DNS servers that way (also see the 744-resolvconf branch and #744). |
Configure where/how?
What routes exactly? Why are they not there yet when the "fixed" VPN is established? |
I wanted to update the
I meant update firewall to allow routing from roadwarrior subnet to fixed VPN subnet(s), also masquerade. |
Works better with |
Sounds a bit hackish. Might be easier to use
Check the logs. |
Maybe this is specific to Docker. Just a guess - the file |
Just a note - I am running now the The first three resolv.conf lines are from |
To avoid confusion - I am also running
|
Yes, sounds better. With |
What exactly did you terminate? Only the CHILD_SA? That won't remove the DNS servers. However, when terminating the IKE_SA, you should see
The advantage is that if the DNS servers change for some reason, you just need to reload |
I just use
From time to time there is
Great point, thanks. I will do that. Thanks for hints, I think I have now a sufficiently working setup to continue. When I have time I will have a look at the /etc/resolv.conf read/write issue inside Docker - I will add some logging around the Also please have a look at patch oldium@23a830e, which fixes some compilation issues under alpine:edge Docker image - two implicit declarations fixed by including |
Are you sure you didn't also specify
To terminate the IKE_SA, you have to pass
Thanks, pushed them to the compile-fixes branch. Will merge them to master after the release today. |
Sorry, my bad, I am really using
Thanks :-) |
By the way, didn't you run into the issue that |
No, but I am not compiling everything, so I might have missed that one (I used https://github.com/Stanback/alpine-strongswan-vpn Dockerfile as a starting point, now compiling from Git master):
|
Branch compile-fixes builds fine for me. 👍 |
It's an internal function in
Thanks for testing. |
Regarding the behaviour of the resolve plugin - I added some logging (https://github.com/oldium/strongswan) and discovered that the strongswan | 08[IKE] deleting file /etc/resolv.conf failed: Resource busy |
It looks like this is Docker specific, you cannot delete |
System (please complete the following information):
All modifications present in this bug report are in this repository: https://github.com/oldium/strongswan
Describe the bug
The updown script's
dns_handler
option does not work, the DNS servers are (1) not queried and (2) not passed to script.To Reproduce
Steps to reproduce the behavior (load_modular = yes):
Expected behavior
DNS are queried and passed to updown script.
Analysis
I updated the code and added log to
updown
plugin to indicate that thedns_handler
option was enabled and also to the attribute handler to see whether the DNS was remembered by the plugin. Observations:Without
resolve
plugin there is actually nothing, the DNS servers are not even queried by the request to VPN server:With
resolve
plugin the DNS are queried, but nothing goes to the updown plugin:Ok, there had to be something wrong. I figured out that the IKE code (
ike_config.c
) queries only attributes required by any plugin, so I copied thecreate_attribute_enumerator
code fromresolve
plugin intoupdown
plugin. Now it is better:Without
resolve
plugin, but withupdown
plugin extended bycreate_attribute_enumerator
:With
resolve
plugin andupdown
plugin extended bycreate_attribute_enumerator
:This means that the DNS querying with
updown
plugin does not work:resolve
andupdown
plugins are both enabled, theresolve
plugin takes all DNS queries. Theupdown
plugin does not see any DNS (which is in contrast with documentation, which states that everything should go toupdown
plugin).updown
plugin is updated with DNS attribute registration, bothresolve
andupdown
plugins cannot coexist, because (1) the IKE request contains DNS and DNS6 request twice (which looks like a bug inike_config.c
) and (2) one plugin eats some DNS servers and the other the rest.Moreover, checking
/etc/resolv.conf
discovered that only one DNS server (the last one) is preserved, so also theresolve
plugin does not work correctly.The text was updated successfully, but these errors were encountered: