Saturday, 22 November 2014

Raspberry pi ssh login without monitor and giving it static IP

Connecting Raspberry Pi to Ethernet and finding its IP address 

Connect Raspberry pi to Ethernet and power it on . The Raspbian "wheezy" distro comes with SSH telnet access enabled .
When you switch Raspberry pi on the router will allocate an IP to it .  Now log in to your router to see the IP assigned to Raspberry Pi . You can also use any IP scanner software also for finding out the IP assigned to Raspberry Pi like Advanced IP Scanner.



Connect to the Raspberry Pi via SSH / Putty

Download & Install Putty. It is not really an Install as you can run the putty.exe directly

Enter the IP address of Raspberry Pi in host name and click open.


Enter username pi and password raspberry (this is the default password )






Now you are connected to Raspberry Pi .

Giving static IP to Raspberry Pi

Type  cat /etc/network/interfaces to list the network interface currently available.


iface etho inet dhcp : This line tells us that we are using DHCP to get IP address . The IP address we get is dynamic and gets assigned to us every time we connect to router .

To set a static IP address we need some information about our connecion .

Type ifconfig to get inet address , Bcast and Mask  .


inet address : 192.168.0.100
Bcast : 192.168.0.255
Mask : 255.255.255.0

Type netstat -nr to get Gateway and Destination .


Gateway : 192.168.0.1
Destination : 192.168.0.0
 
Now we need to edit etc/network/interfaces to get static IP . 

type sudo nano /etc/network/interfaces and delete "iface etho inet dhcp" and replace with iface etho inet static and in the next line paste / write all the info we got in the above step .
It will look like : 

iface lo inet loopback
iface eth0 inet static
address 192.168.0.100
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1


 Type CTRL+X to exit then yes to save changes .


Type sudo reboot to reboot Pi . When the Pi boots it will have a static IP .





No comments:

Post a Comment