Page 1 of 1
[Solved] dhcpcd info file
Posted: 06 Jan 2012, 14:21
by banshee22
Hi all,
Is there a way to read dhcpcd result in a file? Something like dhcpcd-<interface>.info where we can read IP, GATEWAY and other informations returned by dhcp server? I found a dhcpcd.eth0.lease file but I'm unable to read it.
Thanks,
Banshee
Re: dhcpcd info file
Posted: 06 Jan 2012, 17:28
by beny
ifconfig and route:
bash-4.1# dhcpcd --help
usage: dhcpcd [-dgknpqwxyADEGHJKLOTV] [-c script] [-f file] [-e var=val]
[-h hostname] [-i classID ] [-l leasetime] [-m metric] [-o option]
[-r ipaddr] [-s ipaddr] [-t timeout] [-u userclass]
[-F none|ptr|both] [-I clientID] [-C hookscript] [-Q option]
[-X ipaddr] <interface>
all command into the console ,have fun
Re: dhcpcd info file
Posted: 06 Jan 2012, 18:52
by Hamza
Code: Select all
ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'
Enjoy!
Re: dhcpcd info file
Posted: 08 Jan 2012, 21:30
by brokenman
Is there a way to read dhcpcd result in a file? Something like dhcpcd-<interface>.info
What information are you looking for exactly?
cat /etc/dhcpcd.conf
Re: dhcpcd info file
Posted: 09 Jan 2012, 09:12
by banshee22
I'm looking for allocated IP address (Hamza gave me a way to find it through ifconfig and awk command), but I can't find gateway address ?
anybody knows if there is a way to read dhcpcd-<interface>.lease file?
Re: dhcpcd info file
Posted: 09 Jan 2012, 10:40
by beny
type in console: route -n
Re: dhcpcd info file
Posted: 09 Jan 2012, 12:20
by brokenman
For me this would be:
Code: Select all
route -n|sed -n 3p|awk '{print$2}'
sed gets the third line down. awk gets the second field with 'space' delimiter.