This guide is for Raspbian OS for Raspberry Pi, and also tested on B+ model
Log on into Raspbian onto command line and list the network interfaces currently available:
cat /etc/network/interfaces
Note, eth0 is by default configured as dhcp (dynamic ip address)
We will change this behavior to static.
Before we proceed we need to determine the following information. All of these you can easily determine if you have setup your local network (wifi router/switch/hub/etc..), alternatively if your have your Raspberry Pi connected to LAN (eth0) you can run the following commands to get details:
ifconfig
Now note the following values:
inet addr:192.168.2.2
Bcast:192.168.2.255
Mask:255.255.255.0
Next get the Gateway and Destination address (ideally your router IP addess, or use below command):
netstat -nr
Gateway Address – 192.168.2.1
Destination Address – 192.168.2.1
Now, we will edit config and set the static ip details:
sudo nano /etc/network/interfaces
Change the line that reads:
iface eth0 inet dhcp
to
iface eth0 inet static
Next enter the details that you have collected in previous steps:
address 192.168.2.2 Pi's IP address
netmask 255.255.255.0 Mask address
network 192.168.2.1 Destination address
broadcast 192.168.2.255 Broadcast address
gateway 192.168.2.1 Gateway address
Now reboot your Raspberry Pi, and next check the config once again:
sudo reboot
after reboot
ifconfig
That's all folks!
Thanks a lot !!!
ReplyDeleteI see the problem. In the description of the text you enter as the gateway 192.168.1.254, and the screenshot you have an IP gateway 192.168.2.1 (IMHO: It is correct).
ReplyDeleteThanks for pointing out the typo! Corrected.
Deletesudo dhclient works too
ReplyDelete