LinuxQuestions.org
Review your favorite Linux distribution.
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 01-07-2015, 02:07 PM   #1
SpaceBoB
LQ Newbie
 
Registered: Mar 2013
Posts: 10

Rep: Reputation: Disabled
Why won't my BIND / Apache configuration work?


Hey!
I am trying to set up a BIND configuration with an Apache webserver. What I am trying to achieve is to by using the URL www.exampler.net access the content that can be found on my Apache webserver's /var/www/html folder. I am doing this on one machine which has the IP address 192.168.1.4.
When I dig www.exampler.net while my Wired connection is on, it will only find Google's nameservers, but why I turn off my Wired connection it will instantly find my ns1.exampler.net. Why is that?
Furthermore by writing www.exampler.net into the browser it won't redirect me to my local website which can be found in /var/www/html but by writing 192.168.1.4 i it will.

/etc/bind/named.conf.local
Code:
zone "exampler.net"{
        type master;
        file "/etc/bind/zones/db.exampler.net";
};
/etc/bind/zones/db.exampler.net

Code:
;
; exampler.net = domain name
;
$TTL    604800
exampler.net.   IN      SOA     ns1.exampler.net. admin.localhost. (
                              2         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
; name servers
exampler.net.   IN      NS      ns1.exampler.net.

; ip addresses
ns1     IN      A       192.168.1.4
www     IN      A       192.168.1.4
/etc/apache2/sites-available/000-default.conf

Code:
<VirtualHost *:80>
        ServerName exampler.net:80
        ServerAlias www.exampler.net

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I am using Ubuntu 14.04.1. I want to do this only locally, so that the hosts on my LAN server can use the given domain name to access the website that can be found on my Apache/NS server. Thanks in advance!

Last edited by SpaceBoB; 01-07-2015 at 02:08 PM.
 
Old 01-07-2015, 10:03 PM   #2
ceyx
Member
 
Registered: May 2009
Location: Fort Langley BC
Distribution: Kubuntu,Free BSD,OSX,Windows
Posts: 342

Rep: Reputation: 59
The Bind and Apache setup looks fine to me.

Lookes like a DNS issue.
Is your DNS server listed anywhere ? Bet it is not, or that google is listed before your BIND server, so google is searched before your own DNS is searched.
If you give your wired connection a static IP, then you can list the IP of your bind server ahead of google's server.

There are several ways to kill this cat, but the above will do it. Or you could try putting the IPs of your local network in the /etc/hosts file.
 
Old 01-08-2015, 07:19 AM   #3
SpaceBoB
LQ Newbie
 
Registered: Mar 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
I put a record into the hosts file:
192.168.1.4 ns1.kvalami.net

Still not working, so I think this is not enough.
 
Old 01-09-2015, 03:09 PM   #4
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Rep: Reputation: 103Reputation: 103
Is your dns public? Meaning can your domain be accessed by anyone, or is it only local? If it's local, then you need to edit /etc/resolv.conf, where you can add your dns server. So add the following line before the other nameserver lines:

nameserver 192.168.1.4

Editing the hosts file like that won't do the trick, it will only make an association between that particular IP and exactly ns1.kvalami.net

Moreover, try netstat -tulpn | grep 53 and tell us your output. Is port udp 53 (and tcp too, but especially udp) open? If it's not, then there's a problem with your dns server.

Last edited by vincix; 01-09-2015 at 03:10 PM.
 
Old 01-10-2015, 02:28 PM   #5
SpaceBoB
LQ Newbie
 
Registered: Mar 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by vincix View Post
Is your dns public? Meaning can your domain be accessed by anyone, or is it only local? If it's local, then you need to edit /etc/resolv.conf, where you can add your dns server. So add the following line before the other nameserver lines:

nameserver 192.168.1.4

Editing the hosts file like that won't do the trick, it will only make an association between that particular IP and exactly ns1.kvalami.net

Moreover, try netstat -tulpn | grep 53 and tell us your output. Is port udp 53 (and tcp too, but especially udp) open? If it's not, then there's a problem with your dns server.
Thanks! You are correct. But as I am using ubuntu, I needed to add my DNS server to the NetworkManager's configuration file. On debian systems as I understand the resolv.conf file is not editable.
 
Old 01-11-2015, 08:29 AM   #6
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Rep: Reputation: 103Reputation: 103
I see that in ubuntu you've got three files related to dns. /etc/resolvconf/resolv.conf/base - which is the main dns configuration file, head and tail. If your DNS indeed isn't not publicly accessible, then you can add it to tail (it appends it, in contrast to head, which prepends it, meaning it takes precedents over the other namservers).

So add the line
nameserver 192.168.1.4
in the tail and then run sudo resolvconf -u.

Maybe this is more helpful.

[later edit]
Obviously, you need to configure those particular workstation to which you want http access. So you need to change (add) the nameservers there. But it depends on the operating system how you actually do that and what priority you'll give those dns server (which is first).

Anyway, do check and see (netstat) if your server is listening to port 53. You might also add in your main dns configuration file:
Code:
options {
listen-on port 53 { any }; 
allow-query { any; };
}
Or, instead of any, whatever ip addresses/subnet you want to listen on.
For instance, you might want to allow-queries only from the local network, so then:

allow-query { 192.168.1.0/24; };

Be very careful about the syntax. It's so easy to make mistakes when it comes to bind. But that's why you've got utilities like named-checkconf.

Last edited by vincix; 01-11-2015 at 08:43 AM.
 
  


Reply

Tags
apache, bind, dns, ubuntu, webserver


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Apache won't start, says it can not bind to address thllgo Linux - Software 11 01-30-2012 04:40 PM
Why won't Apache work! taigon Linux - Server 4 09-11-2006 11:39 PM
Bind - Why won't my LAN domain work? jimieee Linux - Networking 1 05-09-2005 12:07 PM
cgi won't work in apache davidk Linux - Networking 9 10-16-2004 07:09 AM
Apache and BIND configuration help Darshu55 Linux - Newbie 3 11-18-2003 06:54 PM

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

All times are GMT -5. The time now is 10:09 AM.

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