LinuxQuestions.org
Visit Jeremy's Blog.
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 10-21-2005, 08:37 AM   #1
johnnybhoy67
Member
 
Registered: Sep 2004
Distribution: Knoppix 4.0.2
Posts: 54

Rep: Reputation: 15
How to set up DNS via command line?


Hi All,

I can set up IP address and mask etc using ifconfig on command line but do not know how to set up name server info etc.

can anyone point me in teh right direction please?

Cheers

J
 
Old 10-21-2005, 08:59 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Are you asking how to create a DNS server so that other machines can use yours for resolving names or are you just asking how to allow yours to resolv names from an existing DNS server?

The latter is fairly simple.

Just edit /etc/resolv.conf and add entries for your nameserver(s):
nameserver xxx.xxx.xxx.xxx

Where xxx.xxx.xxx.xxx is the IP address of the name server.

If you have more than one name server you just add another line below the first one using the same format.

Also if this is an internal LAN (say at your office) where most hosts have the samin domain you can add a search string at the beginning of the file:
search domain1.com domain2.net dmz.domain1.com

The above would let you just type "host" or "dig" followed by a host name without requiring the Fully Qualified Domain Name (FQDN).

www.google.com is an FQDN where "google.com" is a domain.

Say you had a host with an FQDN of somehost.dmz.domain1.com. Without the search string you have to type:
host somehost.dmz.domain1.com

With the search string you only have to type:
host somehost
as it will try somehost.domain1.com then somehost.domain2.net then somehosts.dmz.domain1.com.

P.S. Verify your /etc/nsswitch.conf file has a line like:
hosts: files dns
This line tells it to lookup hosts first in your local /etc/hosts file and THEN dns. You don't have to put it in this order but most people do. The important thing is to have "dns" in there otherwise it won't use /etc/resolv.conf.

Last edited by MensaWater; 10-21-2005 at 09:01 AM.
 
Old 10-21-2005, 08:59 AM   #3
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,221
Blog Entries: 1

Rep: Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075
Edit /etc/resolv.conf and add line(s) like this:
Code:
nameserver xx.xx.xx.xx
 
Old 10-21-2005, 09:04 AM   #4
johnnybhoy67
Member
 
Registered: Sep 2004
Distribution: Knoppix 4.0.2
Posts: 54

Original Poster
Rep: Reputation: 15
is there any way to do it without editing this file as I'm running a script on a live CD??

Cheers

J
 
Old 10-21-2005, 09:15 AM   #5
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,221
Blog Entries: 1

Rep: Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075
Code:
echo "nameserver xx.xx.xx.xx" >> /etc/resolv.conf
 
Old 10-21-2005, 09:59 AM   #6
johnnybhoy67
Member
 
Registered: Sep 2004
Distribution: Knoppix 4.0.2
Posts: 54

Original Poster
Rep: Reputation: 15
AHA you the man bathory. I should have thought of that!!!!

Cheers

J
 
  


Reply


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
Command line DNS settings nateDiggsCSU Linux - Software 1 08-28-2004 04:29 PM
How to set Gateway by command line vanhelsing Linux - Networking 1 07-17-2004 11:42 AM
How to set the $PATH on command line? huangyanfeng Programming 3 11-07-2003 12:59 AM
How do i set up svga for command line greendusk Linux - Newbie 2 09-27-2003 09:17 AM
How do i set my command line resolution greendusk Linux - General 1 09-26-2003 05:14 PM

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

All times are GMT -5. The time now is 04:59 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