#how does x-real-ip or CF-Connecting-IP work

3 messages · Page 1 of 1 (latest)

tulip flicker
#

I have a woerk set up with this code

var ip_default = {
  async fetch(request) {
    return new Response(request.headers.get("x-real-ip"));
  }
};
export {
  ip_default as default
};
//# sourceMappingURL=index.js.map

i've tried my worker with both x-real-ip and CF-Connecting-IP but both are returning ipv6 addresses.

i am building a dynamic dns solution so my worker was going to be pinged by my raspberrypi every 5 or so minutes and update the dns entry. i can obviously add an AAAA record with this, but I would like to grab the ipv4 address so i can use it for firewall rules. : )

is there a way to get the ipv4 address instead?

#

how does x-real-ip or CF-Connecting-IP work

heavy stratus
#

It all depends on the client. If the client connects via IPv6 then you’ll see the ipv6. You’d have to force the client to connect via ipv4