sun-tracker
Posts: 6
Joined: Sun May 25, 2014 11:02 pm

wlan0 always selects same IP regardless of Router Assignment

Sat Aug 02, 2014 12:11 am

Hello all.

Having a strange issue with my wireless connection.

Upon first boot and rpi-config, the dongle I have connected just fine to my wifi network and (for whatever reason) chose the IP of 192.168.1.245. Connectivity is fine (eg web browsing).

I want to give it a static IP of 192.168.1.177, though, BUT I want to do it through my wifi router (Asus RT-N66U). Using the MAC address, I tell the router to assign the Pi a static IP of .177. The router accepts this command and upon reboot of both the router and the pi, the pi will ALWAYS take .245.
With any other mac/device on my network, static assignments work fine. I believe the problem is on the Pi's end -- what am I doing wrong and how can I get the pi to release it's obsession with the .245 IP?

Thanks.

-ST

User avatar
kusti8
Posts: 3439
Joined: Sat Dec 21, 2013 5:29 pm
Location: USA

Re: wlan0 always selects same IP regardless of Router Assign

Sat Aug 02, 2014 12:15 am

Post the contents of /etc/network/interfaces and /etc/wpa_supplicant/wpa_supplicant.conf

Remember to take out info like the SSID and the password.
There are 10 types of people: those who understand binary and those who don't.

sun-tracker
Posts: 6
Joined: Sun May 25, 2014 11:02 pm

Re: wlan0 always selects same IP regardless of Router Assign

Sat Aug 02, 2014 12:40 am

/etc/network/interfaces:

Code: Select all

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
/etc/wpa_supplicant/wpa_supplicant.conf:

Code: Select all

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="OMITTED"
psk="OMITTED"
proto=RSN
key_mgmt=WPA-PSK
pairwise=TKIP
auth_alg=OPEN
}
Thanks for your help!
EDIT: I should add that all of the above was auto-generated by the wireless config GUI in Raspbian. I've not made any changes at all - I wanted the router to assign the IP instead of declaring it within the Pi.

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: wlan0 always selects same IP regardless of Router Assign

Sat Aug 02, 2014 1:33 am

What range of addresses are defined as your DHCP pool on your router? Trim the range down so that it ends at 192.168.1.160 (that means 192.168.1.161 through to 192.168.1.254 can be assigned as static).

On my network I have the following
  • xxx.yyy.1.1 to xxx.yyy.1.29 as static.
  • xxx.yyy.1.30 to xxx.yyy.1.99 as DHCP
  • xxx.yyy.1.100 to xxx.yyy.1.229 & xxx.yyy.1.231 to xxx.yyy.1.248 as unassigned
  • xxx.yyy.1.230 & xxx.yyy.1.249 to xxx.yyy.1.252 are assigned for servers (WiFi AP, WiFi printer, NAS box, etc.).
  • My router/gateway is at xxx.yyy.1.1.
  • My Ubuntu server is xxx.yyy.1.4
  • My RPi (called Pi) is at xxx.yyy.1.7, My 2nd RPi (called Raspberry) is at xxx.yyy.1.27
  • My smart-tv is at xxx.yyy.1.5
The only time my DHCP range was exhausted was when I discovered a bug in isc-dhcp-client when you disconnect the ethernet cable from the Raspberry Pi. Seventy addresses is more than enough for the laptops, tablets and smart phones.

If you come and visit you can have my WiFi password (I can give you a QR code to scan) after I've read out the rules.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
emgi
Posts: 357
Joined: Thu Nov 07, 2013 4:08 pm
Location: NL

Re: wlan0 always selects same IP regardless of Router Assign

Sat Aug 02, 2014 10:48 am

sun-tracker wrote:Hello all.

Having a strange issue with my wireless connection.

Upon first boot and rpi-config, the dongle I have connected just fine to my wifi network and (for whatever reason) chose the IP of 192.168.1.245. Connectivity is fine (eg web browsing).

I want to give it a static IP of 192.168.1.177, though, BUT I want to do it through my wifi router (Asus RT-N66U). Using the MAC address, I tell the router to assign the Pi a static IP of .177. The router accepts this command and upon reboot of both the router and the pi, the pi will ALWAYS take .245.
With any other mac/device on my network, static assignments work fine. I believe the problem is on the Pi's end -- what am I doing wrong and how can I get the pi to release it's obsession with the .245 IP?

Thanks.

-ST
This is a typical DHCP issue and I do not believe this problem to be with the Pi.
Please verify that you are indeed using the correct mac address for the static entry in your router.
You know wlan0 has a different mac than eth0 :?: .
Of course a typo is also possible. :mrgreen:

/emgi

sun-tracker
Posts: 6
Joined: Sun May 25, 2014 11:02 pm

Re: wlan0 always selects same IP regardless of Router Assign

Sun Aug 03, 2014 3:20 am

I did ensure the MAC addresses were correct.
Due to another unrelated problem, I ended up having to reflash a clean copy of Raspbian and so also resolved the issue I was having with IP assignment. As soon as the refreshed pi connected to my network on its first boot, it was assigned the right IP.. so I think there was something screwy going on with the Pi, but I'll never know for sure. Thanks for the help anyway!

User avatar
rpdom
Posts: 17173
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: wlan0 always selects same IP regardless of Router Assign

Sun Aug 03, 2014 4:42 am

When the dchp client gets given an IP address it logs it in /var/lib/dhcp/dhclient.wlan0.leases (for wlan0). You can look at the contents of this file, it is plain text, and look at the "expire" time and date of the current lease. If that time is in the future, the dhcp client will say to the server "Hey, I had this IP last time, can I have it again?". The server will see that no one else is using it and say "OK", as it know things don't always like their IP address changing all the time.

At least, that is what I have seen happen on occasions.

If you stop the interface then delete that file and restart the interface it should pick up the new IP.

User avatar
Cancelor
Posts: 776
Joined: Wed Aug 28, 2013 4:09 pm
Location: UK

Re: wlan0 always selects same IP regardless of Router Assign

Sun Aug 03, 2014 9:48 am

sun-tracker wrote:/etc/network/interfaces:

Code: Select all

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
......
What does the 'iface wlan0 inet manual' do?
Can't find the thread you want? Try googling : YourSearchHere site:raspberrypi.org

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: wlan0 always selects same IP regardless of Router Assign

Sun Aug 03, 2014 9:51 am

iface wlan inet manual
means that some external process (external to network-manager) will set up the interface. In this case it's wpa_supplicant that does that.

wpa_supplicant does the association with the access point and the WEP, WPA, WPA2 security handshake. When that is complete the network interface is marked UP and it will do a DHCPDISCOVER to get an address assigned from the DHCP server.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
pluggy
Posts: 3635
Joined: Thu May 31, 2012 3:52 pm
Location: Barnoldswick, Lancashire,UK
Contact: Website

Re: wlan0 always selects same IP regardless of Router Assign

Sun Aug 03, 2014 12:33 pm

I never understood the fascination with using DHCP and wanting a static IP address, just give it a static IP and stuff the router....
Don't judge Linux by the Pi.......
I must not tread on too many sacred cows......

User avatar
rpdom
Posts: 17173
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: wlan0 always selects same IP regardless of Router Assign

Sun Aug 03, 2014 12:55 pm

pluggy wrote:I never understood the fascination with using DHCP and wanting a static IP address, just give it a static IP and stuff the router....
Well, for one thing when at home I always get the same IP address, which allows me certain access levels to things on my network that other IP addresses don't have.

Yes, I could do that with a static IP, but when I'm not at home, using someone else's network, my static address would be wrong for their network. For that I need DHCP. After all, it's not just the IP address, it's also the nameserver, gateway, ntp server and maybe more.

My DHCP server (I don't use the one in the router) works on hostname instead of MAC, which is handy when I just grab the nearest network adaptor and plug it in to whichever computer I'm using at the time :)

Return to “Beginners”