03-03-2012 02:38 PM - edited 03-07-2019 05:19 AM
Just a simple question here, (yes I'm still a beginner):
I have a router which the inside interface is hooked to a PC with the IP address 10.1.0.1.
I want to access that PC with ssh; (from the outside)
I did the command on the router:
Router(config)# ip host ssh1.myhost.com 10.1.0.1
In the future, there will be more PCs hooked to this router, and maybe switches.
I start putty on my workstation and try to open host "ssh1.myhost.com" with port 22. Connection refused.
Is this the proper way to set hosts?
Solved! Go to Solution.
03-03-2012 03:04 PM
Hi Alexandre,
If I got this right, you want to make an alias (name) for a PC host and access it from outside the router? The command ip host is simply a name mapping for ip address and is local significant for that device (in this case it is router). It is useful when you want to ssh FROM the router to another device and you don't want to type in ip address every time. But you can't access an device from outside the router using this name because it is stored only in router. The other thing is that the machine you want to access must have ssh configured and running. Please explain it more if I misunderstood you.
Best regards,
Jan.
03-03-2012 03:03 PM
Alexandre
The syntax that you use is correct. But the command does not do what it seems that you would like it to do. When you configure that command it allows you to use that name while in a session on the router and access that address.
It sounds like what you want is to use the name ssh1.myhost.com from a session on your workstation. To accomplish this you would need DNS in your network and not the ip host command on the router.
HTH
Rick
03-03-2012 03:04 PM
Hi Alexandre,
If I got this right, you want to make an alias (name) for a PC host and access it from outside the router? The command ip host is simply a name mapping for ip address and is local significant for that device (in this case it is router). It is useful when you want to ssh FROM the router to another device and you don't want to type in ip address every time. But you can't access an device from outside the router using this name because it is stored only in router. The other thing is that the machine you want to access must have ssh configured and running. Please explain it more if I misunderstood you.
Best regards,
Jan.
03-03-2012 03:18 PM
Thank you for the advice. Yes, the machine is CentOS and has OpenSSH up and running, it works well if I physically plug a keyboard on it.
So about the DNS stuff, if I set one of my machines to act as a DNS server (for example Named for linux) and I use:
Router# ip name-server
It should work, even if the DNS returns local addresses ?
03-03-2012 03:22 PM
Because I found "ip dns server" on Google, but any "ip dns" commande do not work on my 1760
03-03-2012 03:41 PM
Hi Alexandre,
You're welcome and thank you! About the DNS: I believe that it should work from the router because you can configure named with private ip addresses. But if you try to get to the local machine (with local private IP) from another network it won't work if the host will use another DNS server to resolve the host name (which is locally significant only).
That is because - as in the previous scenario - ip name-server command have significance only for router, not for other machines on the network which may have another DNS server configured. This command tells the router to use DNS server with an configured ip address when translating names to ip addresses.
I don't know if that's what you are asking so feel free to correct me.
Best regards,
Jan.
03-03-2012 05:13 PM
This answer makes sense, I will test this tonight and tell you the results.
03-04-2012 01:12 AM
Hi,
just configure an entry in the hosts file on your machine mapping the name and the IP.
On linux this file is /etc/hosts and on Windows this is %systemrot%\Windows\System32\Drivers\etc\hosts
This is a text file you can open with any text editor.This way you can access the device by name on your LAN without using any DNS server.
Regards.
Alain
03-04-2012 10:22 AM
EDIT: To simplify, all I am trying to do is to access a machine with a paticular alias (ex: web01.myhost.com) from outside my network. Simple as that, but I can't find a solution anywhere.
I made the testing, here's what I did.
I setup a DNS server 10.2.0.1 on my local network, the DNS has been tested from inside and it is OK.
I put those configs:
dns01.myhost.com - 10.2.0.1
web01.myhost.com - 10.6.0.1
From the inside, all pings well. I made the command:
Router# ip name-server 10.2.0.1
From the router, pings to web01.myhost.com work (resolve to 10.6.0.1)
From the outside, if I ping web01.myhost.com, the router responds, but if I try to open a SSH session, the internal host is not even reached.
Any advice ?
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide