One of the first things you will want to do with your Raspberry Pi is to connect it to a network so that you can gain access to the internet. You will need an IP address to gain access so that any information destined for your Raspberry Pi actually gets there. This is much like a house address. If someone is sending you a letter then they would need to know your address for you to receive it. IP addresses take the form of something like this 192.168.0.1 Each device that has access to a network requires a unique IP address otherwise if two addresses are the same, the information will not know which device to deliver the information to. Most networks and out of the box routers automatically supply your Raspberry pi with an IP address. This saves you a lot of the work when setting it up. To connect your Raspberry Pi to the internet just plug in a network Ethernet cable. (See Week 1 – Day 4 (Connecting it up)). To confirm that you have an internet connection following these instructions Open a terminal window Type $ ping 158.43.128.1 -c 5 Press enter. This will ask a device on the internet for a reply. PING 158.43.128.1 (158.43.128.1) 56(84) bytes of data. 64 bytes from 158.43.128.1: icmp_req=1 ttl=64 time=0.342 ms
64 bytes from 158.43.128.1: icmp_req=2 ttl=64 time=0.349 ms
64 bytes from 158.43.128.1: icmp_req=3 ttl=64 time=0.381 ms
64 bytes from 158.43.128.1: icmp_req=4 ttl=64 time=0.355 ms
64 bytes from 158.43.128.1: icmp_req=5 ttl=64 time=0.411 ms For this automatic connection to happen it uses DHCP which stands for Dynamic Host Configuration Protocol. Enter the following $ sudo cat /etc/network/interfaces The line that makes this happen is iface eth0 inet dhcp iface refers to interface, which is the eth0 or the port that you connected your network cable to. The type of connection required is dhcp which configures the Raspberry pi to use DHCP or automatic IP addressing.
|