Problem connecting to local machine using the hostname

You have a problem with Salix? Post here and we'll do what we can to help.
Post Reply
User avatar
Bart
Posts: 41
Joined: 31. May 2011, 17:41

Problem connecting to local machine using the hostname

Post by Bart »

Hi all,
I'm trying to access to my linux server using the hostname of the machine. I am using Windows and samba. I access through ip regularly but with the hostname, connection fails. What could it be?
This is my simple firewall:

Code: Select all

IPT=/usr/sbin/iptables


 $IPT -t filter -F
 $IPT -t filter -X
 $IPT -t filter -Z
 $IPT -t filter -P INPUT DROP
 $IPT -t filter -P FORWARD DROP
 $IPT -t filter -P OUTPUT DROP

 /bin/echo "1" > /proc/sys/net/ipv4/ip_forward
 /bin/echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
 /bin/echo "1" > /proc/sys/net/ipv4/conf/all/rp_filter
 /bin/echo "0" > /proc/sys/net/ipv4/conf/all/accept_redirects
 /bin/echo "1" > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
 /bin/echo "1" > /proc/sys/net/ipv4/conf/all/log_martians
 /bin/echo '1' > /proc/sys/net/ipv4/tcp_syncookies
 /bin/echo '0' > /proc/sys/net/ipv4/conf/all/accept_source_route

 $IPT -t filter -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
 $IPT -t filter -A OUTPUT -m state --state ESTABLISHED,RELATED,NEW -j ACCEPT
 $IPT -t filter -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

 #SAMBA
 $IPT -t filter -A INPUT -p tcp --dport 139 -j ACCEPT
 $IPT -t filter -A INPUT -p tcp --dport 445 -j ACCEPT
Thanks in advance.
Shador
Posts: 1295
Joined: 11. Jun 2009, 14:04
Location: Bavaria

Re: Problem connecting to local machine using the hostname

Post by Shador »

Is there even a DNS entry for it?

Code: Select all

nslookup <hostname>
Also it would be useful if you're more clear how you're trying to access it (samba share from windows explorer?) and what exactly you mean by failing.
Image
User avatar
Bart
Posts: 41
Joined: 31. May 2011, 17:41

Re: Problem connecting to local machine using the hostname

Post by Bart »

I have installed bind and now nslookup return this code:

Code: Select all

nslookup maggie
Server:         8.8.8.8
Address:        8.8.8.8#53

** server can't find maggie: NXDOMAIN
Yes, I'm trying to access with samba on windows explorer (typing \\Maggie in the address bar), but after few seconds appears the following error: "Maggie can not access."
Using ip address everything works fine.

This is my /etc/hosts:

Code: Select all

#
# hosts         This file describes a number of hostname-to-address
#               mappings for the TCP/IP subsystem.  It is mostly
#               used at boot time, when no name servers are running.
#               On small systems, this file can be used instead of a
#               "named" name server.  Just add the names, addresses
#               and any aliases to this file...
#
# By the way, Arnt Gulbrandsen <agulbra@nvg.unit.no> says that 127.0.0.1
# should NEVER be named with the name of the machine.  It causes problems
# for some (stupid) programs, irc and reputedly talk. :^)
#

# For loopbacking.
127.0.0.1               localhost
127.0.1.1               maggie
10.5.1.20               maggie.localdomain maggie

# End of hosts.
Thanks.
Shador
Posts: 1295
Joined: 11. Jun 2009, 14:04
Location: Bavaria

Re: Problem connecting to local machine using the hostname

Post by Shador »

Bart wrote:127.0.1.1 maggie
Why this? 127.0.1.1?
Bart wrote:This is my /etc/hosts:
Your hosts is useless for all but that one machine, especially for windows machines. Unless of course you were running dnsmasq and registered it as your DNS.
Bart wrote:** server can't find maggie: NXDOMAIN
It doesn't work because there's no DNS record in any of your DNS servers for that machine.
Image
User avatar
Bart
Posts: 41
Joined: 31. May 2011, 17:41

Re: Problem connecting to local machine using the hostname

Post by Bart »

Can you tell me what should I do please? Thanks
User avatar
Bart
Posts: 41
Joined: 31. May 2011, 17:41

Re: Problem connecting to local machine using the hostname

Post by Bart »

Up.
User avatar
Ekimino
Posts: 5
Joined: 8. Apr 2012, 07:30

Re: Problem connecting to local machine using the hostname

Post by Ekimino »

That is probably because your windows computer doesn't know what IP Mary is, it should be added in the dns, or for a cheap workaround.

Edit the \system32\drivers\etc\hosts windows file, and add the following line

<IP.IP.IP,IP> <Name you wish>

example: 192.168.1.2 Mary

Edit: Check your network settings, to see which DNS server you are using, if It's internal(ex:router/gateway) you could add the DNS entries to the router, I don't really know if all the routers support it. If It's a small personal network you could just edit the hosts files on the machines.

Linux "DNS" file: /etc/resolv.conf
Linux Hosts file: /etc/hosts

BTW: Learn some DNS theory, it won't do no harm, and you'll see one of the pillars of the internet once you understand it.
Post Reply