ipv6
IIS Request.UserHostAddress returning IPV6 (::1), even when IPV6 disabled
The 4 Guys from Rolla website has a solution here, which I’ve used in my app. Update: Just in case this link goes dead, here is code based on this link: public string GetIpAddress() { string ipAddressString = HttpContext.Current.Request.UserHostAddress; if (ipAddressString == null) return null; IPAddress ipAddress; IPAddress.TryParse(ipAddressString, out ipAddress); // If we got an … Read more
Adding support for IPv6 in IPv4 client/server apps – sin6_flowinfo and sin6_scope_id fields?
The best way to go is to use getaddrinfo(). Pseudo code: struct addrinfo *restrict hints = { .ai_family = AF_UNSPEC, .ai_socktype = SOCK_STREAM }; struct addrinfo * res, r; if (0 == getaddrinfo(“foo.bar.baz”, “http”, &hints, &res)) { for (r=res; r; r=r->ai_next) { sock = socket(r->ai_family, r->ai_socktype, r->ai_protocol); connect(sock, r->ai_addr, r->ai_addrlen); if error: continue break } … Read more
Why is INET6_ADDRSTRLEN defined as 46 in C?
Why is INET6_ADDRSTRLEN defined as 46 in C? Because POSIX defines it to be 46: INET6_ADDRSTRLEN 46. Length of the string form for IPv6. While you are right that longtest IPv6 address takes 39 bytes, with IPv4 tunneling, the longest form can be 45 bytes: ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255 And the 46th byte is for the terminating nul … Read more
How to store IPv6-compatible address in a relational database
I’m not sure which is the right answer for MySQL given that it doesn’t yet support IPv6 address formats natively (although whilst “WL#798: MySQL IPv6 support” suggests that it was going to be in MySQL v6.0, current documentation doesn’t back that up). However of those you’ve proposed I’d suggest going for 2 * BIGINT, but … Read more
IPv6: Is `::’ equivalent to `0.0.0.0′ when listening for connections?
I believe that listening on a port on 0.0.0.0 is equivalent to listening on a port on any network adapter, at least my memory of the Windows socket API says that this is so. That is correct. 0.0.0.0 is defined as INADDR_ANY and can be used to listen on all local IPv4 adapters. It also … Read more
How can I verify that a string is a valid IPv4 or IPv6 address in batch?
Check for valid IPv4: @if (@X)==(@Y) @end /* JScript comment @echo off cscript //E:JScript //nologo “%~f0” %* exit /b %errorlevel% @if (@X)==(@Y) @end JScript comment */ WScript.Quit(ValidateIPaddress(WScript.Arguments.Item(0))); function ValidateIPaddress(ipaddress) { return !(/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ipaddress)) } For valid IPv6 address: @if (@X)==(@Y) @end /* JScript comment @echo off cscript //E:JScript //nologo “%~f0” %* exit /b %errorlevel% @if (@X)==(@Y) … Read more
When is the hybrid IP notation ::ffff:192.168.1.4 appropriate?
It’s IPv4 expressed through IPv6 so that the application only needs to support one IP stack. Being able to reference IPv4 addresses through IPv6 notation means I can work on getting IPv6 support really solid in my application, and not have to worry about duplicating effort. These days some distributions disable IPv4 compatibility by default … Read more
Force requests to use IPv4 / IPv6
I’ve found a minimalistic solution to force urrlib3 to use either ipv4 or ipv6. This method is used by urrlib3 for creating new connection both for Http and Https. You can specify in it any AF_FAMILY you want to use. import socket import requests.packages.urllib3.util.connection as urllib3_cn def allowed_gai_family(): “”” https://github.com/shazow/urllib3/blob/master/urllib3/util/connection.py “”” family = socket.AF_INET if … Read more
Python 3: Does http.server support ipv6?
Starting with Python 3.8, python -m http.server supports IPv6 (see documentation and bug report with implementation history). To listen on all all available interfaces: python -m http.server –bind :: Python 3.8 is was released on 2019-10-14.