Raspberry Pi 3 Cookbook for Python Programmers
上QQ阅读APP看书,第一时间看更新

Getting ready

Before you start, you will need to determine the network settings for your network.

You will need to find out the following information from your router's settings or another computer connected to the network:

  • IPv4 address: This address will need to be selected to be similar to other computers on the network (typically, the first three numbers should match, that is, 192.168.1.X if netmask is 255.255.255.0), but it should not already be used by another computer. However, avoid x.x.x.255 as the last address, since this is reserved as a broadcast address.
  • Subnet mask: This number determines the range of addresses the computer will respond to (for a home network, it is typically 255.255.255.0, which allows up to 254 addresses). This is also sometimes referred to as the netmask.
  • Default gateway address: This address is usually your router's IP address, through which the computers connect to the internet.
  • DNS servers: The Domain Name Service (DNS) server converts names into IP addresses by looking them up. Usually, they will already be configured on your router, in which case you can use your router's address. Alternatively, your Internet Service Provider (ISP) may provide some addresses, or you can use Google's public DNS servers at the addresses 8.8.8.8 and 8.8.4.4. These are also called nameservers in some systems.

For Windows, you can obtain this information by connecting to the internet and running the following command:

ipconfig /all  

Locate the active connection (usually called Local Area Connection 1 or similar if you are using a wired connection, or if you are using Wi-Fi, it is called a wireless network connection) and find the information required, as follows:

The ipconfig/all command shows useful information about your network settings

For Linux and macOS X, you can obtain the required information with the following command (note that it is ifconfig rather than ipconfig):

ifconfig  

The DNS servers are called nameservers and are usually listed in the resolv.conf file. You can use the less command as follows to view its contents (press Q to quit when you have finished viewing it):

less /etc/resolv.conf