Cannot resolve hostname

Cannot resolve hostname

5 PCs, all running Ubuntu, connected by a wireless to router with DNS. Running an ejabberd server on one of the PCs, and an Apache server on another. PC 1 can only connect to the servers with their IP addresses, not their names (so I can't set up a Jabber account on it). All of the other computers are resolving the hostnames without difficulty.

Here are the pertinent files:

/etc/resolv.conf

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN nameserver 127.0.1.1

/etc/hosts

127.0.0.1   localhost
127.0.1.1   nameofPC1

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

/etc/nsswitch.conf

hosts:          files mdns4_minimal [NOTFOUND=return] dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

Firewall: I've never used ufw on this machine. When I run iptables -L this is what I get:

modprobe: ERROR: could not insert 'ip_tables': Operation not permitted
iptables v1.4.21: can't initialize iptables table `filter': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.

Also, ping works for IP address but not for hostname.local. nslookup can't find anything, whether it is IP or hostname (but that's also true of the machines that aren't having problems resolving the hostname).

Any suggestions?

This is a problem only for LAN hostnames, e.g., servername.local. Internet hostnames (google.com) are resolved.

I understand that I can set up a local DNS server, but my router already performs that function, and all of the other PCs on the LAN are resolving hostnames without difficulty. What I can't figure our is why this one PC, out of all the rest, can't resolve hostnames.

答案1

If you want to set up name resolution inside a LAN i can think of 2 options:

1. Set up a DNS-server

Run: sudo apt-get install named on one of the servers, configure the DNS-server and point to that server by editing /etc/resolv.conf or using resolvconf if that's what you use.

2 . edit /etc/hosts

Simply edit this file and add the ip-address & desired name. This has to be done on each machine individually.

相关内容