LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   can ssh by IP, can't by hostname. (https://www.linuxquestions.org/questions/linux-networking-3/can-ssh-by-ip-cant-by-hostname-321806/)

FLOODS 05-09-2005 08:28 PM

can ssh by IP, can't by hostname.
 
I have a Fedora Core 3 box setup in my room on a wireless network.
In my routers page, the active leases says ...
Code:

fragile        192.168.10.2        00:0C:76:96:8D:2B        18 hours, 5 minutes, 26 seconds
acheron.linux.net        192.168.10.3        00:0C:E5:52:EC:E1        23 hours, 59 minutes, 58 seconds
darkstar        192.168.10.4        00:0D:3A:83:34:E6        13 hours, 26 minutes, 36 seconds
nebuchadnezzar.linux.net        192.168.10.5        00:0C:76:CB:10:14        1 hours, 42 minutes, 56 seconds

fragile is the XP machine I am on now. Darkstar is my xBox. The linux.net machines are my Fedora Core machines. I am assuming they are only supposed to say acheron and nebuchadnezzar, but I can't get it to work quite right... I obviously have the hostname setup wrong, which brings me to my bigger problem. I'm trying to ssh this box over the network and can't if I use the hostname, however I can if I ssh 192.168.10.3. This leads to an even bigger problem while I want to be able to ssh this box from the outside world. The same goes for ping..
Here's some config files on the acheron machine.

Code:

[root@acheron ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1      acheron.linux.net      acheron
[root@acheron ~]#

Code:

[root@acheron ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=acheron

Do I simply have the hostname setup wrong? From all I've known, this is how it is supposed to be. I do believe I had it setup the same way on slackware (the /etc/hosts file, there's no sysconfig. so much easier without it :( )
Thanks in advance!

HappyTux 05-10-2005 01:32 PM

Re: can ssh by IP, can't by hostname.
 
Quote:

Originally posted by FLOODS
I have a Fedora Core 3 box setup in my room on a wireless network.
In my routers page, the active leases says ...
Code:

fragile        192.168.10.2        00:0C:76:96:8D:2B        18 hours, 5 minutes, 26 seconds
acheron.linux.net        192.168.10.3        00:0C:E5:52:EC:E1        23 hours, 59 minutes, 58 seconds
darkstar        192.168.10.4        00:0D:3A:83:34:E6        13 hours, 26 minutes, 36 seconds
nebuchadnezzar.linux.net        192.168.10.5        00:0C:76:CB:10:14        1 hours, 42 minutes, 56 seconds

fragile is the XP machine I am on now. Darkstar is my xBox. The linux.net machines are my Fedora Core machines. I am assuming they are only supposed to say acheron and nebuchadnezzar, but I can't get it to work quite right... I obviously have the hostname setup wrong, which brings me to my bigger problem. I'm trying to ssh this box over the network and can't if I use the hostname, however I can if I ssh 192.168.10.3. This leads to an even bigger problem while I want to be able to ssh this box from the outside world. The same goes for ping..
Here's some config files on the acheron machine.

Code:

[root@acheron ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1      acheron.linux.net      acheron
[root@acheron ~]#

Code:

[root@acheron ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=acheron

Do I simply have the hostname setup wrong? From all I've known, this is how it is supposed to be. I do believe I had it setup the same way on slackware (the /etc/hosts file, there's no sysconfig. so much easier without it :( )
Thanks in advance!

Well if all the /etc/hosts files are the same as the acheron one then no wonder. You should be putting in the name and IP of every machine on your network otherwise your machine(s) has no way to know what IP to associate with a given hostname my file for example.

Code:

>$ cat /etc/hosts
127.0.0.1      localhost
192.168.0.1    HappyTux
192.168.0.2    DocTux
192.168.0.3    BashfulTux
192.168.0.4    SleepyTux
192.168.0.254  GrumpyTux
# The following lines are desirable for IPv6 capable hosts
# (added automatically by netbase upgrade)

::1    ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts


ocularbob 05-10-2005 01:40 PM

this is a pretty simple problem.
None of your machines have actual/qualified host.domain.names
when a machine tries to lookup a another by name it will ask one of the vast number of DNS(domain name server) machines on the internet. But you presumably do not own linux.net so that will not work.
There is a simple way to work around this.
You should first change the domainname of the machines with the linux.net at the end by editing the file /etc/domainname or maybe
/etc/dnsdomainname to be blank.
Then you can use the file /etc/hosts to tell each machine the name of each other on your network. This file will get checked first when you try to get to a machine by name.

just add entries to /etc/hosts like this on seperate lines

darkstar 192.168.10.4
fragile 192.168.10.2

do this on each of your machines.
that should do it.

maybbach 05-10-2005 02:28 PM

try setting up a dns server on a spare box if u have one (or install the service on an existing one). it's pretty simple in windows and i dont think its incredibly hard in linux, that way u wont have to worry about name resolution being screwed up because u mistyped something. if ur gonna stay w/ host files, make sure u check /etc/nsswitch.conf to make sure that file is listed to first to save u a few miliseconds in name resolving.

FLOODS 05-12-2005 12:43 PM

Well, so far, without doing any of this, I have my laptop working fine. I had to startup the samba service (which I had taken down while in school). Now my laptop can ping all of the other computers fine. The hosts file is the same, so I'm curious why it's able to suddenly. I don't have any dns services/servers up as far as I know, either.

I went through the services list on both the laptop and desktop and all services are the same. I also went through /etc/hosts and /etc/sysconfig/network and they both have identical setup.
I also changed the domain to launchmodem.com since that is what my ISP assigned. Hoped that would do something to.
So now, why can the laptop ping all other machines on the network, while the desktop cannot?:confused:

edit: when it goes through my DNS to lookup acheron.launchmodem.com, it goes to my router first, which is then supposed to notice that it's a local machine, correct? So I see no reason why I would need to setup a DNS server on this machine.

last edit: fixed. added ..
Code:

hosts:      files dns wins
to my /etc/nsswitch.conf and now everything works fine.
Thanks for the help :)

maybbach 05-12-2005 01:03 PM

Quote:

Originally posted by FLOODS
Well, so far, without doing any of this, I have my laptop working fine. I had to startup the samba service (which I had taken down while in school). Now my laptop can ping all of the other computers fine. The hosts file is the same, so I'm curious why it's able to suddenly. I don't have any dns services/servers up as far as I know, either.

I went through the services list on both the laptop and desktop and all services are the same. I also went through /etc/hosts and /etc/sysconfig/network and they both have identical setup.
I also changed the domain to launchmodem.com since that is what my ISP assigned. Hoped that would do something to.
So now, why can the laptop ping all other machines on the network, while the desktop cannot?:confused:

edit: when it goes through my DNS to lookup acheron.launchmodem.com, it goes to my router first, which is then supposed to notice that it's a local machine, correct? So I see no reason why I would need to setup a DNS server on this machine.

if your router is also a dns server, then you don't need to use the /etc/hosts file. make sure ur hosts are all on the same subnet and all have the same default gateway. if u have a dhcp server as well then it should be configured correctly more than likely. also make sure all of your interfaces on your other machines are up. i know in mepis at least, if i cant get an address from the server, the interface goes down and stays down.

joshtt 09-19-2005 06:21 AM

Hi all!

I'm having the same issue as the topic starter.
I can connect to my machine via ssh using the ip, but not using the hostname.
I'm a linux noob, so beware. ;-)

When the pc starts it sets the correct hostname, so that should be fine.
My /etc/hosts file looks like this:

127.0.0.1 localhost
computers static ip computer.univ.ac.be

When I try to ssh using the hostname, ii times out.....
Am I missing something else here?
Oh yeah, same thing happens when trying to sftp.... ip works, hostname doesn't.
Using Mandriva 10.2.

Thanks!

FLOODS 09-19-2005 01:41 PM

It's probably a good idea to start your own thread on this. My problem finally fixed itself, I suppose. I never had to do anything for this to be solved. I'm still confused by it. I think it eventually had to do with a mixture of samba problems and router setup. Start a new thread and I'll be sure to look it up, though.

Good luck.


All times are GMT -5. The time now is 10:44 AM.