0

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.

  • 1
    I don't understand. The whole point of noip.com is to have a name that is easy to remember. Can't you just pick a better name? Are you just looking for something like storing the name in a variable and then doing ping "$name"? – terdon Nov 05 '23 at 13:37
  • Yes, but I accepted a random-generated one, and that was my fault. Anyway it'd be great if I learn how to do that.

    And as an answer to your question, I don't know anything about variables, it may work but I'm not sure... Can you show me how, please?

    As I said, I use /etc/hosts for static IPs, but it doesn't work for DNS domain name.

    – Abd Alhaleem Bakkor Nov 05 '23 at 15:09
  • @xhienne not really, I don't run my own DNS server, I'm using openDNS, but I have DDNS to point me to Dynamic IP address node that I always need access to.

    I'm looking into linux variables now as terdon mentioned them, I will update if I have any success with that.

    – Abd Alhaleem Bakkor Nov 05 '23 at 15:18
  • @terdon it seems variables are for system/local environment like shell home folder etc...

    I don't think they are useful for DNS stuff.

    Maybe ip addr , dnsmasq or some other networking service?! All I need is to call that long name as short one... Thanks

    – Abd Alhaleem Bakkor Nov 05 '23 at 15:29
  • @Abd In the other question, OP has a domain on DDNS and wants to use a short name like home instead. This is exactly what you want if I understand your question correctly. So, the answers are the same here and there. – xhienne Nov 05 '23 at 15:52
  • 1
    "_ I accepted a random-generated one_" - why not discard that one and get a fresh one that you define? – Chris Davies Nov 05 '23 at 16:05
  • @ChrisDavies I'm on free account, I don't know if they allow me to change it. being cheap has it's negatives – Abd Alhaleem Bakkor Nov 06 '23 at 05:22
  • 1
    It's trivial to change one. I've literally just created an account to try this. Delete the hostname you've got and then add your own preferred one – Chris Davies Nov 06 '23 at 07:30

1 Answers1

1

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.

terdon
  • 242,166