LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-09-2005, 08:28 PM   #1
FLOODS
Member
 
Registered: Aug 2003
Location: GA
Distribution: Fedora Core 4 Desktop/Server.
Posts: 361

Rep: Reputation: 30
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!
 
Old 05-10-2005, 01:32 PM   #2
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 4,170

Rep: Reputation: 244Reputation: 244Reputation: 244
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
 
Old 05-10-2005, 01:40 PM   #3
ocularbob
Member
 
Registered: Nov 2002
Location: brooklyn NYC
Distribution: gentoo
Posts: 212

Rep: Reputation: 30
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.
 
Old 05-10-2005, 02:28 PM   #4
maybbach
Member
 
Registered: Feb 2004
Location: Cincinnati, OH
Distribution: SimplyMepis 3.3
Posts: 68

Rep: Reputation: 15
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.
 
Old 05-12-2005, 12:43 PM   #5
FLOODS
Member
 
Registered: Aug 2003
Location: GA
Distribution: Fedora Core 4 Desktop/Server.
Posts: 361

Original Poster
Rep: Reputation: 30
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?

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

Last edited by FLOODS; 05-12-2005 at 01:00 PM.
 
Old 05-12-2005, 01:03 PM   #6
maybbach
Member
 
Registered: Feb 2004
Location: Cincinnati, OH
Distribution: SimplyMepis 3.3
Posts: 68

Rep: Reputation: 15
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?

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.
 
Old 09-19-2005, 06:21 AM   #7
joshtt
LQ Newbie
 
Registered: Apr 2003
Location: Belgium
Distribution: Mandrake 10.0
Posts: 17

Rep: Reputation: 0
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!

Last edited by joshtt; 09-19-2005 at 06:24 AM.
 
Old 09-19-2005, 01:41 PM   #8
FLOODS
Member
 
Registered: Aug 2003
Location: GA
Distribution: Fedora Core 4 Desktop/Server.
Posts: 361

Original Poster
Rep: Reputation: 30
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Running a shell script remotely via 'ssh <hostname> <command>' davee Linux - General 4 10-09-2005 01:38 AM
Cannot SSH/FTP by hostname, but ip works joshtt Linux - Networking 3 09-20-2005 05:08 AM
Ping or SSh by hostname ElectroLinux Linux - Newbie 2 10-26-2004 03:21 AM
can't ssh through hostname romel Linux - Networking 4 07-25-2004 01:54 PM
Do after changed the hostname, can't connection by SSH again? explorer1979 Linux - Networking 2 03-30-2004 10:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration