Hardware Reference
In-Depth Information
Chapter 7
Ethernet
Networking has become an important part of everyday life, whether wireless or by wire.
Having a network adapter on your Raspberry Pi allows you to connect to it and do things
on it from the comfort of your desktop or laptop computer. It also allows your application
on the Pi to reach out to the outside world. Even when the Raspberry Pi is deployed as
part of an embedded project, the network interface continues to be important. Remote
logging and control are just two examples.
Wired Ethernet
The standard Raspbian SD card image provides a wired network connection, using
DHCP to automatically assign an IP address to it. If you are using the HDMI output and
keyboard devices to do work on the Pi, the dynamically assigned IP address is not a
bother. But if you would like to eliminate the attached display and keyboard, connecting
over the network is attractive. The only problem is the potentially changing IP address.
(DHCP will not always use a different IP address, since the address is leased for a time).
It is difficult to contact your Raspberry Pi from a laptop until you know its IP address.
As covered in Chapter 1 of Raspberry Pi System Software Reference (Apress, 2014), you can
use the nmap command to scan for it, but this is inconvenient:
$ sudo nmap −sP 192.168.0.1−254
Starting Nmap 6.25 ( http://nmap.org ) at 2013−04−14 19:12 EDT
. . .
Nmap scan report for mac (192.168.0.129)
Host is up.
Nmap scan report for rasp (192.168.0.132)
Host is up (0.00071s latency).
MAC Address: B8:27:EB:2B:69:E8 ( Raspberry Pi Foundation )
Nmap done : 254 IP addresses (6 hosts up) scanned in 6.01 seconds
$
If you use your Pi at school or away from your own premises, using DHCP may still
be the best option for you. If you are plugging it into different networks as you travel,
DHCP sets up your IP address properly and takes care of the name server configuration .
However, if you are using your unit at home, or your school can assign you a valid IP
address to use, a static IP address simplifies access.
 
Search WWH ::




Custom Search