Editing /private/etc/hosts

hostsssh

I just added my no-ip domain to /private/etc/hosts under a shorter alias:

alias host.no-ip.biz

I tried the following on the shell:

dscacheutil -flushcache

but it still says:

ssh: Could not resolve hostname

What up with that?

Best Answer

/etc/hosts can't be used for that:

/etc/hosts cannot be used (by itself) to produce hostname "aliases".

The hosts file produces the internal equivalent of A and PTR records from the DNS, i.e. mapping of hostname to IP address and vice-versa.

It cannot be used to produce the same effect as a CNAME record.

You can make ssh alias equivalent to ssh host.no-ip.biz or ssh username@host.no-ip.biz by adding lines like this to ~/.ssh/config:

Host alias
HostName host.no-ip.biz
# User username