In this article, we’ll explore how to network two Ubuntu computers using an Ethernet cable. This can be particularly useful for sharing files, printers, or even an Internet connection between two computers. We’ll cover three main methods: using a switch, hub, or crossover cable; using the NetworkManager GUI; and using the command line (nmcli).
To network two Ubuntu computers with Ethernet, you can use a switch, hub, or crossover cable, manually assign IP addresses, and edit network settings. Alternatively, you can use the NetworkManager GUI to connect the computers and share the connection. Lastly, you can use the command line tool nmcli to add a new Ethernet connection and test the connection.
Networking with a Switch, Hub, or Crossover Cable
This method involves physically connecting the two computers using a switch, hub, or crossover cable. Here are the steps:
- Connect the Computers: Connect the two computers using your chosen device. If you’re using a crossover cable, make sure that your hardware supports it. Most modern computers can use a standard Ethernet cable.
- Assign IP Addresses: You’ll need to manually assign IP addresses in the same range on both computers. For example, you could use 192.168.1.1 on one computer and 192.168.1.2 on the other.
- Edit Network Settings: In Ubuntu, right-click on the network manager applet, then go to “Edit Connections.” Add a new wired connection. Set the method to manual and add the IP address, netmask (usually 255.255.255.0 for a small local network), and gateway (the IP address of the other computer).
- Test the Connection: You can test the connection by using the
pingcommand followed by the IP address of the other computer. For example,
Networking with the NetworkManager GUI
The NetworkManager GUI provides a user-friendly way to network two computers. Here’s how:
- Connect the Computers: Connect the two computers using an Ethernet cable.
- Edit Network Settings: On one of the computers, click on the network indicator and select “Edit Connections.” Choose the Ethernet connection and click “Edit.”
- Share the Connection: In the IPv4 tab, change the method to “Shared to other computers.” This will allow the second computer to get assigned an IP address from the server and have access to the internet.
Networking with the Command Line (nmcli)
For those who prefer using the command line,
nmcli provides a powerful tool for networking. Here’s how:
- Connect the Computers: Connect the two computers with an Ethernet cable.
- Identify the Ethernet Interface: Determine the Ethernet interface of each computer using the
ip addrcommand. This will display a list of network interfaces along with their IP addresses.
- Add a New Connection: Use the
nmclicommand to add a new Ethernet connection with a specific IP address on each computer. The command would look something like this:
nmcli con add type ethernet con-name Connection1 ifname eth0 ip4 192.168.1.1/24. Here,
con-namespecifies the name of the connection,
ifnamespecifies the interface name, and
ip4specifies the IP address and netmask.
- Test the Connection: As before, you can test the connection by pinging the IP address of the other computer.
In conclusion, networking two Ubuntu computers with an Ethernet cable can be accomplished in several ways, each with its own advantages. Whether you prefer a physical device like a switch or hub, the user-friendly NetworkManager GUI, or the powerful command line tool
nmcli, Ubuntu provides the tools you need to get connected.
Yes, most modern computers can use a standard Ethernet cable for networking. However, if you’re using a crossover cable, make sure that your hardware supports it.
You’ll need to manually assign IP addresses in the same range on both computers. For example, you could use 192.168.1.1 on one computer and 192.168.1.2 on the other.