Directly connect two linux machines using an ethernet cable

Fujitsu Esprimo D756

The wiring process is straightforward. Get an ethernet cable and connect the two machines fiber optics cable will work too. To make the two machines talk to each other, a static IP has to be configured in each machine. For this setup a gateway isn't needed, as internet connection is not required.
The static IP can be configured via ip addr command or editing interfaces file and making it persistent to reboots.
For the network example we will use the ip 192.168.5.10 on machine 1 and 192.168.5.11 on machine 2 both using Debian 12. The subnet will be /24 or 255.255.255.0

Fujitsu Esprimo D756

The network cards used for this guide are the Mellanox MCX311A-XCAT Connect X-3 and Mellanox MCX312A-XCBT ConnectX-3. The only difference is that the CX312A has two ports. The transceivers used are Finisar FTLX8571D3BCL connected with an OM3 optical fiber cable of 3 meter length.

Note:

You need a way to configure machines locally. If you mess up the configuration the network connection could be interrupted.

Let's start with the setup.

Installing net-tools for easy debugging

net-tools package offers ifconfig command making interface address really visual.

apt install net-tools

For testing the link ping command will be used. The -c 2 params limit the count to two echoes.
If you need to force an interface for the pings use the -I param followed by the interface name as the example.

ping -I enp3s0d1 192.168.5.10 -c 2

To list the interfaces ifconfig command will be used

/sbin/ifconfig
enp3s0: flags=4163  mtu 1500
        inet 192.168.4.11  netmask 255.255.255.0  broadcast 192.168.4.255
        inet6 fe80::3bc9:42f7:3b30:8714  prefixlen 64  scopeid 0x20
        ether e4:1d:7e:6c:bc:79  txqueuelen 1000  (Ethernet)
        RX packets 2869  bytes 2914734 (2.7 MiB)
        RX errors 0  dropped 481  overruns 0  frame 0
        TX packets 1728  bytes 149455 (145.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp3s0d1: flags=4163  mtu 1500
        ether e4:1d:7e:6c:bc:7a  txqueuelen 1000  (Ethernet)
        RX packets 26  bytes 4537 (4.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 32  bytes 4078 (3.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 12  bytes 1704 (1.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12  bytes 1704 (1.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Now identify the network adapter that you want to set the static ip, enp3s0d1 in this case.

The same has been done for the other computer and the name of the interface is enp9s0

From now one instead of listing the whole list we can use /sbin/ifconfig enp3s0d1 to list only the desired interface.

Non persisten method

Using the ip command we can set an IP to an interface.

Machine 1, enp9s0 interface.

To flush any old configuration

ip addr flush dev enp9s0

Now set the new IP

ip addr add 192.168.5.10/24 dev enp9s0

Machine 2, enp3s0d1 interface.

ip addr flush dev enp3s0d1

Set the ip with:

ip addr add 192.168.5.11/24 dev enp3s0d1

Using ifconfig you can see that the interface has the new IP now:

LAN setup

ip addr command example

Persistent method

To make the network persistent to reboots you need to edit interfaces file.

nano /etc/network/interfaces

The default file looks like this. Do not remove lo interface settings and append your configuration at the bottom of the file.

source /etc/network/interfaces.d/*

auto lo
iface lo inet loopback

Machine 1, enp9s0 interface.

Add the following configuration at the bottom of the file

## Set a static IP to enp9s0 interface
auto enp9s0
iface enp9s0 inet static
   address 192.168.5.10/24

Now restart the networking service using:

systemctl restart networking.service

Machine 2, enp3s0d1 interface.

Add the following configuration at the bottom of the file

## Set a static IP to enp3s0d1 interface
auto enp3s0d1
iface enp3s0d1 inet static
   address 192.168.5.11/24

Now restart the networking service using:

systemctl restart networking.service
LAN setup

networking file configuration


If you spot any typos, have questions, or need assistance with the build, feel free to contact me at: antonimercer@lthjournal.com

This guide contains no affiliate links or ads. If you'd like to support this or future projects, you can do so here:

By supporting monthly you will help me create awesome guides and improve current ones.


Technologies used

Debian 12, 10GbE, networking, ip, Mellanox Connect X-3, Finisar, OM3 fiber optic cable

Books are knowledge and knowledge is power.

After ending my studies, I always tried to dedicate some time to books. They helped me a lot and I want to dedicate a little space here as a greeting. From basics on different languages to more advanced level.