Problems with dhcp-client

Hi,

I want to connect my AR300M via a script to a wifi-network and I am having problems on how to propery configure the dhcp-client…

This is how I connect to the network:

`uci set wireless.@wifi-iface[0].mode=sta;

uci set wireless.@wifi-iface[0].network=;

sudo uci set wireless.@wifi-iface[0].wds=;

uci set wireless.@wifi-iface[0].ssid=my_essid;

uci set wireless.@wifi-iface[0].encryption=psk2;

uci set wireless.@wifi-iface[0].key=my_password;

uci set wireless.@wifi-iface[0].proto=dhcp;

/etc/init.d/network restart;

Now I thought that setting “proto” to “dhcp” would automatically start a dhcpclient, but that does not happen.

And if I start one myself with “udhcpc -n -i wlan0” I get an ip and a gateway but it does not configure a nameserver.

So what is the proper way to do this?

(please note that it is intentional that I do NOT issue an uci commit).

You need to configure a network, e.g. wwan and write the proto there

uci set network.wwan=‘interface’

uci set network.wwan.proto=‘dhcp’

uci set wireless.@wifi-iface[0].network=“wwan”;

uci commit

I assume you had a typo in your first line to I tried to add this:

uci set network.wwan.ifname=wlan0

uci set network.wwan.proto=dhcp

uci set wireless.@wifi-iface[0].network=wwan
But it still does not work.

Correction:

Your first line was correct, so I added “uci network.wwan=interface”.

Now I can see that a dhcpclient is started. The problem I have now is that it does not get a lease.

I’ve seen that before when I started the dhcp-client mnually that sometimes it would not get a lease when my laptop would get a lease every time (which makes me believe it’s not the dhcp-server).

What could be the problem here?

uci set network.wwan=interface
uci set network.wwan.proto=dhcp
uci set wireless.@wifi-iface[0].network=wwan
uci set wireless.@wifi-iface[0].device=radio0
… set your other options in wireless
uci commit
/etc/init.d/network restart

This must work

It does work in all network, apart from one where for reasons I cannot figure out I cannot seem to get a lease on my 300M, but can get a lease on my laptop and my phone…

Beats me…

But I can’t be bothered anymore as I made a hack for this one network where I simply assign an ip that I hope no one else is using :slight_smile: