TL;DR curl -L v4v6.ml will give you your IPv4 and IPv6 address with a single cURL command.
There are a couple services that give you your IP address with one cURL. The problem with all of those is that they either give you your IPv4 or IPv6. And getting both at the same time seems impossible at first, because you either connect over v4 or v6, but there is a simple trick I use to avoid this.
I have two domains, v4v6.ml, I'll call it A, and v4.v4v6.ml, and call it B. Domain A has an A and AAAA record to my server, and domain B only an A record.
The code looks roughly like this:
app.get('/', (req, res) => {
if (connected via ipv6) {
res.redirect(`https://B/r/${ip}/`)
} else {
res.redirect(`https://A/results/${ip}/null/`)
}
})
app.get('/r/:v6/', (req, res) => {
res.redirect(`https://A/results/${ipv4}/${ipv6}`)
})
app.get('/results/:v4/:v6/', (req, res) => {
res.send(v4, v6)
})
If you make a request to A/, it will check if you are connected over IPv6 or IPv4. If you are connected over v6, it will redirect to B/r/[your IPv6]. That will initiate an IPv4 connection, and I can get your v4 address that way, and redirect you to A/result/[IPv4]/[IPv6]! If you are connected to A over IPv4, it will redirect you to A/result/[IPv4]/null immediately. This way, I can show your v4 and v6 at the same time! You can try it out with (i forgor 💀 to renew the domain)curl -L v4v6.ml or by visiting v4v6.ml :)
Full source code in Node.js: http://ix.io/4bjp