A dumb server to tell you your IP on your network, or your IP as the world sees it
These are the steps I use for raspbian. Some paths may differ slightly on other distros.
- Build the executables
$ go build
- Copy the executable to /bin
# cp ipecho /bin
- Copy the .service file to systemd's config directory
# cp ipecho.service /etc/systemd/user
- Reload the systemd daemon
$ systemctl --user daemon-reload
- Start the service
# systemctl start ipecho.service
By default, the service runs on port 5353. This can be changed in the service file via the -port
flag.
To get your IP on your LAN or whatever, just visit the server.
$ curl ipecho.your.net:5353
To spice things up and get your external IP as the world (or at least AWS (which is the same thing)) sees it:
$ curl ipecho.your.net:5353/external
This endpoint just hits checkip.amazonaws.com
This solves a problem I have approximately every 8 to 14 months and is written in Go. It would probably be useful in a script.