[GH-ISSUE #3345] WG/AWG .conf import silently ignores a single DNS server and uses application DNS #3205

Open
opened 2026-10-30 04:57:46 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Noksa on GitHub (Oct 28, 2026).
Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/3345

Describe the bug

Importing a valid WireGuard .conf file with exactly one IPv4 DNS server silently discards that DNS setting. On Android, the resulting VPN network receives the application's DNS values instead of the server specified in the file.

The connection itself succeeds, so this is easy to miss when public names still resolve. It breaks resolution of private names available only through the configured resolver.

Environment

  • AmneziaVPN: 5.0.3.0
  • Client OS: Android 16
  • Protocol tested: ordinary WireGuard, without AmneziaWG obfuscation
  • Profile imported from a .conf file

To Reproduce

  1. Take a working WireGuard configuration and specify a single reachable IPv4 DNS server in [Interface], for example:
    DNS = 10.23.0.53
    
    This is an illustrative private address, not an address from the tested setup.
  2. Leave the application DNS settings at their defaults (1.1.1.1 and 1.0.0.1).
  3. Import the file as a new profile and connect.
  4. Inspect the active VPN network's DnsAddresses in adb shell dumpsys connectivity.

Actual behavior

The configured private resolver is absent. The captured VPN network state contained:

InterfaceName: tun0
DnsAddresses: [ /1.1.1.1,/1.0.0.1 ]

The intended private DNS server was independently tested from the phone: a direct UDP/53 DNS query returned a successful response. This is a DNS configuration/import problem, rather than evidence that the intended resolver is unreachable.

Android Private DNS was in automatic (opportunistic) mode during the captured baseline. The incorrect addresses were already present in the VPN's DnsAddresses; this report concerns which servers the VPN registers with Android, not a DNS leak-test website's result.

Expected behavior

A valid single DNS address in an imported WireGuard configuration should be retained and applied to the VPN network. It should not silently disappear because no second DNS address is provided.

Source-level cause

In tag 5.0.3.0, ImportController::extractWireGuardConfig() uses a DNS regular expression with two mandatory IPv4 capture groups. It only populates the profile's dns1 and dns2 when that entire expression matches:

https://github.com/amnezia-vpn/amnezia-client/blob/5.0.3.0/client/core/controllers/selfhosted/importController.cpp#L645-L652

Consequently:

  • DNS = 10.23.0.53 does not match.
  • DNS = 10.23.0.53, 10.23.0.54 matches.

When profile DNS fields are absent, NativeServerConfig::getDnsPair() falls back to the application settings:

https://github.com/amnezia-vpn/amnezia-client/blob/5.0.3.0/client/core/models/selfhosted/nativeServerConfig.cpp#L38-L49

The application defaults are 1.1.1.1 and 1.0.0.1:

https://github.com/amnezia-vpn/amnezia-client/blob/5.0.3.0/client/core/repositories/secureAppSettingsRepository.cpp#L74-L88

The same import function handles both WireGuard and AmneziaWG profiles. The device-level reproduction above used ordinary WireGuard.

Workaround

Add a second reachable private DNS server to the same line and import the modified file as a new profile:

DNS = 10.23.0.53, 10.23.0.54

After this change, the previously failing name resolution in Chrome started working in the tested setup.

Suggested fix

Parse the DNS field as a list and preserve a valid single entry. Add regression coverage for a single IPv4 DNS address and two comma-separated IPv4 addresses, including verification that the single-entry case does not silently fall back to the application primary DNS.

Related issues

  • #2957 concerns imported profile DNS taking precedence over application settings. This report concerns a valid single DNS entry being lost during import.
  • #3059 reports ignored DNS settings on Android, without identifying this single-entry parsing failure.
Originally created by @Noksa on GitHub (Oct 28, 2026). Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/3345 **Describe the bug** Importing a valid WireGuard `.conf` file with exactly one IPv4 DNS server silently discards that DNS setting. On Android, the resulting VPN network receives the application's DNS values instead of the server specified in the file. The connection itself succeeds, so this is easy to miss when public names still resolve. It breaks resolution of private names available only through the configured resolver. **Environment** - AmneziaVPN: 5.0.3.0 - Client OS: Android 16 - Protocol tested: ordinary WireGuard, without AmneziaWG obfuscation - Profile imported from a `.conf` file **To Reproduce** 1. Take a working WireGuard configuration and specify a single reachable IPv4 DNS server in `[Interface]`, for example: ```ini DNS = 10.23.0.53 ``` This is an illustrative private address, not an address from the tested setup. 2. Leave the application DNS settings at their defaults (`1.1.1.1` and `1.0.0.1`). 3. Import the file as a new profile and connect. 4. Inspect the active VPN network's `DnsAddresses` in `adb shell dumpsys connectivity`. **Actual behavior** The configured private resolver is absent. The captured VPN network state contained: ```text InterfaceName: tun0 DnsAddresses: [ /1.1.1.1,/1.0.0.1 ] ``` The intended private DNS server was independently tested from the phone: a direct UDP/53 DNS query returned a successful response. This is a DNS configuration/import problem, rather than evidence that the intended resolver is unreachable. Android Private DNS was in automatic (`opportunistic`) mode during the captured baseline. The incorrect addresses were already present in the VPN's `DnsAddresses`; this report concerns which servers the VPN registers with Android, not a DNS leak-test website's result. **Expected behavior** A valid single DNS address in an imported WireGuard configuration should be retained and applied to the VPN network. It should not silently disappear because no second DNS address is provided. **Source-level cause** In tag `5.0.3.0`, `ImportController::extractWireGuardConfig()` uses a DNS regular expression with two mandatory IPv4 capture groups. It only populates the profile's `dns1` and `dns2` when that entire expression matches: https://github.com/amnezia-vpn/amnezia-client/blob/5.0.3.0/client/core/controllers/selfhosted/importController.cpp#L645-L652 Consequently: - `DNS = 10.23.0.53` does not match. - `DNS = 10.23.0.53, 10.23.0.54` matches. When profile DNS fields are absent, `NativeServerConfig::getDnsPair()` falls back to the application settings: https://github.com/amnezia-vpn/amnezia-client/blob/5.0.3.0/client/core/models/selfhosted/nativeServerConfig.cpp#L38-L49 The application defaults are `1.1.1.1` and `1.0.0.1`: https://github.com/amnezia-vpn/amnezia-client/blob/5.0.3.0/client/core/repositories/secureAppSettingsRepository.cpp#L74-L88 The same import function handles both WireGuard and AmneziaWG profiles. The device-level reproduction above used ordinary WireGuard. **Workaround** Add a second reachable private DNS server to the same line and import the modified file as a new profile: ```ini DNS = 10.23.0.53, 10.23.0.54 ``` After this change, the previously failing name resolution in Chrome started working in the tested setup. **Suggested fix** Parse the DNS field as a list and preserve a valid single entry. Add regression coverage for a single IPv4 DNS address and two comma-separated IPv4 addresses, including verification that the single-entry case does not silently fall back to the application primary DNS. **Related issues** - #2957 concerns imported profile DNS taking precedence over application settings. This report concerns a valid single DNS entry being lost during import. - #3059 reports ignored DNS settings on Android, without identifying this single-entry parsing failure.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amnezia-client#3205
No description provided.