Creating a Simple Ad-hoc Two-PC Wired LAN in Linux

Setting up a basic two-computer wired LAN connection in Linux can sometimes be a challenge due to the lack of straightforward examples. If you find yourself in need of connecting two machines together using a LAN cable, the following steps will guide you through the process.

On Computer A, open a terminal and enter the following command:

sudo ip addr add 192.168.20.1/24 dev eth0

On Computer B, open a terminal and enter the following command:

sudo ip addr add 192.168.20.2/24 dev eth0

By executing these commands, you will assign IP addresses to each computer within the LAN. This process also typically adds the necessary routing tables, but it’s always good to double-check. You can verify the routing tables by typing the following command:

ip route show

These steps should help you establish a basic wired LAN connection between the two computers. Feel free to adjust the IP addresses as needed to suit your network requirements.

Leave a comment