HOWTO: Manually Ask my DHCP Server for an IP Address?
In the Windows world, most users are comfortable with either using the Windows networking control panel applet or the command line tool ipconfig (or winipcfg depending on your Windows version).
In GNU/Linux there are three major dhcp clients:
- dhclient
- pump
- dhcpd
You’ll have to experiment with which one of these (or more than one) your distro comes with and use the man system to figure out the finer points of using them. As a quick reference, you can try the following (substituting eth1 for your interface):
- pump -i eth1
- dhclient eth1
I do not have dhcpd installed on my system so I won’t speculate how to use that. Man dhcpd if that’s the client you wish to use.
Related Stories
POSTED IN: How To
12 opinions for HOWTO: Manually Ask my DHCP Server for an IP Address?
stranger
Oct 13, 2005 at 8:14 am
It’s ‘dhcpcd’. ‘dhcpd’ is the server daemon; dhcpcd is one of the many implementations of the client.
Jon
Oct 13, 2005 at 8:32 am
Wha??
I’ll have to try this when I get back to my GNU/Linux box. I use dhclient right now, but I swear back when I used it, I just typed ‘dhcpd’ and off it went.
I’ll check and correct the article if required.
Thanks for the info!
Jon
Oct 13, 2005 at 7:35 pm
I just checked on my Kanotix (Debian) box at home. When I type ‘dhcpcd’ I get nothing. When I type ‘dhcpd’ I get the expected output.
So…I’m lost. Can you explain what you mean by the ‘dhcpcd’ comment?
Thanks!
New Linux User » HOWTO: Use Ifconfig.
Nov 9, 2005 at 8:12 pm
[…] Requesting an IP address Managing a wireless network card This entry was posted on Wednesday, November 9th, 2005 and is filed under How To. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site. […]
phily
Nov 29, 2005 at 1:55 pm
I just tried command ‘dhclient’.
So, I have to confirm that
I had to do it as root.
It worked both /sbin/dhclient eth0 and /sbin/dhclient, i.e. both of them returned the same results.
Greetings
phil
ps. Is it possible to get know the outside IP. I got LAN, so dhclient command returns my IP and some router where my IP is obtained from. Of course I know IP of my server, but is any command that can retrive this information?
Jon
Nov 29, 2005 at 2:09 pm
Hi Phil,
Thanks for the information. I think the two differences between dhclient eth0 and just dhclient is that dhclient alone will try to obtain an IP address for ALL your network interfaces (not the lo localhost, though). So, if you’re like me and only have one network card, then both commands will indeed return the same results.
Good question about the outside IP. I don’t know if that information is generally available to inside clients. I’ll see what I can find out.
geoff
Nov 29, 2005 at 7:55 pm
You could always do this:
$ curl -s http://checkip.dyndns.org/ | grep -i addressDirty, but quick and easy.
phily
Nov 30, 2005 at 9:36 am
Hi Geoff,
Thanks. It is a good one, but the address is retrieved from outside… I want to do it from inside, i.e. to retrieve IP from my server…
Greetings
phily
geoff
Dec 1, 2005 at 12:08 am
From Shields Up!.
Jon
Dec 1, 2005 at 5:40 am
Hi Geoff,
That’s kind of what I was pondering in my comment above. However, I’ll bet you that a clever hacker can figure out how to get it.
Since my external IP is shown on my router’s admin page, it seems to me that information could be scraped off it and used.
It’s an interesting thought.
geoff
Dec 1, 2005 at 4:17 pm
I guess, as above, you could curl the router’s HTML page and grep for the particular line. That would, theoretically, be obtaining the external address from within the server.
$ curl -s http://192.168.0.1/st_device.html | grep -i “IP address”This should work for me, except that I cannot get passed the authorization step (even using -u in curl).
Jon
Dec 1, 2005 at 8:56 pm
For my Linksys, a url like:
http://username:password@192.168.100.1 logs me in.
Actually, to be more specific, I don’t have a username, just a password. Therefore:
http://null:password@192.168.200.1 works for me.
Have an opinion? Leave a comment: