LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to map IP to hostname (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-map-ip-to-hostname-738496/)

maya.asagao 07-08-2009 01:03 AM

how to map IP to hostname
 
Hi,

I used to log-in PC (OS is ubuntu-9.04) from my room. Instead of "ssh username@IP", I want to use hostname such as " ssh username@hostname". Could you please explain me how to do it?


Thanks in advance,
maya

chrism01 07-08-2009 01:08 AM

You need the machine your are coming from to have a name-to-ip mapping to find your target system.
Typically, if on Linux, you would add an entry to /etc/hosts. Otherwise you need a dns server to have an entry.

karamarisan 07-08-2009 01:10 AM

Is that IP address statically configured (i.e., doesn't regularly change)? If so, just edit /etc/hosts and add an entry with the IP address and the hostname.

Edit: Ah, beat me to it.

maya.asagao 07-08-2009 01:54 AM

Hi,

Thank you so much for your prompt responses. It is statically configured and when I add hostname/ip to /etc/hosts as you suggested, it worked.

However, to gain new knowledge, I would like to know that

(1) if my IP is changing (in the case of DHCP), how can I map IP to hostname?

(2) if there is dns server, how should I do ?


thanks in advance,
maya

indeliblestamp 07-08-2009 02:07 AM

(1) You'd need to have a dynamic dns server. I've not tried it, but a quick search brought up a lot of links (like this). Then a small script on each of your clients is required, which will update the DynDNS server every 20 minutes or so about its present ip address.
(2) If you have a dns server already, put its address in /etc/resolv.conf of the client machine.

karamarisan 07-08-2009 02:30 AM

I do use a dynamic DNS service (dyndns.com, to be precise), so let me add to that - it's pretty straightforward. You register with the service and get your hostname, and then you set up something to regularly make sure the entry the service has is correct on the machine in question. A program that does this and seems to be broadly available is inadyn, if you're interested.


All times are GMT -5. The time now is 01:23 AM.