Saturday, 2 April 2016

Accessing raspberrypi with static IP address using Ubuntu 14.04


To create static IP, edit file in Raspbain OS so that we can get an access to laptop screen by connecting the raspberry pi to projector using HDMI-to -VGA converter or TV with HDMI enabled option. 
Step 1:  Editing /etc/network/interfaces in raspbain OS to, 
===========================
auto lo
iface lo inet loopback
iface eth0 inet static
address 10.42.0.2
netmask 255.255.255.0

and at the same time, my laptop's /etc/network/interfaces looks like this
auto lo wlan0

iface lo inet loopback


Note how the IP address on the eth0 interface is  now 10.42.0.1. This implies that the Linux PC is  basically  acting as a router between the 10.42.0.0 network ( really only a point to point network ) on which the RPi  and eth0 are attached, and the 192.168.0.0 network, which is attached to the internet & PC  via the wlan0 interface. Also note that the mask for the 10.42.0.0 network is 255.255.255.0 . This means that the IP address of the RPi is somewhere between 10.42.0.2 & 10.42.0.254.  To find the exact address we can use nmap  “sudo nmap -sP 10.42.0.2-254″. In my case, nmap reported that the my RPi has an IP address of 10.42.0.33 (Figure 6). If nmap is not installed, you can easily install it with “sudo apt-get install nmap“.
abhi@linux:~$ sudo nmap -sP 10.42.0.2-254

Starting Nmap 6.40 ( http://nmap.org ) at 2014-10-24 00:19 IST
Nmap scan report for 10.42.0.33
Host is up (0.00054s latency).
MAC Address: B8:27:EB:3E:64:DE (Raspberry Pi Foundation)
Nmap done: 253 IP addresses (1 host up) scanned in 22.15 seconds
abhi@linux:~$ ssh pi@10.42.0.33


you may need to re-start network namager: $sudo service network-manager restart
you can also use putty in ubuntu if needed.

Type command "$ssh pi@10.42.0.33" on the laptop, pi here is my username, and 10.42.0.2 here is RPi's IP address, then enter my password (raspberry, default password), and I finally have a direct connect to my RPi with my laptop(ubuntu 14.04).

$sudo raspi-config
From the raspi-config menu, first select “8 Advanced Options” -> “A5 Update” & hit enter. This will update the raspi-config tool to the latest version.
  • The Raspbian image is designed to expand into 2GB space on your SD card. This means that if you are using a larger SD Card, say 4GB or 8GB, the additional space is not part of the root file system partition.  To use all the space on your SD card  select “1 Expand Filesystem” and hit enter. This will expand the root file system partition to fill the entire SD card. The actual partition expansion will happen on reboot.

    Once at the RPi prompt shown after reboot, type “sudo apt-get updatefollowed by “sudo apt-get upgradeor alternatively we can do both at the same time “ sudo apt-get update && sudo apt-get upgrade.



     

 

No comments:

Post a Comment