Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Raspberry Pi Server Essentials

You're reading from  Raspberry Pi Server Essentials

Product type Book
Published in Feb 2014
Publisher
ISBN-13 9781783284696
Pages 116 pages
Edition 1st Edition
Languages
Author (1):
Piotr J Kula Piotr J Kula
Profile icon Piotr J Kula

Chapter 2. Preparing the Network

It is important to learn how your network works, especially if you plan to connect your Raspberry Pi to the Internet. A home user like yourself will typically use an Internet package designed for browsing websites and reading e-mails. Business packages on the other hand allow you to do a lot more than you might think. These two different ISP packages usually carry important technical differences that decide how your network can be reached.

In this chapter, we will learn how to connect to the Internet and look at how to solve some common problems for home users. We will also learn how to benchmark your network and try to isolate any network-related issues.

Local Area Network (LAN)


Using the standard Raspbian package, the essential drivers are included; most of the other drivers are also preloaded.

We will start by plugging in a network cable between the Pi and the router provided by your ISP. By default, this router has a DHCP server that automatically assigns an IP address to your Pi.

You may also use network switches to make a more complex network, but because the Pi has a 100 MB network port, it may downgrade the entire network to 100 MBs. Some switches can negotiate separate connections for lower-speed interfaces without downgrading the entire network, but you need to refer to the specifications of the device.

To check whether your LAN network is up and running, just type ifconfig, and you will get text containing your current settings:

  • HWaddr: This is your Pi's MAC address that identifies the vendor and should provide a globally unique address.

  • inet addr: This is your current LAN IP address that belongs to a private range of 10.x.y.z (Class...

Wireless configuration – Wi-Fi


Wi-Fi is a very convenient way to allow your Pi to operate in a remote place within the wireless range. There are many types of wireless adapters available, and not all drivers are included with Raspbian. You might have to install a specific driver, but that is usually a simple process. However, when talking about wireless, you have to target the chip that is used on the adapter and not the end vendor who is selling it.

Recommended wireless adapters

There is a comprehensive list of compatible adapters available at http://elinux.org/RPi_USB_Wi-Fi_Adapters.

One of the most stable and affordable chipsets is the Realtek RT8191, which works with the 802.11n standard. It is also compatible with the older 802.11b/g specifications, just in case your router does not support the newer 802.11n specification. It does not support 5 GHz frequencies or 40 MHz dual band though. Shop around to find the best price and don't be fooled by overpriced adapters that claim to be the...

Static network address


Some DHCP servers on routers tend to change your private address every now and again. Setting a static private address is a quick way to prevent this from happening, and it is easier to remember what the IP address is.

However, many newer routers have the ability to assign a preferred IP address in the DHCP settings or automatically assign a long term IP to the device based on its MAC address. Long term usually means until the router is reset to factory defaults or if it runs out of IP addresses and replaces the oldest entry in the DHCP list.

The downfall with using static addresses with most home routers is that the router will not know about this device. The reason is because it would have to scan the entire network endlessly, taking up valuable resources. If the DNS service does not advertise the IP address of the Pi, you will not be able to use its host name (by default, raspberry), and instead you have to type in the full IP address. Furthermore, if you want to...

Testing and benchmarking your network


These are essential tests that can be carried out to troubleshoot network problems, but there are also some advanced techniques to benchmark your network.

Basic tests

The simplest way to check whether you are connected to the Internet is to ping a remote address.

We can ping http://google.com, but we can also use the shorthand method and a quicker address, 8.8.8.8, which is Google's public DNS server. This IP address will resolve to the nearest Google DNS server in your area, and even if it goes down, there are many backup servers, making this a reliable test.

ping -c 1 www.google.com
ping -c 1 8.8.8.8

A ping can help you determine whether you have access to the public network. You may want to see how fast you can download files to the Pi. We use the popular http://speedtest.com server to help us with this directly in the command line.

wget --output-document=/dev/null http://speedtest.wdc01.softlayer.com/downloads/test500.zip

My Pi is connected over a fast...

Internet configuration


There are some obstacles to resolve before you can successfully host any kind of Internet application. The solutions are influenced by the package that your ISP provides to you, but almost every problem can be worked around.

ISP packages

Let's have a quick discussion on the two most popular packages supplied by ISP's.

Home packages

The most fundamental part of home packages is that you almost always have a dynamic IP address. Some ISPs will allow you to upgrade to a static IP, but there would still be some limitations. The problem with having a dynamic IP is that it may change without notice. So, if you try to access your network from the Internet using an IP, one day it will certainly stop working after a while. This lease time varies from ISP to ISP, some are as short as a few hours and others can last for years. If you don't know what your current Internet IP address is while you are in a remote place, finding out what it is can be quite inconvenient.

One of the best...

Summary


It is important to understand how your networks are configured. This includes both the Internet side and your local network. This in-depth understanding will surely help you troubleshoot particular problems on your own.

We now have our Pi connected to our private network and we have configured a domain name that can be accessed by anybody on the Internet. In the next chapters, we will learn more about the various services that can be made available to friends over the Internet.

lock icon The rest of the chapter is locked
You have been reading a chapter from
Raspberry Pi Server Essentials
Published in: Feb 2014 Publisher: ISBN-13: 9781783284696
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}