LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-26-2009, 12:39 PM   #1
dils
LQ Newbie
 
Registered: Mar 2009
Posts: 11

Rep: Reputation: 0
DNS setup


hello there
well i have been deploying a linux box as a router for a private network. i have been using Fedora Core 9 as linux distribution. My NAT and DHCP server is already working fine. but now i have a problem setting up a DNS which should point to the actual DNS server of my ISP. the thing is that i don't know how to set up a DNS server. Anyone out there could help me with this. i would be very grateful to u.

cheers
dils
 
Old 03-26-2009, 02:41 PM   #2
oldtincup
LQ Newbie
 
Registered: Mar 2006
Posts: 11

Rep: Reputation: 1
I don't know how much help I'll be. I have only setup a DNS server in SuSE, and that was years ago.

I am not sure why you want a DNS server. Usually when you connect to your ISP it should setup resolv.conf with the ISP's DNS info.

Although, maybe you want to setup a caching DNS server? This would speed up name resolution for frequently visited sites.

Or do you have a home network that you want to resolve names for and just pass the rest to your ISP?
 
Old 03-26-2009, 02:59 PM   #3
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Debian
Posts: 1,265

Rep: Reputation: 98
Smile

Quote:
Originally Posted by dils View Post
hello there
well i have been deploying a linux box as a router for a private network. i have been using Fedora Core 9 as linux distribution. My NAT and DHCP server is already working fine. but now i have a problem setting up a DNS which should point to the actual DNS server of my ISP. the thing is that i don't know how to set up a DNS server. Anyone out there could help me with this. i would be very grateful to u.

cheers
dils
Hey,

I have made this script to configure DNS on RHEL machines, may be it works for others too. I am not very sure about this. I have tested it, works fine.

Anyways, here is it. You just need to given a hostname to your linux box like server.vikas.com, and everything else will be handled by the script.

After running the script, run these commands :--
Code:
bind-chroot-admin -d; bind-chroot-admin -e; service named restart

SCRIPT

Code:
mkdir /tmp/my_logs/
exec 2>/tmp/my_logs/dns_error_logs

IP=$(ifconfig eth0 | grep "inet addr" | sed -e 's/^[ \t]*//' | awk -F"Bcast" '{print $1}' | awk -F":" '{print $2}')

IP1=$( echo $IP |  awk -F "." '{print $1}' )
IP2=$( echo $IP |  awk -F "." '{print $2}' )
IP3=$( echo $IP |  awk -F "." '{print $3}' )
IP4=$( echo $IP |  awk -F "." '{print $4}' )

echo -n "Please enter your desired hostname (in format like server.example.com) - "
read hname

hname1=$( echo $hname |  awk -F "." '{print $1}' )
hname2=$( echo $hname |  awk -F "." '{print $2}' )
hname3=$( echo $hname |  awk -F "." '{print $3}' )

cp -p /etc/sysconfig/network	/etc/sysconfig/network.BACKUP
cp -p /etc/resolv.conf		/etc/resolv.conf.BACKUP

sed -i '/HOSTNAME/d' /etc/sysconfig/network
echo "HOSTNAME=$hname" >> /etc/sysconfig/network
hostname $hname

grep $IP /etc/resolv.conf > /dev/null
if [ $? -eq 1 ]
then
echo "nameserver $IP" >> /etc/resolv.conf
fi

# Install needed packages with dependecies
yum -y remove bind* caching-nameserver* system-config-bind*
rm -rf /var/named rm -f /etc/named*
yum -y install bind* caching-nameserver* system-config-bind*
chkconfig named on

# MAKING SKELETON /etc/named.conf
echo "options {" >> /etc/named.conf
echo "listen-on port 53 { 127.0.0.1; };" >> /etc/named.conf
echo "listen-on-v6 port 53 { ::1; };" >> /etc/named.conf
echo "directory       "/var/named";" >> /etc/named.conf
echo "dump-file       "/var/named/data/cache_dump.db";" >> /etc/named.conf
echo "statistics-file "/var/named/data/named_stats.txt";" >> /etc/named.conf
echo "memstatistics-file "/var/named/data/named_mem_stats.txt";" >> /etc/named.conf
echo "query-source    port 53;" >> /etc/named.conf
echo "query-source-v6 port 53;" >> /etc/named.conf
echo "allow-query     { localhost; };" >> /etc/named.conf
echo "};" >> /etc/named.conf
echo -e -n "\n" >> /etc/named.conf
echo -e -n "\n" >> /etc/named.conf
echo "zone "localhost" IN {" >> /etc/named.conf
echo "type master;" >> /etc/named.conf
echo "file "localhost.zone";" >> /etc/named.conf
echo "allow-update { none; };" >> /etc/named.conf
echo "};" >> /etc/named.conf
echo -e -n "\n" >> /etc/named.conf
echo "zone "0.0.127.in-addr.arpa" IN {" >> /etc/named.conf
echo "type master;" >> /etc/named.conf
echo "file "named.local";" >> /etc/named.conf
echo "allow-update { none; };" >> /etc/named.conf
echo "};" >> /etc/named.conf

# Correcting entries in /etc/named.conf where double quotes (") are not inserted
sed -i 's/localhost IN/"localhost" IN/' /etc/named.conf
sed -i 's/localhost.zone/"localhost.zone"/' /etc/named.conf
sed -i 's/0.0.127.in-addr.arpa/"0.0.127.in-addr.arpa"/' /etc/named.conf
sed -i 's/named.local/"named.local"/' /etc/named.conf
sed -i 4's|/var/named|"/var/named"|' /etc/named.conf
sed -i 5's|/var/named/data/cache_dump.db|"/var/named/data/cache_dump.db"|' /etc/named.conf
sed -i 6's|/var/named/data/named_stats.txt|"/var/named/data/named_stats.txt"|' /etc/named.conf
sed -i 7's|/var/named/data/named_mem_stats.txt|"/var/named/data/named_mem_stats.txt"|' /etc/named.conf


cp -p /etc/named.conf /etc/named.conf_skel

# Putting new entries in /etc/named.conf
sed -i 2's/127.0.0.1/'$IP1'.'$IP2'.'$IP3'.'$IP4'/' /etc/named.conf
sed -i '/allow-query/d' /etc/named.conf
sed -i '10i\allow-query     { IP1.IP2.IP3.0/24; };' /etc/named.conf
sed -i 's/IP1/'$IP1'/' /etc/named.conf
sed -i 's/IP2/'$IP2'/' /etc/named.conf
sed -i 's/IP3/'$IP3'/' /etc/named.conf
sed -i 14's/localhost/'$hname2'.'$hname3'/' /etc/named.conf
sed -i 's/localhost.zone/'$hname2'.fwd/' /etc/named.conf
sed -i 's/0.0.127.in-addr.arpa/'$IP2'.'$IP1'.in-addr.arpa/' /etc/named.conf
sed -i 's/named.local/'$hname2'.rev/' /etc/named.conf

# Copy sample files
cp -p /var/named/localhost.zone /var/named/$hname2.fwd	
cp -p /var/named/named.local /var/named/$hname2.rev

# New Reverse Lookup file
sed -i 's/localhost/'$hname'/'    /var/named/$hname2.rev
sed -i 2's/localhost/'$hname'/'    /var/named/$hname2.rev
sed -i 9's/1/'$IP4'.'$IP3'/'      /var/named/$hname2.rev
sed -i 9's/'$hname'./'$hname1'/'  /var/named/$hname2.rev

# New Forward Lookup file
head -2 /var/named/$hname2.rev > /var/named/$hname2.fwd.tmp1
cat /var/named/$hname2.fwd.tmp1 /var/named/$hname2.fwd > /var/named/$hname2.fwd.tmp2
cp -p /var/named/$hname2.fwd.tmp2 /var/named/$hname2.fwd
rm -f /var/named/$hname2.fwd.tmp*
sed -i 11's/@/'$hname'./' /var/named/$hname2.fwd
sed -i 's/IN A/'$hname1' &/'  /var/named/$hname2.fwd
sed -i 's/127.0.0.1/'$IP1'.'$IP2'.'$IP3'.'$IP4'/'  /var/named/$hname2.fwd
sed -i '/IN AAAA/d'  /var/named/$hname2.fwd
sed -i '13d' /var/named/$hname2.fwd
grep $IP1 /var/named/$hname2.fwd | sed -e 's/^[ \t]*//' >> /var/named/$hname2.fwd
sed -i '12d' /var/named/$hname2.fwd
sed -i '3d' /var/named/$hname2.fwd
sed -i '3d' /var/named/$hname2.fwd

echo -e -n "\t\t\t\t Reboot or logoff the machine to apply the changes\n and run bind-chroot-admin -d; bind-chroot-admin -e; service named restart"
 
Old 03-27-2009, 01:00 PM   #4
dils
LQ Newbie
 
Registered: Mar 2009
Posts: 11

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by oldtincup View Post
I don't know how much help I'll be. I have only setup a DNS server in SuSE, and that was years ago.

I am not sure why you want a DNS server. Usually when you connect to your ISP it should setup resolv.conf with the ISP's DNS info.

Although, maybe you want to setup a caching DNS server? This would speed up name resolution for frequently visited sites.

Or do you have a home network that you want to resolve names for and just pass the rest to your ISP?
@
well for my project, i need to provide internet for a private network. hence i did nat. but my clients are not getting an internet connection as i do not have a DNS server. If i am pinging an external IP address, am receiving data, meaning NAT configuration is good...

@vikas
well will try that and let u know if it worked. thx a lot for ur help
 
Old 03-30-2009, 08:27 AM   #5
oldtincup
LQ Newbie
 
Registered: Mar 2006
Posts: 11

Rep: Reputation: 1
Quote:
Originally Posted by dils View Post
@
well for my project, i need to provide internet for a private network. hence i did nat. but my clients are not getting an internet connection as i do not have a DNS server. If i am pinging an external IP address, am receiving data, meaning NAT configuration is good...
In that case you don't need a DNS server. You just need to point your clients to your ISP's DNS server. Since you already have a DHCP server setup the easiest way to do that would be to add a line like this to your dhcpd.conf file:

Code:
option domain-name-servers      ISP's Primary DNS Address, Secondary DNS Address;
 
Old 03-30-2009, 09:23 AM   #6
malekmustaq
Senior Member
 
Registered: Dec 2008
Location: /root
Distribution: Slackware & BSD
Posts: 1,206

Rep: Reputation: 229Reputation: 229Reputation: 229
dils:

There is an easily configurable dns/router daemon freely available in linux. Check if you have it already in your system:

/usr/doc/dnsmasq-2.46/setup.html

try to find out if dnsmasq can meet your need.

goodluck

hope this helps.
 
Old 03-31-2009, 11:54 AM   #7
dils
LQ Newbie
 
Registered: Mar 2009
Posts: 11

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by malekmustaq View Post
dils:

There is an easily configurable dns/router daemon freely available in linux. Check if you have it already in your system:

/usr/doc/dnsmasq-2.46/setup.html

try to find out if dnsmasq can meet your need.

goodluck

hope this helps.
@vikas
the code u gave me did not work... anywayz thxxx for ur help. i appreciate it...
@oldtincup
tried that out... the starting of my dhcp service failed... :(
@malekmustaq
is it a seperate package to be installed or it comes with the DNS bind package??
 
Old 03-31-2009, 12:13 PM   #8
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Debian
Posts: 1,265

Rep: Reputation: 98
Question

Quote:
Originally Posted by dils View Post
@vikas
the code u gave me did not work... anywayz thxxx for ur help. i appreciate it...
What problems are you facing while running the script. It runs on RHEL 5, RHEL 4. I have tested it many times.

Do you have yum configured ?? my script needs yum to be installed.

Last edited by vikas027; 03-31-2009 at 12:17 PM.
 
Old 04-01-2009, 11:09 AM   #9
dils
LQ Newbie
 
Registered: Mar 2009
Posts: 11

Original Poster
Rep: Reputation: 0
well thnk i got the problem... was just that yum was not configured on my machine :S
thxx everyone who replied to the thread
 
  


Reply

Tags
dns, router, set


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
help needed to setup a DNS server can anyone say how to configure a DNS server subha Linux - Networking 4 04-27-2012 11:50 PM
DNS Setup Yomaoni Linux - General 7 03-18-2008 12:54 PM
DNS setup help tsaravan Linux - Networking 1 11-12-2007 02:10 AM
How do I Setup DNS bsurfin Linux - Newbie 3 05-21-2004 09:05 PM
Dns Setup doggy Linux - Newbie 1 04-30-2004 07:12 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration