How to set up the Raspberry Pi using static IP address with a wireless wi-fi connection. To setup your Raspberry Pi with a static IP address using a wireless adapter connection you simply follow the instructions that was previously used for an Ethernet connection but with a minor change. Remember that the Raspberry Pi is automatically set to obtain an IP address when using a wireless network. To change this to a static IP address following the instructions below.
If you do not have a compatible wireless adapter then you can purchased one below from Amazon.
Login and bring up a terminal window. Enter the following.
The line below is referring to the wlan0 interface and that is should use DHCP.
iface wlan0 inet dhcp
To change this line to a static IP address, enter the following command to retrieve your existing IP address and network information.
Make a note of your current IP address, the broadcast IP and the Mask. This is represented by the
inet addr: 192.168.0.6 [CHANGE]
Bcast: 192.168.0.255 [CHANGE]
One last thing that is required is the gateway. This is in most cases your routers internal IP address.
Enter the following
sudo route -nee
Make a note of Gateway address.
Next you need to edit the interfaces file to set this static information. Enter the following command.
sudo nano /etc/network/interfaces
Remove the line that reads
iface wlan0 inet dhcp
Add the following but replace the network settings with your own.
iface wlan0 inet static
Save the file by pressing CTRL-X and select Y to save the changes.
When the raspberry Pi reads this file when booting up, it will look at the interface wlan0 and set it to the static IP address specified in the interfaces file. I will set the IP address to 192.168.0.6, the network to 188.8.131.52, the broadcast address and the gateway address so that it can find its way out of the network. Remember that you must use your network settings.
Reboot your Raspberry Pi with the following command
Login back in and enter the following.
ping 192.168.0.1 -c5
This will ping your gateway address or router and will return :
64 bytes from 192.168.1.254: icmp_req=1 ttl=255 time=2.11
64 bytes from 192.168.1.254: icmp_req=2 ttl=255 time=3.32
64 bytes from 192.168.1.254: icmp_req=3 ttl=255 time=2.34
64 bytes from 192.168.1.254: icmp_req=4 ttl=255 time=3.31
64 bytes from 192.168.1.254: icmp_req=5 ttl=255 time=3.46
One last thing that needs to be modified is the /etc/resolv.conf file. This file contains information of DNS name resolvers that allow your raspberry pi to resolve names to IP addresses. For example, if you ping www.suntimebox.com the raspberry pi will have to determine the IP address of www.suntimebox.com.
Enter the following command to edit the resolv.conf file.
sudo nano /etc/resolv.conf
Enter the follow Google public dns server IP address.
name server 184.108.40.206
Press CTRL-X to exit but remember to save the file by accepting the changes.
If you prefer, you can always make a reservation on your router or server. For this you will have to make a note of the hardware address when you enter the
command. The hardware address is represent as the HWaddr: 08:00:22:ef:65:bc. Note that your hardware address will be different.
Please let me know if you want to add something that will benefit someone or a comment just saying thank you would be nice. If I missed something then just yell at me so I can correct it. Remember these tutorials are produced in my spare time so any help that you wish to give is greatly appreciated because these do take a lot of time and of course money. I believe in Karma, so by helping you, somewhere along the line someone will help me. Hopefully this has saved you some time and the need for less coffee to keep you up all night.