Raspberry Pi Wifi Static IP
My RPi is going to be a telepresence robot so it uses wifi. It also needs a static IP address. Here's how to configure Raspbian Wheezy with a static IP for wifi using WPA2 personal with PSK (Private Shared Key). The changes to your /etc/network/interfaces file will result in something like the following.
Finally, you can either reboot, or you can issue the following commands to restart the wlan0 interface
auto lo
iface lo inet loopback
iface eth0 inet static
address 192.168.0.5
netmask 255.255.255.0
gateway 192.168.0.1
auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.0.4
netmask 255.255.255.0
gateway 192.168.0.1
wpa-passphrase yourpassphrasehere
wpa-ssid yourssidhere
wireless-channel yourchannelhere
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
#iface default inet dhcp
Specify using static instead of manual for interface wlan0, then specify the address, netmask, and gateway, configure the WPA passphrase and SSID, and the wireless channel. Finally, you have to disable the wpa_supplicant configuration, and you have to disable the default dhcp behavior.Finally, you can either reboot, or you can issue the following commands to restart the wlan0 interface
sudo ifdown wlan0
sudo ifup wlan0
If you get no errors on the last command, except possibly some ioctl errors, you're a-ok.pi@raspberrypi:/etc/network$ sudo ifup wlan0
ioctl[SIOCSIWAP]: Operation not permitted
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
pi@raspberrypi:/etc/network$
Double-check by issuing ifconfig wlan0, make sure it's configured correctly, then issue a ping to your gateway (ping 192.168.0.1) and then ping google.com or some other reliable website.pi@raspberrypi:/etc/network$ ifconfig -a
eth0 Link encap:Ethernet HWaddr b8:27:eb:fb:8d:50
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:36 errors:0 dropped:0 overruns:0 frame:0
TX packets:36 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3480 (3.3 KiB) TX bytes:3480 (3.3 KiB)
wlan0 Link encap:Ethernet HWaddr 80:1f:02:86:ef:61
inet addr:192.168.0.4 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:38 errors:0 dropped:1467 overruns:0 frame:0
TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:841044 (821.3 KiB) TX bytes:100717 (98.3 KiB)
pi@raspberrypi:/etc/network$ ping 192.168.0.1
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_req=1 ttl=64 time=3.07 ms
64 bytes from 192.168.0.1: icmp_req=2 ttl=64 time=1.90 ms
^C
--- 192.168.0.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 1.905/2.491/3.077/0.586 ms
^C
Et voila, you have a wifi static IP. Congratulations!
Hi man! I am new to raspberry pi, Wheezy also making me more frustrate. I am really confused with Ethernet. please provide me a brief tutorial for Ethernet.
ReplyDeleteEthernet is just the low level standard/protcols that connect your computer to a hub/switch with wires. What are you having problems with?
DeleteMany thanks! After many searches on the Internet, you're the only one who provides the right solution to configure two static IP addresses for both eth0 and wlan0 (and that allows the WiFi interface to work without the Ethernet cable to be connected). You made my evening...
ReplyDeletePhilippe (France)
@Philippe It makes my day to hear that! Really happy I could help. It may help others find this if you +1 / like / whatever else. :) Take care!
DeleteGreat job!
ReplyDeleteCan I set the IP addresses the same for wired and wireless?
As long as you don't have ethernet and wifi active at the same time, each adapter could be assigned the same IP address. I'd have to do some research to do anything more than that.
Deletegreat post! i hope this will solve my problem when i got home tonight.
ReplyDeletejonel
Hi - After trying about 10 sets of solutions your post has fixed it for me as well. Thanks.
ReplyDeleteThank you thank you thank you!!!
ReplyDeleteI've been trying to get this to work all day and this is the only solution that has worked, I owe you a pint! You truly are a saint.
Like the other Anonymous of Feb 11, I'd done several searches and yours were the only instructions that worked - many thanks!
ReplyDeleteJust wanted to say thanks. Works sweet with Occidentalis v0.2
ReplyDeleteJust wanted to say after trying quite a few things both online and just tinkering, this just worked, no messing with it, just save it and go. So, uh, thanks! =D
ReplyDeleteAfter a lot of searching on the net and even more trail and error. Nothing worked
ReplyDeleteThis one does!!!
Thanx a lot, this just made my day :)