Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 06-09-2003, 06:03 PM   #1
Senior Member
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Rep: Reputation: 58
How to find out dynamic IP address in a script?

I am writing a script, which should somehow find out what dynamic IP address is assigned to the local machine.
Is there an easy and generic way (say... checking an environment variable?) to find it?

I know ifconfig shows the IP address, but I found it hard to find a common way to grep it out, since the list has a different structure on the two unixes I have access to.
I also know that it may be found (and easily grepped out) in /var/log/messages, but I do not know if it is always there.
So, is there an other solution?
Old 06-09-2003, 07:13 PM   #2
Registered: Feb 2002
Location: Fairfax, VA
Distribution: RedHat 8, Mandrake9.1, Slack9
Posts: 456

Rep: Reputation: 31
you can parse the dhcpclient-ethX.leases file. if the client gets an ip it will be written in that file.

the file is in /var/lib/dhcp/


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
Getting Base Address of Dynamic Library Damaged Soul Programming 11 12-13-2010 01:28 PM
Can anyone help me to build a DNS with a dynamic IP address babyboss Linux - Networking 10 08-10-2005 07:53 AM
Fix ip address vs Dynamic ip address yenonn Linux - Networking 5 04-13-2004 07:25 AM
Script to capture dynamic IP address scon Linux - General 4 02-21-2003 03:30 AM
dynamic IP address acid_kewpie Linux - Networking 4 09-13-2001 02:53 AM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:30 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration