Internet of Things with Python
上QQ阅读APP看书,第一时间看更新

Retrieving the board's assigned IP address

The board has finished the boot process with the Yocto Linux microSD card and is connected to our LAN throught the Ethernet port. The DHCP server has assigned the board an IP address and we need to know it in order to run commands on a Yocto Linux console. There are many ways for us to retrieve the board's assigned IP address. We will explore the different options and you can choose the most convenient one based on your LAN configuration.

If the board is connected to one of the Ethernet ports of a Wireless router and we have access to the router's Web interface, we can easily know the IP address assigned to the board. Some router's Web interfaces display the wired clients list. As our board is connected through an Ethernet wire, it will be listed as one of the wired clients and the device MAC address will match the MAC address printer in the adhesive label on the board's Ethernet jacket. The following picture shows the Wired-clients list in a router's Web interface and the list includes a device named galileo with A1-B2-C3-D4-E5-F6 as the MAC address that matches the MAC address printed without hyphens (-) in the board: A1B2C3D4E5F6. The IP address assigned to the board is 192.168.1.104. For security reasons, the original MAC address has been erased and we are using a fake MAC address for our example.

Retrieving the board's assigned IP address

Sometimes, the router's Web interface doesn't provide an option that displays the wired clients list. If this is the case for our router, we will always be able to retrieve the DHCP client list that provides all the IP addresses assigned to either the wireless or wired devices connected to the LAN. We just need to find the device that has the MAC address for the board. The following picture shows the DHCP Client List in a router's Web interface and the list includes a device named galileo with A1-B2-C3-D4-E5-F6 as the MAC address that matches the MAC address printed without hyphens (-) in the board: A1B2C3D4E5F6. The IP address assigned to the board is 192.168.1.104.

Retrieving the board's assigned IP address

Another option is to install a Bonjour Browser to discover the board and its services on the LAN automatically through this zero-configuration networking implementation, without knowing the IP assigned to the board.

In Windows, download, install, and launch the free Bonjour Browser for Windows from http://hobbyistsoftware.com/bonjourbrowser. The application will display many available Bonjour services with galileo as their name. The following screenshot shows the _ssh._tcp service type with galileo as its name selected with the details. The IP Adresses section shows the IP address and the port number for the SSH service: 192.168.1.105:22. We can use the IP address with any SSH client to connect to the board. In addition, the Bonjour browser lets us know that the board has an SFTP service that will make it easy for us to transfer files from and to the Yocto Linux running on the board.

Retrieving the board's assigned IP address

In OS X, download and run the free Bonjour Browser from http://www.tildesoft.com. You can click on Reload Services to refresh the discovered devices and their services. The following picture shows a board and its services listed in the Bonjour Browser. You have to click on each right-arrow to expand the details for each listed service. In this case, all the services are provided by the same device named galileo. Once you expand the device, the application displays the IPv4 and IPv6 addresses. The SSH (_ssh._tcp.) service type lists a device with galileo as its name and with 192.168.1.105:22 as the IPv4 address and the port number. We can use the IP address with any SSH client to connect to the board. The Bonjour Browser also displays the details for the SFTP service.

Retrieving the board's assigned IP address

Tip

SSH stands for Secure Shell Protocol and its default port is 22. Yocto Linux runs the SSH server in the default port, and therefore, there is no need to specify the port in SSH clients, we can just specify the discovered IP address.