Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - General > LinuxAnswers Discussion
User Name
LinuxAnswers Discussion This forum is to discuss articles posted to LinuxAnswers.


  Search this Thread
Old 02-09-2010, 02:30 PM   #1
LQ Newbie
Registered: Mar 2009
Posts: 4

Rep: Reputation: 3
How to make a linux machine with a static IP address dynamically add its hostname to

A new la entry has been added:

How to make a linux machine with a static IP address dynamically add its hostname to DNS

I had searched for this answer for hours and finally was able to cobble together enough pieces of the puzzle to compile this "how to" document. There are many references to adding the DHCP_HOSTNAME parameter to the ifcfg-ethX file. While that approach will work for DHCP it will not for statically assigned IP addresses.

Please note: This "how to" only addresses registering a statically assigned IP dynamically with DNS - WINS/NETBIOS is not used. In this example I am using non-secure dynamic updates to a Windows 2003 DNS server that is active directory enabled.
Old 02-15-2010, 08:46 PM   #2
Registered: Sep 2008
Location: MN
Distribution: Gentoo, Fedora, Suse, Slackware, Debian, CentOS
Posts: 98
Blog Entries: 1

Rep: Reputation: 19
Why using so many applications to get the IP Address?
You are using 4 applications when you do (single line):
ADDR=`/sbin/ifconfig eth0 | grep 'inet addr' | awk '{print $2}' | sed -e s/.*://`
Why not only use 2 applications and do (single line also):
ADDR=`/sbin/ifconfig eth0 | sed -n '/inet addr:/s=[^:]*:\([^ ]*\).*=\1=;2p'`
To handle an unassigned address:
ADDR=`/sbin/ifconfig eth0 | sed -n '/inet addr:/p' | sed 's=[^:]*:\([^ ]*\).*=\1='`

Last edited by allanf; 02-15-2010 at 09:01 PM. Reason: Changed to handle no IP address assigned handling.


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
How to add multiple IP address on linux machine different IP range? arfal Linux - Server 4 12-08-2009 10:26 PM
How to make my public ip address as static smrutiranjan Linux - Networking 29 07-30-2009 11:44 PM
Cannot access my linux machine when i type the hostname instead of ip address dcordina Linux - Networking 1 04-07-2009 06:43 AM
Setting a static IP address, but dynamically obtaining DNS config from a router bgoodr Linux - Hardware 3 09-28-2008 12:33 PM
Difference in MySQL packages: glib(static) and Dynamically link Swakoo Linux - General 2 08-01-2007 10:36 PM > Forums > Linux Forums > Linux - General > LinuxAnswers Discussion

All times are GMT -5. The time now is 01:30 AM.

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