Introduction: How to Configure Static IP Address for Raspberry Pi
This Instructable will give you clear idea about how to configure static IP address for raspberry Pi. Whenever you connect the Raspberry pi to your network the router assigns random IP address, this may become difficult to access your Raspberry pi via ssh . Every time you need to log on your router and have to check the IP address of Raspberry pi.So to overcome this we will configure the Raspberry pi to static ip address.
Step 1: Step 1: Configure Static IP for Raspberry Pi in Router
Before configuring the raspberry pi ,configure the static address in your router. The configuration in router varies from model to model. In our case we have configured in D-Link.To avoid IP conflict configure on both router and raspberry Pi
Log on to the router by entering the following address 192.168.1.1(this may change ) and enter user name and password .On the static IP address setting page mention MAC address of raspberry pi wireless network/or ethernet network and enter the IP address to which the you want to connect as shown in the images
Step 2: Step 1:
After this restart your router and open the terminal window on your raspberry pi and type the following command
From above screenshot, our Raspberry Pi is connected to our network and has been given the IP address 192.168.1.10 (Because we have already configured this on our router)
Step 3: Step 3: Now See the Router Information
Run the command sudo route -n, this will give us information from your router as shown in the screenshot.
Make sure you note down the following information given from this command:
For exampe in our case its
Gateway = 192.168.1.1
Destination = 192.168.1.0
Step 4: Step 3:Configuring Network Interface
Run sudo nano/etc/network/interfaces . This opens the configuration file for the network settings in the nano text editor.The screenshot is shown in the image1 and make changes from eth0 to wlan0 and manual to static as shown in image2, because we are using wireless. Next , add the following lines directly below the line you just altered.
address [your chosen IP address]
netmask [your netmask]
network [your destination]
broadcast [your broadcast range]
gateway [your gateway]
save your file and run sudo reboot to restart your Raspberry Pi with its new static IP address. The changes we have made will only take effect after a reboot.Hope its very clear instructable