Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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.
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"
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
@
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;
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??
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.