I know that you can add hostnames to /etc/hosts
so that resolving them doesn't actually perform a DNS lookup. This would be a line such as
123.45.67.89 myhostname
My question is, what can I set the first part (IP address) to so that any attempted connection to this myhostname
will always fail?
Edit: By fail, I mean an explicit ICMP rejection if possible. I don't want to wait for a timeout.
Reason
I have a VM instance running somewhere, sometimes. The cloud server sets a different IP on every launch and I'm not paying for any public domain name. I have a script that launches the instance and adds a line to /etc/hosts
so I can easily ssh or open a browser tab to this host using myhostname
.
That all works great, but I'd like to also remove this entry when the instance is killed, and have attempted connections to myhostname
not incur any DNS lookups or (worse) try to connect to some same-named host on whatever local domain I'm sitting in at the moment.