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

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

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

Configure git to use IPv4 instead of IPv6 by default

The more generic solution (that also works for BSD) is to edit the global /etc/ssh/ssh_config or per-user ~/.ssh/config and add/replace the entry: AddressFamily any with the following line (where inet corresponds to ipv4): AddressFamily inet You can also set this for just a single host: Host example.com AddressFamily inet

Get local network interface addresses using only proc?

/proc/net/fib_trie holds the network topography To simply print the addresses of all adapters: $ awk ‘/32 host/ { print f } {f=$2}’ <<< “$(</proc/net/fib_trie)” 127.0.0.1 192.168.0.5 192.168.1.14 To determine the adapter of those addresses (a) consult the adapters’ destination networks from /proc/net/route, (b) match those networks with the ones of /proc/net/fib_trie and (c) print the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)