Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I rebuilt a Windows 7 Workstation with CentOS 6.5. The Windows 7 had a host name aaa attached to domain ddd.local.

The new CentOS hostname is bbb. When I try to ping it:

$ ping bbb
ping: unknown host 

However when I try the old host name it get the correct IP:

$ ping aaa
PING aaa.ddd.local (192.168.2.33) 56(84) bytes of data.
64 bytes from 192.168.2.33: icmp_seq=1 ttl=64 time=0.345 ms
64 bytes from 192.168.2.33: icmp_seq=2 ttl=64 time=0.374 ms

In fact I can ssh to it using username@aaa and it works.

My /etc/hosts is:

127.0.0.1   bbb.ddd.local localhost 

My /etc/hostname is:

bbb

My /etc/sysconfig/network is:

NETWORKING=yes
HOSTNAME=bbb.ddd.local
NTPSERVERARGS=iburst

I tried adding DNS_HOSTNAME=bbb to the ifcfg-eth0 with no success.

I have little, to possibly no access, to our companies DNS Server and any changes would have to go through a long process, something I would like to keep as the very last option.

Please let me know how I can inform the DNS server to update the hostname for the specific network Card?

share|improve this question
add comment

1 Answer 1

The hostname you set on a give system has nothing to do with the hostname that other computers on your network know this computer by, unless you're making use of DHCP to delve out your IP addresses AND your DHCP sever is setup to communicate with your domains DNS server. I'll describe methods for setting that up down below in the Sending your hostname to DHCP section.

Why can't I ping bbb but still aaa?

If your domain is not making use of what's called dynamic DNS (this is where the clients can provide their hostnames' to the DHCP server) then there is really nothing you can do to change your hostname to IP address mapping that exists in your domains DNS server.

If you've continued to get the same lease when your system was using Windows 7 (which you should be since it's the same hardware using the same MAC address), then your DHCP server is likely continuing to use the hostname that was originally reported when you were using Win 7.

Using the method described below should get your Linux host to send its hostname if it isn't already doing so.

Sending your hostname to DHCP

If your DHCP server supports it you might want to try and have your client send the desired hostname that it wants. Add the following to the file /etc/dhcp/dhclient.conf:

send host-name 'your-hostname-here';

If you want to send a fully qualified domain name (fqdn) - myhost.mydomain.com instead of just myhost you need to add these lines too:

send fqdn.fqdn "myhost.mydomain.com.";
send fqdn.encoded on;
send fqdn.server-update off;
also request fqdn, dhcp6.fqdn;

Edit #1

The OP was asked to try the following commands and report back:

dig <hostname> @<router ip>

The OP reported that this worked so it was determined to try adding the router's IP explicitly to his dhclient.conf file.

Edit #2

It was suggested to try adding the following to the /etc/dhcp/dhclient.conf file:

prepend domain-name-servers 192.168.2.1;

Edit #3

Given you're able to now ping servers using your router's DNS server when you added 192.168.2.1, but not the internet, I would suggest you add some external DNS servers as well using the above prepend option like so:

prepend domain-name-servers 192.168.2.1, 8.8.8.8, 8.8.4.4;

This will add your router as a DNS resolver along with Google's DNS servers.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.