In today's world, it is very convenient to connect multiple computers together. We often want these devices to share information, and we accomplish this through computer networking.
We refer to many directly-connected computers in the same location as a Local Area Network, or LAN network. A common example of a LAN is several computers connected to the same wifi network.
When there are multiple devices at play, we often don't want every single computer to have a direct connection to every other computer in the network. This is where the router comes into play. A router is simply a device which passes information between different networks.
In a typical LAN, every computer device is assigned an address, according to the IPV4 standard. For example, your computer's home address could be something like
192.168.1.34. This is simply a number which refers to your computer on the network.
Your router is also given its own address, and on a typical home LAN network, its address is
Suppose computer A wants to send data to computer B on a LAN. Computer A has the address
192.168.1.4, computer B has the address
192.168.1.5, and the router has the address
192.168.1.1. When computer A transmits data, the data packets are sent to the router, and the router then sends the packets to computer B. It acts as a centralized location which manages all the data packets on the network.
Your computer is assigned an IP address whenever it joins a LAN. The Dynamic Host Configuration Protocal, or DHCP, is a process which assigns your computer an address automatically.
However, every time your computer joins the network, it will be assigned a different IP address. This is a problem, because if you need to send data to a specific computer, its address on the network keeps changing!
To fix this, you may want to assign a static IP-address, which is simply a constant IP address for your device, which never changes. This article goes into more detail about how to set this up.
Suppose that you do not want to use a router in your computer setup.
It is indeed possible to directly connect two computers with an ethernet cable! Here, we will show you how to connect a Raspberry Pi directly to a host computer with an ethernet cable. This will allow you to send data packets or SSH into the device by simply connecting an ethernet cable.
Here's how the setup will look: The host computer and the Pi will form a two-computer LAN, with only one ethernet cable connecting the two computers. The Raspberry Pi and host computer will each be assigned their own static IP address, so that each computer can always access the other one every time they are connected.
Your computer will also be assigned as the "router," so that all data packets are sent to the right location.
First, install Raspberry Pi OS on a Raspberry Pi. By default, there will be no static IP address.
You can configure one by modifying the
dhcpcd configuration file. Run this command:
sudo nano /etc/dhcpcd.conf
and append the following information to the file:
INTERFACE with the name of the interface you plan on using.
eth0 is the name of the ethernet interface, and if you are connecting over a USB cable, then
usb0 will be the name of your interface instead.
Suppose that you plan to assign the IP address
10.0.0.1 to the Pi, and
10.0.0.100 to the host computer, and you plan to connect the devices over an ethernet cable. Then your configuration file will look like:
Save your changes to the file, and restart the Pi. When it boots, you can confirm that the IP address is set correctly by running the following command:
You will need to add a new netowrk configuration to your host computer. These instructions vary based on the device you're using.
In the System Settings application, go to the Networks tab.
Add a new network configuration of the type Thunderbolt Bridge. (If you wish to use Ethernet, select the Thunderbolt Bridge configuration and use an Ethernet dongle).
Go to the "Advanced" tab, and under TCP/IP, set the IP address configuration from DHCP to manual. Set the IP address to the static IP we want for the computer (based on the previous example, it would be
10.0.0.100). Then set the subnet mask to
If your setup is correct, then you should be able to ping the Raspberry Pi with the following command: