View Full Version : getting an ip adress with udhcpc
jackdaniels
18-11-2005, 21:25
Hi All,
I have set a wl500g router set in client mode with the following commands:
wl ap 0
Next i connect to another wl500g router with the following command:
wl join 'SSID'
Now i want an ip adress, a default gateway and dns server etc using udhcpc. How do i do this?
--
greetz Bjorn
HanseHouse
05-12-2005, 00:45
Hi Bjorn,
I suppose eth1 is you WLAN interface, am not sure about that.
First you need to get eth1 out of the bridge:
brctrl delif br0 eth1
Then you can use udhcp:
#!/bin/sh
/sbin/udhcpc -q -n -i eth1 -s /usr/local/sbin/udhcpc.script
When udhcpc got a lease for eth1 it calles the udhcpc.script in which you can compute all parameters received by DHCP.
#!/bin/sh
RESOLV_CONF=/tmp/resolv.conf
case "$1" in
bound|renew)
echo interface $interface up...
ifconfig $interface up
echo set IP $ip $subnet
ifconfig $interface $ip netmask $subnet
echo adding default route $router
route add default gw $router
for ii in $dns; do
echo adding nameserver $ii
echo nameserver $ii >> $RESOLV_CONF
done
# trigger dnsmasq restart
kill -s SIGHUP `pidof dnsmasq`
;;
deconfig)
echo setting interface $interface to 0.0.0.0
ifconfig $interface 0.0.0.0
#ifconfig $interface down
echo deleting $RESOLV_CONF
echo -n > $RESOLV_CONF
kill -s SIGHUP `pidof dnsmasq`
;;
esac
Best regards,
Matthias