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

I have a woerk set up with this code
// index.js
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?
Was this page helpful?