LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-09-2015, 07:29 PM   #1
rewards
Member
 
Registered: Dec 2010
Posts: 135

Rep: Reputation: 0
Question resolve localhost to IP address


Hello all,

My server name is centos.linux.local. The httpd service is running. I can access the webserver via IP address on the browser 10.0.0.25. But when I type localhost or linux.local or centos.linux.local I get server not found error. Does anyone have any suggestion what I am missing here?

The content of the /etc/hosts file;
[root@centos /]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.25 linux.local

The DNS and named is running also.
[root@centos html]# nslookup centos
Server: 127.0.0.1
Address: 127.0.0.1#53

Name: centos.linux.local
Address: 10.0.0.25


[root@centos html]#
[root@centos html]# nslookup linux.local
Server: 127.0.0.1
Address: 127.0.0.1#53

Name: linux.local
Address: 10.0.0.25

[root@centos html]#

Reverse lookup Zone file located in /var/named
[root@centos named]# vi linux.local.rr.zone
$ORIGIN 25.0.0.in-addr.arpa.
$TTL 86400
@ IN SOA dns1.linux.local. hostmaster.linux.local. (
2001062501 ;serial
21600 ;refresh after 6 hours
3600 ;retry after 1 hour
604800 ;expire after 1 week
86400) ;minimum TTL 1 day

@ IN NS centos.linux.local.

1 IN PTR centos.linux.local.

2 IN PTR centos.linux.local.

3 IN PTR centos.linux.local.

4 IN PTR centos.linux.local.

Forward looku Zone located in /var/named;

$ORIGIN linux.local.
$TTL 86400
@ IN SOA dns1.linux.local. hostmaster.linux.local. (
2001062501 ;serial
21600 ;refresh after 6 hours
3600 ;retry after 1 hour
604800 ;expire after 1 week
86400) ;minimum TTL 1 day

IN NS dns1.linux.local.

IN MX 10 mail.linux.local.

IN A 10.0.0.25

dns1 IN A 10.0.0.25

centos IN A 10.0.0.25

ftp IN A 10.0.0.25

mail IN CNAME centos

www IN CNAME centos

Here is the iptables information;

[root@centos /]# vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 20 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT


Here is the content of resolve.conf file;
[root@centos /]# cat /etc/resolv.conf
nameserver 127.0.0.1
search linux.local

Static IP address information;

[root@centos /]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
UUID=26976c13-ebeb-44f8-a2ce-a1f87ab431d0
ONBOOT=yes
NM_CONTROLLED="no"
BOOTPROTO=none
HWADDR=3C:4A:92:06:C7:AC
IPADDR=10.0.0.25
PREFIX=24
GATEWAY=10.0.0.1
DOMAIN="linux.local"
DNS1=127.0.0.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"

Last edited by rewards; 05-09-2015 at 07:33 PM.
 
Old 05-10-2015, 01:05 PM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,901

Rep: Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318
Quote:
Originally Posted by rewards View Post
Hello all,

My server name is centos.linux.local. The httpd service is running. I can access the webserver via IP address on the browser 10.0.0.25. But when I type localhost or linux.local or centos.linux.local I get server not found error. Does anyone have any suggestion what I am missing here?
Where did you type that text? on what host, using what app .....?
 
Old 05-10-2015, 02:39 PM   #3
rewards
Member
 
Registered: Dec 2010
Posts: 135

Original Poster
Rep: Reputation: 0
When I open a browser firefox or IE. On the browser url. When I type www.linux.local or linux.local
 
Old 05-10-2015, 03:09 PM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,901

Rep: Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318
on the same host or on another one?
 
Old 05-10-2015, 03:12 PM   #5
rewards
Member
 
Registered: Dec 2010
Posts: 135

Original Poster
Rep: Reputation: 0
The Linux OS with Apache web server is on a laptop. I am trying to access it from another computer within the same network LAN. Is there any other configurations needed to be done on the router? In my router there is a section for Tertiary DNS. There is another section in my router called port forwarding/port triggering and services to select such as FTP, HTTP, ICUII, IP Phone, Net Meeting, News etc. Do I have to configure this option? Maybe I am off and I need to do something on the Linux box? Thanks

Last edited by rewards; 05-10-2015 at 04:22 PM.
 
Old 05-10-2015, 11:22 PM   #6
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Blog Entries: 1

Rep: Reputation: 90
Ok.... sounds like you need to set up that other computer (the one that you are using FF or IE on... for sure IE you are not using on gnu/linux) to use the linux server as its DNS server. Plus enable access to dns service on the linux server.

What is the output (on the guindous computer) of this?

Code:
ipconfig /all
 
Old 05-11-2015, 12:40 AM   #7
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,901

Rep: Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318
yes, it looks like you need to configure the DNS service. (just a remark: localhost will never work, do not try that)
 
Old 05-11-2015, 02:58 AM   #8
rewards
Member
 
Registered: Dec 2010
Posts: 135

Original Poster
Rep: Reputation: 0
How do you do it? I mean what and where do I configure the server side? Do I need to do something on the client computer also? I want simply to be able to connect to the local LAN Apache web server using domain name instead of typing IP address at the browser url yet I want to be able to have my regular Internet access also. Is it doable? Where to configure DNS service? On the Linux box?

C:\Users\Test>ipconfig/all

Windows IP Configuration

Host Name . . . . . . . . . . . . : DELL-PC
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No

Wireless LAN adapter Local Area Connection* 12:

Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter
Physical Address. . . . . . . . . : E2-06-E6-D8-E3-8F
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes

Ethernet adapter Bluetooth Network Connection:

Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Bluetooth Device (Personal Area Network)
Physical Address. . . . . . . . . : E0-06-E6-D8-E3-90
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes

Wireless LAN adapter Wi-Fi:

Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Dell Wireless 1704 802.11b/g/n (2.4GHz)
Physical Address. . . . . . . . . : E0-06-E6-D8-E3-8F
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IPv6 Address. . . . . . . . . . . : 2601:9:4f82:30:18b1:9d60:dfd6:db6a(Prefer
red)
IPv6 Address. . . . . . . . . . . : 2601:9:4f82:30:e206:e6ff:fed8:e38f(Prefer
red)
Lease Obtained. . . . . . . . . . : Monday, May 11, 2015 12:25:17 AM
Lease Expires . . . . . . . . . . : Monday, May 11, 2015 12:48:41 AM
Temporary IPv6 Address. . . . . . : 2601:9:4f82:30:45b7:da08:908d:e2bc(Prefer
red)
Link-local IPv6 Address . . . . . : fe80::18b1:9d60:dfd6:db6a4(Preferred)
IPv4 Address. . . . . . . . . . . : 10.0.0.22(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Sunday, May 10, 2015 1:20:19 AM
Lease Expires . . . . . . . . . . : Tuesday, May 12, 2015 12:47:51 AM
Default Gateway . . . . . . . . . : fe80::eafc:afff:fe7a:6772%4
10.0.0.1
DHCP Server . . . . . . . . . . . : 10.0.0.1
DHCPv6 IAID . . . . . . . . . . . : 383780582
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1C-DC-3D-16-E0-DB-55-89-B7-C0

DNS Servers . . . . . . . . . . . : 2001:558:feed::1
2001:558:feed::2
75.75.75.75
75.75.76.76
NetBIOS over Tcpip. . . . . . . . : Enabled
 
Old 05-11-2015, 03:48 AM   #9
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,901

Rep: Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318
the most simple solution would be to edit your hosts file: http://helpdeskgeek.com/windows-7/windows-7-hosts-file/
add the following line at the end:
<ip of your linux server> <name of that host>
 
Old 05-11-2015, 09:38 AM   #10
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Blog Entries: 1

Rep: Reputation: 90
I guess you need to set up your linux server as the DNS server of the guindous client (remember to open access to named on the firewall of the linux server). That should take care of name resolution on the guindous box.
 
Old 05-12-2015, 12:46 PM   #11
MikeDeltaBrown
Member
 
Registered: Apr 2013
Location: Arlington, WA
Distribution: Slackware
Posts: 96

Rep: Reputation: 10
I'm assuming your Linux box's host name is linux and the domain is local (from your hosts file entry).

If so, you've got a number of configuration errors:

your search line in resolv.conf should be:
search local

Your Windows machine's nameservers should be pointing to your Linux box. It appears that you are using DHCP on your router/gateway so you'll have to figure out how to configure that.

Your reverse zone should be:
$ORIGIN 0.0.10.in-addr.arpa.
not
$ORIGIN 25.0.0.in-addr.arpa.
...and also check your named.conf file for the proper matching entry.

In your 'ifcfg-eth0' file, the DOMAIN should be 'local'

Oh, and host names in the forward DNS file should be like 'centos.local'.
That should be a good start....

Last edited by MikeDeltaBrown; 05-12-2015 at 12:48 PM.
 
Old 05-19-2015, 02:40 PM   #12
rewards
Member
 
Registered: Dec 2010
Posts: 135

Original Poster
Rep: Reputation: 0
Thank you all.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How I can resolve the error Postfix? warning: hostname does not resolve to address kanzer Linux - Server 1 03-22-2013 08:56 AM
kernel upgraded, now php_network_getaddresses can't resolve localhost sean.simpson Linux - Server 5 07-19-2012 03:08 PM
localhost bind will not resolve from other clients cwc Linux - Networking 3 01-17-2007 10:06 PM
can't resolve localhost auji Linux - Networking 16 09-29-2005 02:39 PM
postfix can't resolve localhost yapp Linux - Networking 2 12-02-2003 01:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration