local hostname resolution get failed for DHCP configured IP

Hi,

I have configured DHCP IP in my open suse system. Internet and all other things works fine.

But I could not resolve system hostname(for example: MySusePC) from DNS. Even ping is also not working.

resolv.conf looks okey as it can resolve google.com.

Is this expected behaviour or DNS/DHCP issue?

Thanks,
Regards,
Rakesh Patel

How is the following configured?

grep -i hosts /etc/nsswitch.conf

Also, check

cat /etc/HOSTNAME

Hi deano_ferrari,

Thanks for your reply.

cat /etc/HOSTNAME → Contains valid name “MYSUSE”

grep -i hosts /etc/nsswitch.conf
hosts: files dns

Is there any problem in configuration ?

Thanks
Rakesh Patel

Observed that for static IP, /etc/hosts contain entry for IP-Hostname. So everthing is working fine.

Why DHCP does not contain entry in /etc/hosts file ? If this is expected than how to resolve localhost name ?

Well, check that /etc/hosts also contains

127.0.0.1       MYSUSE localhost

No its does not contain MYSUSE.

cat /etc/hosts
127.0.0.1 localhost

No its does not contain MYSUSE.

cat /etc/hosts
127.0.0.1 localhost

Well ,if you add the hostname, then it should be able to resolve?

Yes. When you have hostname then no problem. Able to resolve name.

But as per my networking knowledge, for DHCP IP /etc/hosts file does not contain IP-Hostname mapping. Correct me if I am wrong.

Thanks
Rakesh Patel

No, /etc/hosts also provides name/IP address mappings and works in conjuction with DNS, NIS etc.

Does this help clarify?

uname -n–> MYSUSE
hostname -a–>Name or service not known.
hostname -s–>Name or service not known.
hostname -d–>Name or service not known.
hostname -f–>Name or service not known.
hostname—>MYSUSE

Entry is not same in /etc/hosts.
It is : 127.0.0.1 localhost
It should be : 127.0.0.1 mybox.mydomain.com localhost.localdomain localhost

/etc/sysconfig/network/ifcfg-eth0 does not contain HOSTNAME or DHCP_HOSTNAME?

Is this system OS issue or DHCP server issue ?

Thanks
Rakesh Patel

uname -n–> MYSUSE
hostname -a–>Name or service not known.
hostname -s–>Name or service not known.
hostname -d–>Name or service not known.
hostname -f–>Name or service not known.
hostname—>MYSUSE

Entry is not same in /etc/hosts.
It is : 127.0.0.1 localhost
It should be : 127.0.0.1 mybox.mydomain.com localhost.localdomain localhost

/etc/sysconfig/network/ifcfg-eth0 does not contain HOSTNAME or DHCP_HOSTNAME?

Is this system OS issue or DHCP server issue ?

Thanks
Rakesh Patel

It is working for me. But it is the local router that provides DNS forwarding, and sometimes fakes DNS support for local hostnames. If I use a different DNS server (other than provided by the router), then I define hostnames for local systems in “/etc/hosts”. At present I am not doing that, because the router is handling it well.

In Yast Network Settings, Hostname/DNS tab, I do check the box “Assign Hostname to Loopback IP” and I uncheck the box “Change Hostname via DHCP”.

Same working for me when i set “Assign Hostname to Loopback IP”. Its update /etc/hosts file.

Is it exepected behaviour for “Change Hostname via DHCP” not to work.

Thank.
Regards,
Rakesh Patel

It depends on your router, and on what you mean by “works”.

I have not tried it with my present router. When used with my previous router, if I left that on then my computer would be renamed to what the router wanted to call it. I did not want that, which is why I always uncheck that box.

However, I think that “worked” with my previous router only when using “ifup” network settings. It never worked when using “NetworkManager”.

Thanks for your quick reply.

I mean by “Is it exepected behaviour for Change Hostname via DHCP not to work.” is for when you have DHCP setting “Change Hostname via DHCP” , /etc/hosts file does not get changed. and ping to local hostname get failed.

As I observed, ping to local host-names works only its entry present in /etc/hosts file.

I am not getting “its depends on your router”. which configurations i need to check in router. Can you please explain me ?

And is there any service on DNS server which maintain Hostname-IP (DHCP home network’s) mapping ?

That’s what I expect.

The idea of change name via DHCP is really for a business workplace environment, where the local hostnames are assigned via the DHCP server. That alliows the network manager to set up all machines to have identical software, and take care of the naming at the level of the DHCP server. This is probably not what you want in a small home network.

I am not getting “its depends on your router”. which configurations i need to check in router. Can you please explain me ?

Again, in a business workplace environment, I would not expect the router to do anything except provide IP address, perhaps hostname, domain name, DNS server. In such an environment, the network manager would add entries to the company DNS server to take care of the name lookups for local systems.

Routers intended for small home networks try to fake some of this. For example, they expect the client computer (probably a Windows box) to identify its NETBIOS name, and they setup a fake DNS response for queries for that name. But small home routers vary in how much of this they implement. There often isn’t anything to configure on the router. It depends on the router design.

Or, to put it all differently, in a small home network one learns to put up with whatever works or doesn’t work. That costs a lot less than hiring a network administrator.

That’s correct. This option makes dhcpcd change host name; nothing more.

and ping to local hostname get failed.

Well, name-to-address resolution is independent from host name. Host name is simply string that is stored in kernel and which is retrieved by commands like “hostname”. If you want to also update /etc/hosts you can write/extend script that is called when DHCP client gets address and modify /etc/hosts accordingly.