resolve local hostnames

how do you get linux to resolve local hostnames without DNS?

i’ve recently migrated from a fully windows home network, to a few linux machines and im unable to ping any local machines with hostname via these linux machines.
i can ping IP and internet hostnames. also, windows > anything pings ok too.
however linux > anything will not ping via hostname.

i beleive it’s an additional service running on windows to resolve hostnames without DNS (wins/netbios).

DNS is done via a netgear DG834 router (DNS forwarding).

i know i could either use direct IP, or add machines into the hosts file, but im wondering if theres some way around that and to have it dynamically update like it does on the windows machines. static mappings seem a bit silly inside DHCP zones :slight_smile:

i’ve seen some reports of avahi causing local network issues (taking over the .local domain), but i think this only extends to having to manually enter in .local after the hostname and even after removing avahi, the problem is still present.

vi /etc/hosts

veehexx wrote:
> how do you get linux to resolve local hostnames without DNS?
>
> i’ve recently migrated from a fully windows home network, to a few
> linux machines and im unable to ping any local machines with hostname
> via these linux machines.
> i can ping IP and internet hostnames. also, windows > anything pings ok
> too.
> however linux > anything will not ping via hostname.
>
> i beleive it’s an additional service running on windows to resolve
> hostnames without DNS (wins/netbios).
>
> DNS is done via a netgear DG834 router (DNS forwarding).
>
> i know i could either use direct IP, or add machines into the hosts
> file, but im wondering if theres some way around that and to have it
> dynamically update like it does on the windows machines. static mappings
> seem a bit silly inside DHCP zones :slight_smile:
>
> i’ve seen some reports of avahi causing local network issues (taking
> over the .local domain), but i think this only extends to having to
> manually enter in .local after the hostname and even after removing
> avahi, the problem is still present.
>
>
11.2 is born with IPv6 enabled by default…many find much better DNS
if that is disabled…try it…easy:

next boot, when the green screen first comes up, just start typing:
ipv6.disable=1

and that will appear on the kernel parameters line (or whatever it is
called)…when finished typing just hit enter…

then see if your DNS troubles are over…if it works for you than add
that line to the

at the end of the kernel line used in /boot/grub/menu.lst

if you don’t know how to do that, ask (or google the how)


Enjoy Packman’s benefits? Show your appreciation by donating at
http://se.unixheads.org/?donate

DenverD
CAVEAT: http://is.gd/bpoMD [posted via NNTP w/openSUSE 10.3]

I think a little bit more information for this seemingly Windows adapt may be usefull :wink:

Indeed, as root edit /etc/hosts. But first read

man hosts

to see what goes there. No need to run any erxtra tool/program.

sorry, you right hcvv

a GUI solution: open YaST and go to Network Services -> Hostnames and
add your local hostnames and IP

@VampirD: you completey revenged yourself. I strongly support the YaST method.

thanks all; i thought it’d be a hosts file edit :slight_smile:

Sometimes your modem/router has a simple DNS forwarder that can also resolve local names. You’d have to look through your router’s menus, it depends if the model implemented it. The local name is usually taken from the identifier sent in the DHCP request, so you might see a name of the form linux-az78df. You can change name in the YaST networking setup. Sometimes the router even allows you to enter some fixed IP/name mappings, this is useful for machines that should have a static IP.

On 2010-07-14 19:06 GMT hcvv wrote:

>
> VampirD;2188584 Wrote:
> > vi /etc/hosts
>
> I think a little bit more information for this seemingly Windows adapt
> may be usefull :wink:

He is asking for some automatic method not needing to do that (read his
post, he did mention “not editing the host file”). Plus, the solution
you propose does not work with DHCP, as the IP assigned can change from
one day to the next.

veehexx: you will be able to access windows machines by names if the
appropriate ports are opened in the firewall. There was a question
about that recently. Linux to linux, dunno. Avahi, perhaps.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” GM (Minas Tirith))

thanks for a more precise answer.

editing the hosts file (for my immediate intended purpose) isnt a huge issue; DHCP reservation on a NAS box. however since i do build PC’s for friends/family and rely on VNC/RDP hostnames are easier to use than ever changing IP addresses under DHCP. i’ll disable firewall for a few moments and see if i can ping local hostnames… and do some more digging to find that post you mention, Carlos. im so used to windows just working in that reguard, i never thought of the firewall!

IMO, VampireD and hcvv are right, you can edit /etc/hosts or use YaST -> Hostnames. I’m not sure how that works when the IP addr is changed by DHCP.

I think what ken_yap suggests is that some routers allow you to reserve IP addresses to MAC addresses and also resolve hostname by DCHP lookup of the reserved IP Address.

As example;
DHCP Reservation… Hostnname… MAC Address …IP Address
…enabled …chillout …13:12:11:0a0:0b:0c …192.168.0.1
…enabled …tarpharazon … a1:b1:c1:01:02:03 …192.168.0.2

These interfaces will always be assigned these IP address and names.

i disabled firewall last night and was able to ping [hostname].local, where i couldnt with the firewall enabled.

hosts file is great if your on static IP/reserved DHCP. it does work the way i want it to, but it’s certainly no replacement for a DNS name resolution though. i’m still playing with the firewall to work out what protocol&ports i need open…

Correct. /etc/hosts is only usefull for fixed UP addresses. I like fixed IP addresses in my LAN (as long as it is not about tens of systems and even then theree are tools to help), better security, administration, etc.

53 no? And I thought you didn’t want to use DNS?

On 2010-07-15 20:26 GMT veehexx wrote:

>
> thanks for a more precise answer.
>
> editing the hosts file (for my immediate intended purpose) isnt a huge
> issue; DHCP reservation on a NAS box. however since i do build PC’s
> for friends/family and rely on VNC/RDP hostnames are easier to use
> than ever changing IP addresses under DHCP. i’ll disable firewall for
> a few moments and see if i can ping local hostnames… and do some
> more digging to find that post you mention, Carlos. im so used to
> windows just working in that reguard, i never thought of the firewall!

I tracked the thread. Subject was “Can not see linux host until i reset
Firewall … why ?”, this month. He had to set «the “netbios
server” in allowed services at the Linux firewall». That should work to
access windows machines by name, at least.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” GM (Minas Tirith))

slip of the finger; correct, i do not want to use DNS. or more specifically, i dont want to setup a dedicated DNS server on my network. netgear DG834g doesnt have any options to change from the way it’s currently setup.

i’ll give the firewall port/service comment a go sometime this weekend…

ok, i’ve got sucessful ping to * hostname.local*
however, im unable to ping hostname

more googling returns avahi causing issues taking over the .local domain, hence why it wont auto resolve hostname to hostname.local.
i’ve removed avahi but i then loose the ability to ping hostname.local due to no firewall port(s) being open.

so, how do i get oSUSE to insert .local into ‘hostname’ only pings? /etc/resolv.conf already has ‘search local’…
is the obvious fix of remove avahi, and then find out what ports zeroconf/bonjour use to manually enter them into firewall the best way?

for the sake of sanity and future reference, you need to allow ‘Zeroconf/bonjour multicast DNS’. this rule appears to be installed with avahi or one of it’s 2 dependance, ‘nss-mdns’ or ‘nss-mdns-32bit’.