DnsTube
DnsTube copied to clipboard
DnsTube is not able to get the current IPv6.
2023-11-14 05:00:46 | Cloudflare API error: Content for AAAA record must be a valid IPv6 address. | Error 2023-11-14 05:00:41 | Current public IPv6 address: | Information
DnsTube is not able to get the current IPv6.
Had to delete the .db file and reinstall
@sushantshah-dev I don't use IPv6 so have never been able to actually test it. What API endpoint are you using to get your address and what does it return?
It's the default. When hitting the endpoint manually, I do actually see my IPv6... I am behind a CGNAT, so the IPv4 is shared by a huge number of networks, but IPv6 is provided to individual networks (still shared by the devices). That's why I am forced to use IPv6.
However, deleting the db file fixed it for me.
I ran into this issue as well, i am in the same situation as sushantshah-dev as far as needing ipv6 because of CGNAT. When i first installed the service it worked perfectly. Then after some time of running the service stopped and when i restarted it, it could no longer detect i had an ipv6 address. I had to delete the db file as sushantshah described (thank you) to get it back up and running, however this did mean i needed to re enter all of my credentials.
I am currently using the default https://api64.ipify.org/ as an IPv6 API
I will move over to http://checkip6.spdyn.de and see if the issue re appears
Beware! I ran into this once again... You should probably set up another service or something like that to first backup the db file right after creation, and restore it every 12 hours.
Thanks for the updates. I have not experienced anything like this with IPv4 and unfortunately am unable to test IPv6. The best way to resolve this would be to compare the difference in the db when it's non-functional vs. functional. If you are comfortable with it, please do the following the next time you experience this issue before deleting the db file:
- Go to the Settings page and note the file path for the db (it's at the bottom), e.g.,
C:\ProgramData\DnsTube\DnsTube.db
. - Copy the file to another location, e.g.,
c:\temp
. - Stop the DnsTube service, delete the db located at the path on the settings tab (e.g.,
C:\ProgramData\DnsTube\DnsTube.db
), and restart the service. - Copy the newly generated db to the same temp folder with a different name, e.g.,
DnsTube2.db
. - Go to https://sqliteviewer.app/ in two different browser tabs and load each db from the temp location you copied them to. (This app does not send your db data over the internet, it's all read locally in browser.)
- In each tab:
- Select the
Settings
table on the left. - Hover over row 1 and click the purple arrow on the left. This will open the row data in a model.
- Select the
- Now flip between tabs and look for any differences.
2023-11-15 10:57:00 Unable to update IPv6 DNS. If you are updating all zones, token permissions should be similar to [All zones - Zone:Read, DNS:Edit]. If your token only has permissions for specific zones, click Settings and configure the Zone IDs with a comma-separated list. Content for AAAA record must be a valid IPv6 address. Error
2023-11-15 10:57:00 Error updating [AAAA] record [host.domain.net] in zone [domain.net] to Error
2023-11-15 10:57:00 Cloudflare API error: Content for AAAA record must be a valid IPv6 address. Error
2023-11-15 10:56:58 Current public IPv6 address: Information
2023-11-15 10:56:57 Manual update requested Information
2023-11-15 10:55:57 Public IP address has not changed Information
2023-11-15 10:55:57 A socket operation was attempted to an unreachable network. (checkip6.spdyn.de:80) Error
2023-11-15 10:55:51 Network change detected, updating in 5 seconds Information
2023-11-15 10:54:13 Public IP address has not changed Information
2023-11-15 10:54:13 No such host is known. (checkip6.spdyn.de:80) Error
2023-11-15 10:54:08 Network change detected, updating in 5 seconds Information
2023-11-15 10:52:16 A socket operation was attempted to an unreachable network. (checkip6.spdyn.de:80) Error
2023-11-15 10:52:02 A socket operation was attempted to an unreachable network. (checkip6.spdyn.de:80) Error
Here are the log outputs if it is helpful.
at 2023-11-15 10:56:57 i switched to the default ipv6 api to see if that makes a difference and it gave a different error.
EDIT: I forgot to delete and restart, sorry. Soit doesnt look like the DnsTube.db updates when you update the webui instead i see an updated "date modified" on a file called DnsTube.db-wal . the service works after restarting but the DnsTube.db is empty even after clicking save in the settings page.
I have an idea what is going on here and I expect it is just an intermittent external API issue. I'm going to try to make things more robust and will have a new release for this soon.
I'm guessing this is related? Context: this is a fresh install of 2.4.0 having had this issue on a very old version after a Windows update today.
@jamesxsc I don't think so. I'm guessing you're on an older version of Windows? The fix for this is usually to choose a different endpoint to get your public IP address. It's just a matter of finding one that will work with your version of Windows.
Yeah this is on server 2012... will try and find another endpoint.
@jamesxsc A quick workaround is to not use SSL, e.g., change the API end point to http://api.ipify.org/
.
You should add a options that collect real ipv6 public
address from local machine instead of relying on remote service, since windows generates and uses temporary ipv6 address for such operation. This kind of address changes frequently and may only able to do outgoing traffic on some ISPs.
It seems to be stable if i never change settings after first putting them in. I think one time i just selected a network interface or checked a box next to which hostname to update and it broke the config after some time.
Just wanted to offer another data point.
I've narrowed down the error of being some sort of cache of the httpclient see: https://stackoverflow.com/questions/53408781/system-net-http-httpclient-disable-caching-net-standart-project
it is returning the ipv4 address when I select IPV6 only.
I've did what the post suggested and the problem was solved, i.e. replaced line 34 https://github.com/drittich/DnsTube/blob/DnsTubeService/DnsTube.Core/Services/IpAddressService.cs#L34
with
var httpClient = new HttpClient();
Now everything seems to work fine.
Tryed to solve in a more elegant way, please take a look into it if you will.
Closed by #66. Thanks @fbordignon.
@drittich thanks for the review but unfortunately the issue returned. I believe that it was because I was messing with my router's ipv6 config, the dnstube process lost ipv6 connectivity and defaulted to ipv4. When you access the default api64.ipfy.org without ipv6 connectivity, it returns your ipv4 and it messes with the config and/or the state of the http client. I've found a solution to force ipv6 connectivity on the ipv6 http client but it is not so elegant. I've been testing for 3 weeks now and it has not given me any error. Let me know if you are interested in merging this. On the IpAddressService():
if (protocol == IpSupport.IPv4){
httpClient = _httpClientFactory.CreateClient(HttpClientName.IpAddress.ToString());
}
else
{
httpClient = new HttpClient(new SocketsHttpHandler()
{
ConnectCallback = async (context, cancellationToken) =>
{
// Use DNS to look up the IP addresses of the target host:
// - IP v4: AddressFamily.InterNetwork
// - IP v6: AddressFamily.InterNetworkV6
// - IP v4 or IP v6: AddressFamily.Unspecified
// note: this method throws a SocketException when there is no IP address for the host
var entry = await Dns.GetHostEntryAsync(context.DnsEndPoint.Host, AddressFamily.InterNetworkV6, cancellationToken);
// Open the connection to the target host/port
var socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
// Turn off Nagle's algorithm since it degrades performance in most HttpClient scenarios.
socket.NoDelay = true;
try
{
await socket.ConnectAsync(entry.AddressList, context.DnsEndPoint.Port, cancellationToken);
// If you want to choose a specific IP address to connect to the server
// await socket.ConnectAsync(
// entry.AddressList[Random.Shared.Next(0, entry.AddressList.Length)],
// context.DnsEndPoint.Port, cancellationToken);
// Return the NetworkStream to the caller
return new NetworkStream(socket, ownsSocket: true);
}
catch
{
socket.Dispose();
throw;
}
}
});
}
Sorry, initially pushed a commit with HttpClientName.IpAddress instead of HttpClientName.IpAddressV4. Fixed it, compiled and it should be fine.
I guess the elegant solution would implement IHttpClientFactory with this method for ipv6, but no time or patience for that 😅 sorry.
Another attempted fix released as beta here: https://github.com/drittich/DnsTube/releases/tag/v2.6.0-beta