Ever thought sites like ifconfig.me and similar are too slow from the command line? Here I'll show you how easy it is to setup something similar to those services - except it is extremely fast because of Varnish.

The receiver part:

sub vcl_recv {
  if (req.http.host == "ip.vanad.is") {
    return(synth(800));
  }
}

The synthetic part:

sub vcl_synth {
  if (resp.status == 800) {
    set resp.status = 200;
    synthetic(client.ip);
    return (deliver);
  }
}

Go to http://ip.vanad.is or test it out from the terminal:

curl ip.vanad.is