m237b
Posts: 1
Joined: Sun Nov 11, 2012 6:44 pm

Can't force wlan0: to use static IP

Sun Nov 11, 2012 6:55 pm

Hello Guys,

I'm trying to set static IP for my wlan0 interface...doesn't look like it's working.

Original /etc/network/interfaces file:
-----------------------------
auto lo
iface lo inet loopback
iface eth0 inet static
address 192.168.1.111
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
-------------------------------
If I set wlan0 the same way as eth0, with "static" and all address/netmask stuff
I loose my wireless and ethernet connection. Have to remove WIFI NIC from the
port and reboot to restore my ethernet connectivity. It looks like wlan0 and eth0
won't run via static if both defined within interfaces file.

Any ideas ?

Thanks in advance

hunternet93
Posts: 336
Joined: Mon Dec 12, 2011 4:34 pm

Re: Can't force wlan0: to use static IP

Mon Nov 12, 2012 1:11 pm

I'm having the same issue when trying to set up my Pi as a wireless hotspot. I solved a couple of the issues. Try this /etc/network/interfaces:

Code: Select all

auto lo
iface lo inet loopback
  iface eth0 inet static
  address 192.168.1.111
  netmask 255.255.255.0
  network 192.168.1.0
  broadcast 192.168.1.255
  gateway 192.168.1.1

#allow-hotplug wlan0
iface wlan0 inet static
  address put.static.ip.here
  netmask put.net.mask.here
  gateway put.gate.way.here

#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
#iface default inet dhcp
The last two lines cause some major issues when configuring WiFi, make sure they're commented out. I'm still having an issue where the static IP doesn't get set on boot, but if you set in manually with the command:

Code: Select all

sudo ifconfig wlan0 static.ip.add.ress
or if you unplug + replug the wireless dongle, it works fine.

EDIT: I changed a line in the above config file, it should now set the IP address for wlan0 on boot without problems.

GizmoB73
Posts: 80
Joined: Fri Jan 27, 2012 12:51 pm

Re: Can't force wlan0: to use static IP

Tue Nov 13, 2012 8:26 am

Try looking at this article, I followed it and it worked for me:

http://kerneldriver.wordpress.com/2012/ ... pberry-pi/

Good luck.

jb1000
Posts: 1
Joined: Sat Mar 09, 2013 6:49 pm

Re: Can't force wlan0: to use static IP

Sat Mar 09, 2013 7:00 pm

This worked for me without setting the default to static

/etc/network/interfaces:

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 home inet static
address 192.168.38.18
netmask 255.255.255.0
gateway 192.168.38.7

iface default inet dhcp


and /etc/wpa_supplicant/wpa_supplicant.conf

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

network={
ssid="not telling"
scan_ssid=1
psk="not telling"
key_mgmt=WPA-PSK
id_str="home"
priority=15
}

The key to it is the id_str option in the wpa_supplicant.conf file. This refers back to the home interface in the interfaces file.

Oddly, this does not allow the ethernet and the wireless interfaces both to be up. If you plug in the ethernet, wlan0 goes down. This is fine for me - I will only use the ethernet if the wireless gives problems.

Cloudcentric
Posts: 982
Joined: Fri Sep 14, 2012 9:13 am

Re: Can't force wlan0: to use static IP

Sat Mar 09, 2013 8:15 pm

JB1000 you do realise the post you responed to is 3 months old and support embedded for wlan adaptors has been improved ? :twisted:
I know everything about nothing"

ASUOS
Posts: 1
Joined: Sat Mar 23, 2013 3:31 am

Re: Can't force wlan0: to use static IP

Sat Mar 23, 2013 3:34 am

THANKS A LOT JB1000! after look a lot of information this post help me a lot!

northernguardian
Posts: 1
Joined: Tue Apr 16, 2013 3:22 am

Re: Can't force wlan0: to use static IP

Tue Apr 16, 2013 3:37 am

Thought I would post what I found. The other settings I researched weren't working on my system. This works for me at boot also.

I'm using an old Linksys wireless-G network adapter, I can provide the model if necessary.

I only use this wireless and no other connections, ie ethernet. I haven't figured out this setting yet, but if I remove/comment out the "auto lo and iface lo inet loopback" it doesn't work. The "allow-hotplug" lets my device connect to the raspberrypi. "WPA-roam" does NOT work with wlan0 set as static. That's why at the bottom you have to define the default settings as static and declare the address settings.(The default overrides the wlan0 which is why this sticks? Not sure yet.)

I saw some posts set a network address setting at the bottom, but it didn't make me specify an address. I did not have to edit the wpa_supplicant.conf file either.

Code: Select all

auto lo
iface lo inet loopback

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

iface default inet static
address 192.168.x.xxx
netmask 255.255.255.0
gateway 192.168.x.x

onebeartoe
Posts: 6
Joined: Fri May 03, 2013 7:18 pm

Re: Can't force wlan0: to use static IP

Mon Dec 02, 2013 10:13 pm

Thank you, northernguardian. Your suggestion for static IP address via WiFi configuration worked on a Raspberry Pi model B revision 1 that I am using for a lizard enclosure.

four2six
Posts: 1
Joined: Tue Jan 28, 2014 1:14 pm

Re: Can't force wlan0: to use static IP

Tue Jan 28, 2014 1:16 pm

This worked for me, thank you.
It even lets me be connected via wifi and lan at the same time.

FiremanKurt
Posts: 1
Joined: Wed Mar 05, 2014 4:30 am

Re: Can't force wlan0: to use static IP

Wed Mar 05, 2014 4:35 am

This is my Settings that work with both Ethernet and Wifi Active:

sudo nano /etc/network/interfaces

Code: Select all

auto lo

iface lo inet loopback

allow-hotplug wlan0 eth0
iface wlan0 inet static
address 10.42.43.15
netmask 255.255.255.0
network 10.42.43.1
gateway 10.42.43.1
wpa-passphrase Password
wpa-ssid MyWifi

#iface eth0 inet dhcp
iface eth0 inet static
address 10.42.43.14
netmask 255.255.255.0
network 10.42.43.1
gateway 10.42.43.1
metric 100

#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Code: Select all

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

network={
ssid="TRENDnet"
scan_ssid=1
psk="passphrase"
proto=RSN
key_mgmt=WPA-PSK
pairwise=TKIP
group=TKIP
}

mprinc
Posts: 1
Joined: Thu Feb 26, 2015 12:45 am

Re: Can't force wlan0: to use static IP

Thu Feb 26, 2015 1:00 am

I had an issue in having multiple/more than one WiFi router i wanted to connect with, and to each router with different subnet, ip, ...

Here is the trick:

First to establish connection with WiFi (negotiate protocols, pass), you have 2 options:

1) do it through GUI tool:
  • WiFi config
  • Current Status
  • Scan
  • Double click the network
  • provide pass
  • save it
  • Manage Networks
  • IDString: <set the id string to what you want>
  • Priority: 0
  • File -> Save Configuration
2) Do it manually (you have already abovementioned advice from other users). This is what i did set:
sudo joe /etc/wpa_supplicant/wpa_supplicant.conf
network={
ssid="Chupavi D-Link"
psk="xxx"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
id_str="wifi_oslo"
}

network={
ssid="rudani"
psk="xxx"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
id_str="wifi_bg"
}


You will notice that there are TWO networks, and that PSK is the pass that you set to your own pass, same as SSID and other parameters. ID_STR you also choose.

Finally you have to provide IP parameters:

sudo joe /etc/network/interfaces

iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface wifi_oslo inet static
address 192.168.0.125
netmask 255.255.255.0
gateway 192.168.0.1
network 192.168.0.0
broadcast 192.168.1.255

iface wifi_belgrade inet static
address 192.168.2.125
netmask 255.255.255.0
gateway 192.168.2.1
network 192.168.2.0
broadcast 192.168.2.255


You can see that you simply refer to ID_STR you created in the first step and set any IP parameters you want.

Good luck!

pola_raspberry
Posts: 1
Joined: Sun Apr 17, 2016 8:05 pm

Re: Can't force wlan0: to use static IP

Sun Apr 17, 2016 8:08 pm

That works for me! RaspBerry PI 2 Model B

I think the same, "WPA-roam" does NOT work with wlan0 set as static"

Thanks northernguardian!!!



by northernguardian » Tue Apr 16, 2013 3:37 am
Thought I would post what I found. The other settings I researched weren't working on my system. This works for me at boot also.

I'm using an old Linksys wireless-G network adapter, I can provide the model if necessary.

I only use this wireless and no other connections, ie ethernet. I haven't figured out this setting yet, but if I remove/comment out the "auto lo and iface lo inet loopback" it doesn't work. The "allow-hotplug" lets my device connect to the raspberrypi. "WPA-roam" does NOT work with wlan0 set as static. That's why at the bottom you have to define the default settings as static and declare the address settings.(The default overrides the wlan0 which is why this sticks? Not sure yet.)

I saw some posts set a network address setting at the bottom, but it didn't make me specify an address. I did not have to edit the wpa_supplicant.conf file either.

Return to “Beginners”