how can I set up a P2P ethernet connection

I've searched and not found anything of substance. I remember reading the ethernet whitepaper and (if memory serves) it should be possible to eddit the ethernet connection on one pc to act as a slave/modem to connect another pc.

I know that it's theoretically possible because it automatically negotiates the connection, but even having connected both PCs and trying to configure the software I still can't get a connection

in short I want PC-to-PC networking with ethernet

inb4. buy switch - no, can't do.

FYI - I'm using GNU/Linux 5.8.0-53 - ubuntu 20.04


Solution 1:

I have tried to configure eno1 as a slave (no-go), then I tried to assign an ip to the port (no-go), I also tried to bridge it to a loopback and bond it as well, but I'm too inexperianced to get it working

Don't do any of that.

Ethernet connections have nothing to do with "modems", "slaves", "loopback", "bonds", or such. There is no special hardware mode (like there would be with Wi-Fi) – Ethernet already is a P2P connection, so most of the time it really is just "connect and configure IPs".

In particular, there's nothing special about direct connections between two computers – it works exactly the same as connecting them through a switch. (Maybe 15 years ago you needed a special cross-over cable, but other than that, everything else still was the same as connecting them through a switch. Now you don't even need the special cable, any old Cat5 cable will do.)

  1. First, on a physical level, take a standard Ethernet Cat5/6 cable, connect both ends to computers, and they should both indicate "Link up". That's usually it.

    For the moment, ignore the IP addresses (or lack thereof), just make sure that both ports establish an Ethernet link. For example, on Linux running ip link or ip addr should show the 'LOWER_UP' flag:

    2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP>
    

    (The <UP> within brackets indicates that the interface is enabled at OS level; if that's missing run 'ip link set eno1 up'. On the other hand, <LOWER_UP> as well as state UP indicate that the physical status is okay. If you see NO-CARRIER, that's the opposite of LOWER_UP and indicates that the physical connection cannot be established.)

    If they don't – try a different cable. A premade one that already has the connectors from factory, instead of them being hand-crimped afterwards, might work better.

    (There are some laptops with Ethernet NICs which can't establish a link when paired together, no matter what cable, even though they seem to work just fine with other devices.)

There's only one difference compared to connecting devices through a router – the lack of automatic IP address configuration (usually), because there is no device that'd act as a DHCP server. (This is the same whether you use a switch or not.)

  1. Now that the physical connection is working, configure IP addresses.

    If you're using NetworkManager, open either Ubuntu's network settings or nm-connection-editor, edit the Ethernet connection profile, and change the IPv4 settings to Manual. Then configure both hosts to have different IP addresses on the same subnet.

    For example, one host could be 10.0.0.1 and the other 10.0.0.2. (The netmask 255.255.255.0 will work, as will 255.255.0.0 and others. Make sure the netmask is identical on both hosts.) You don't need to add any routes, DNS servers, domain suffixes, etc.

    Make sure the connection profile is applied – ip addr should show the address that you've added.

To repeat: In case of physical problems, do not waste time with IP addresses if the interface doesn't indicate that physical link is up. That'd be like trying to adjust TV channels when the power is out.