Some networks return a ipv4 and others return a ipv6 address

on some networks the below code gives IPV4 and on some it returns the IPV6.We are getting these details from the header.

string _ipList = page.Request.Headers[“CF-CONNECTING-IP”].ToString();
if (!string.IsNullOrWhiteSpace(_ipList))
ClientIP = _ipList.Split(‘,’)[0].Trim();

we consistently need an IP4 address if possible to verify end users. Is there a way to override the IPV6 and return the IPV4 everytime?

  1. You should do this on a webserver level, not in your code.
  2. You get IPv6 addresses because these requests were made by IPv6 clients, hence there is no IPv4 address
  3. Considering there is no IPv4 address, you cannot get one either.
  4. You can however enable that - Understanding and configuring Cloudflare's IPv6 support · Cloudflare Support docs
1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.