Dhcp through ifconfig

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

Misha
Location: Florence.
Posts: 73
Joined: Mon Nov 22, 2004 4:15 pm

Dhcp through ifconfig

Tue Aug 09, 2005 4:24 pm

By means of ifconfig I can safely set MAC address, Ip address, broadcast netmask: problem arise when dhcp enabling is tried...
Command: "ifconfig eth0 dynamic up" returns no error (even with LAN cable disconnected !), and following "ifconfig eth0" returns:

eth0 Link encap:Ethernet HWaddr 12:34:56:78:9A:BC
inet addr:192.168.1.71 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST DYNAMIC MTU:1500 Metric:1
RX packets:43 errors:0 dropped:0 overruns:0 frame:0
TX packets:17 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
Interrupt:24 Base address:0xc000

where the DYNAMIC option is correctly set.


However the former IP address is still present.
Of course my intranet has a dhcp server which works perfectly.

The kernel image (linux-2.4.27-vrs1) has dhcp support enabled.
bootp support disabled.

After one day of self help, I beg your help...
Any hints ?

Thank you for your attention.
Misha
Location: Florence.
Posts: 73
Joined: Mon Nov 22, 2004 4:15 pm

Solution found...

Wed Aug 10, 2005 2:53 pm

Strangely enough the 'dynamic' option for ifconfig is useless...
for my own ifconfig at least...

The proven way to enable dhcp is to retrieve somewhere the dhcpcd daemon (ex http://www.wearablegroup.org/software/ramdisk/)
store it in /sbin, then and issue:

dhcpcd -t 10 -h hostname

to search the dhcp server for at most 10 second, giving it the dhcp client device hostname, in case the server can manage DNS...

How do an application knows that a dhcp server is available ?

sprintf(syscmd,"dhcpcd -t 10 -h hostname");
system(syscmd);

Yes, if the time elapsed for the system command execution is greater of the timeout, then the server is not available..
but I wish I could find a more specific method...

I hope this can help someone to spare time.
Onitake
Location: Switzerland
Posts: 18
Joined: Fri Mar 11, 2005 2:46 pm

Re: Solution found...

Mon Aug 22, 2005 1:35 pm

Misha wrote:Strangely enough the 'dynamic' option for ifconfig is useless...
for my own ifconfig at least...
not strange at all, because the kernel does not implement dhcp (and all ifconfig does is sending commands to the kernel).
to use dhcp, you always need a dhcp client (daemon). besides dhcpcd, i also know of dhclient, but dhcpcd is better.

Return to “LINUX”

Who is online

Users browsing this forum: No registered users and 2 guests