PDA

View Full Version : [ubuntu] [SOLVED] newbie can't resolve hostname



BigBadBaz
June 20th, 2008, 04:18 PM
Hi. I'm a complete newbie (first time setting up a server or dealing with Linux). I just installed Ubuntu 8.04 server. I can ping the ip address, but when I try to ping the hostname, it doesn't work.

drs305
June 20th, 2008, 04:21 PM
Run this to check the hosts file. It should have a line like:
127.0.0.1 yourcomputername


cat /etc/hosts

If you aren't sure, you can post the results here and we can look at it and give you further advice.

the_doc
June 20th, 2008, 04:21 PM
You resolve host names either by a DNS service or by your own hosts file. If you're setting up your own server I'm guessing you've not set up a DNS sevice?

BigBadBaz
June 20th, 2008, 04:36 PM
Run this to check the hosts file. It should have a line like:
127.0.0.1 yourcomputername


cat /etc/hosts

If you aren't sure, you can post the results here and we can look at it and give you further advice.

It reads:
127.0.0.1 localhost

BigBadBaz
June 20th, 2008, 04:36 PM
You resolve host names either by a DNS service or by your own hosts file. If you're setting up your own server I'm guessing you've not set up a DNS sevice?

I set my server up within another network that has a DNS service.

the_doc
June 20th, 2008, 04:37 PM
Put the IP address of the PC you want to connect to plus its name into that file in the same format as the localhost entry.

BigBadBaz
June 20th, 2008, 04:41 PM
Put the IP address of the PC you want to connect to plus its name into that file in the same format as the localhost entry.

I did that with one computer, and it worked. However, I also want to be able to access my server with webmin from any machine I want.

the_doc
June 20th, 2008, 04:43 PM
After re-reading this thread I guess what you want is for every network node to be able to access the new server by its name. If you already have a DNS server in that network then I'm guessing you'll have to register the new server with the DNS server.

The host file method isn't really convenient if this is the case, as every node would have to have an entry for the new server in its host file.

BigBadBaz
June 20th, 2008, 04:45 PM
How do I do that? Does it have to be done from the DNS side?

JordanH
June 20th, 2008, 04:46 PM
Let me see if I got this straight...
PC1 - new linux machine. eg hostname PC1.acme.com / IP address 192.168.1.1
PC2 - Other whatever machine. eg hostname PC2.acme.com / IP address 192.168.1.2

You try to ping PC1 from PC2 as follows: ping 192.168.1.1
and you receive the correct reply.

You try to ping PC1 from PC2 as follows: ping pc1.acme.com
and you receive timeouts.

Ok... so the problem is that pc1.acme.com is not being resolved on PC2. So a) pc1.acme.com is not registered in your DNS or b) PC2 does not have an entry in its host file for pc1.acme.com.

Lets assume b) and we'll go from there.

Make sure each system has a host file with the correct address of the other.
Linux: /etc/hosts
Windows: c:\windows\system32\drivers\ets\hosts

Now add the appropriate line in each host file
on PC1: echo "192.168.1.2 pc2 pc2.acme.com" >> /etc/hosts
on PC2: echo "192.168.1.1 pc1 pc1.acme.com" >> /etc/hosts
(if it is Windows, use notepad to edit the appropriate file then save and close)

You may now ping the hosts using IP address, hostname or fully qualified name.

[edit] D'oh! It appears you have decided to use Option a) the DNS instead of using option b) local hosts files. Are you sure you have a local DNS server? If this is a company, speak to your sysadmin and they will add the appropriate records for you. (You can ask them to add an "a" record for your new host and they'll understand. If you do not have a sysadmin or DNS server, then you are back to Option B).

If you want to install a DNS server, this is more work. Do some searching on "bind".

BigBadBaz
June 20th, 2008, 04:50 PM
That won't work for me. I want to be able to use webmin from any machine in the network.

the_doc
June 20th, 2008, 04:54 PM
As I've already said, the hostfile method is not convenient.

How do I do that? Does it have to be done from the DNS side?

I'm not a complete DNS expert, but yes I would suggest that would have to be done on the DNS server. Essentially you would be putting the new servers name and IP address into the DNS database, then the network nodes should be able to resolve the new server name if your DNS server is set up correctly.

BigBadBaz
June 20th, 2008, 05:03 PM
I probably won't be able to get access to the DNS server until Monday. I'll try it then, and let you know.

the_doc
June 20th, 2008, 05:04 PM
Good luck!

BigBadBaz
June 20th, 2008, 05:59 PM
I didn't get to the dns server yet, but I was told that our main ubuntu server didn't need to be added to it.

Dedoimedo
June 20th, 2008, 06:51 PM
Hello,
Setting up the DNS server (BIND) is a lot of work. But if you want, I can help ... say the word.
Dedoimedo

BigBadBaz
June 20th, 2008, 07:25 PM
I don't need to set up the DNS server, it's already set up. I'm just trying to get my derver to be reachable through its hostname. the_doc recommended that I try to add my hostname to the DNS server, but my boss told me that our main LAMP server didn't need to be. Any other ideas?

Dedoimedo
June 20th, 2008, 09:16 PM
Hello,

The DNS server is defined in this file:

/etc/resolv.conf

Add the line: nameserver xxx.xxx.xxx.xxx where xxx.xxx.xxx.xxx is the IP address. Save and exit and you should have your DNS server all set up.

Of course, you must be able to reach it - this means the right route and firewall rules.

Dedoimedo

the_doc
June 21st, 2008, 12:50 PM
I don't need to set up the DNS server, it's already set up. I'm just trying to get my derver to be reachable through its hostname. the_doc recommended that I try to add my hostname to the DNS server, but my boss told me that our main LAMP server didn't need to be. Any other ideas?

If your network uses DNS to resolve hostnames I can't see how your new server name will be resolved unless it's added to the database if you don't want to use the host file method. But I'll be happy to be educated!

hyper_ch
June 21st, 2008, 12:53 PM
Listen to Dedoimedo two posts above.

the_doc
June 21st, 2008, 12:57 PM
Who me?

hyper_ch
June 21st, 2008, 12:59 PM
no, not you doc... I meant the TO

the_doc
June 21st, 2008, 01:02 PM
Phew, thought I'd missed something!

BigBadBaz
June 23rd, 2008, 03:16 PM
Hello,

The DNS server is defined in this file:

/etc/resolv.conf

Add the line: nameserver xxx.xxx.xxx.xxx where xxx.xxx.xxx.xxx is the IP address. Save and exit and you should have your DNS server all set up.

Of course, you must be able to reach it - this means the right route and firewall rules.

Dedoimedo

I already had the line nameserver xxx.xxx.xx.xxx
I don't have any firewall on my server. How do I make sure that I have the right route?

Dedoimedo
June 23rd, 2008, 03:44 PM
Hi,

Type route and if you want post here. Just in general:

default is the default gateway --> this IP leads to all IPs not defined in any other route; preferably, it will point to your DNS server.

A flag that indicates gateways is G.

Ping and traceroute can also help make sure you have no network connectivity problems.

Dedoimedo

BigBadBaz
June 23rd, 2008, 04:34 PM
Hi,

Type route and if you want post here. Just in general:

default is the default gateway --> this IP leads to all IPs not defined in any other route; preferably, it will point to your DNS server.

A flag that indicates gateways is G.

Ping and traceroute can also help make sure you have no network connectivity problems.

Dedoimedo

I can ping google.com ad well as all of my internal servers.
Route gives me the following:

Destination 192.168.42.0 default
Gateway * 192.168.42.1
Genmask 255.255.255.0 0.0.0.0
Flags U UG
Metric 0 100
Ref 0 0
Use 0 0
face eth0 eth0

The gateway does look right.

I'm sorry, the post didn't come out like I thought it would. There's a space in between each of the addresses.

JordanH
June 23rd, 2008, 04:51 PM
I didn't get to the dns server yet, but I was told that our main ubuntu server didn't need to be added to it.

As per my previous note and the_doc's comments, your above statement is incorrect. You really do need to have it in the DNS.
Your 2 options are
A) Update the DNS to point to your new machine.
B) Use Host files.
You have said that host files are out of the question (correct answer, seeing as this is not your home system)

Your sysadmin really needs to add a record to your DNS to point to your server in order for clients to resolve the IP address.

BigBadBaz
June 23rd, 2008, 05:24 PM
I confirmed with my sysadmin that we have never had to manually add a server to the DNS, nor have we used host files.

the_doc
June 23rd, 2008, 05:30 PM
Do you use DHCP on that network?

BigBadBaz
June 23rd, 2008, 05:31 PM
Yes.
I just had my sysadmin add my server to the DNS, and it still doesn't work.

the_doc
June 23rd, 2008, 05:33 PM
Ask him if you're using dynamic DNS.

BigBadBaz
June 23rd, 2008, 06:24 PM
We are using dynamic DNS.

the_doc
June 23rd, 2008, 06:34 PM
Right! That's why you don't manually add DNS host records, because the IP address associated with each hostname would be updated to frequently with DHCP, and would be inconvenient. So dynamic DNS does it in conjunction with DHCP, everytime DHCP dishes out a new IP to a host it updates DNS with the new details.

Same principle as doing it yourself, but less hassle!

Your /etc/resolv.conf file lets your computer find and query the DNS server.

You say it's still not working?

BigBadBaz
June 23rd, 2008, 06:40 PM
That's correct.

the_doc
June 23rd, 2008, 07:12 PM
Ok, sorry if I'm regurgitating old info, are you sure you are getting a DHCP address?

BigBadBaz
June 23rd, 2008, 07:17 PM
I believe that I'm getting a DHCP address. In the file /etc/network/interfaces it says iface eth0 inet dhcp. Also, I got an IP address without setting it manually. Unless something's not working right, I should be getting a DHCP address.

BigBadBaz
June 24th, 2008, 05:58 PM
Any other ideas?

the_doc
June 24th, 2008, 06:08 PM
I have been thinking about this one and haven't simply jumped ship!

Can you check to see if there are any host records on the DNS server that pertain to your new server (in addition to the one your sysadmin added manually)?

And it may be worth trying to refresh the new servers IP address lease and see if that updates the DNS server.

BigBadBaz
June 24th, 2008, 06:44 PM
There are no other records on the DNS sever. When I refreshed the IP address I did get a new address. However, although the DNS server says that my IP address is leased, it doesn't associate any name with it.

By the way, I just asked the sysadmin if we're using dynamic DNS and he said that we are using it to connect to the outside, but within our network we're not using it. (The first time I asked the boss.)

JordanH
June 27th, 2008, 04:35 AM
Some Dynamic DNS servers require that you explicitly login and update your IP address when it changes. Do the other servers in the environment really do this? It's rare that I see servers use dynamic addresses within a company network.

I'm really confused how you can have no records in the DNS and no host files and yet be able to lookup other server addresses.

So, internally, do you use a DNS server? Or are you strictly relying on an external DNS?

BigBadBaz
June 27th, 2008, 02:43 PM
We have an internal DNS server, but it's not dynamic (post #39). We usually do not have to add a server to the DNS (it's done automatically), but we tried doing that anyway, and it didn't help.

From my server I can ping another IP address or hostname, and all of the other servers can be pinged by there hostnames or IP addresses.

BigBadBaz
July 2nd, 2008, 03:40 PM
Hi all. I solved it! I had to set up a Samba file server, so I reinstalled Ubuntu, but this time with Samba. After the installation of Webmin, I tried logging on using the hostname, and it worked! I tried doing it on another machine, and that one worked as well!

My thanks to all of you for your time and help.

the_doc
July 4th, 2008, 08:42 PM
Hi all. I solved it! I had to set up a Samba file server, so I reinstalled Ubuntu, but this time with Samba. After the installation of Webmin, I tried logging on using the hostname, and it worked! I tried doing it on another machine, and that one worked as well!

My thanks to all of you for your time and help.

Not sure how that solved the problem, but I'm happy for you!

BigBadBaz
July 6th, 2008, 11:32 PM
I don't know either, but it worked on another server I was trying to set up as well. I'm not about to start complaining.

lavinog
October 15th, 2008, 06:25 PM
I think it worked because samba setup wins