short name a domain name
I have a DDNS service with noip.com, but the link I have is so hard to remember.
It’s working, I can resolve it using resolveip link
and I get the current IP of the router.
I tried to use /etc/hosts but it didn’t work, it requires that I put an IP.
How can I give a short name to the DDSN link I have.
for example ping name
, so the system would resolve name for the DDNS link.
I wonder if NetworkManager or ip addr can help me.
Thanks a lot.
Just store the address in a variable and then you can ping that:
$ foo=unix.stackexchange.com
$ ping "$foo"
PING unix.stackexchange.com (104.18.43.226) 56(84) bytes of data.
64 bytes from 104.18.43.226 (104.18.43.226): icmp_seq=1 ttl=58 time=5.12 ms
64 bytes from 104.18.43.226 (104.18.43.226): icmp_seq=2 ttl=58 time=10.5 ms
64 bytes from 104.18.43.226 (104.18.43.226): icmp_seq=3 ttl=58 time=8.05 ms
^C
--- unix.stackexchange.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 5.120/7.901/10.532/2.212 ms
To make it permanent, edit your ~/.profile
file (or ~/.bash_profile
if that file exists and you are using bash
) and add this line (of course, change foo
to whatever you want your variable to be called and change the URL to the name of your server):
export foo=unix.stackexchange.com
Now, from the next time you log in, you will be able to run ping "$foo"
to ping, or echo "$foo"
to print it out etc.