2 ms·
Two devices connected to each other are just another form of LAN - one with 2 nodes instead of many. You can manually configure IPs without a router exactly as
by zamadatix 2mo ago
Two devices connected to each other are just another form of LAN - one with 2 nodes instead of many. You can manually configure IPs without a router exactly as this article demonstrates:
# On sender...
ip address add dev eth0 fd42:dead:beef::1/48
ip link set dev eth0 up
# On receiver...
ip address add dev eth0 fd42:dead:beef::2/48
ip link set dev eth0 up
The first 2 lines are run on one host and the second two lines on the second host. The 1st line of each segment sets the IPv6 address to use and the second line of each segment makes the adapter enabled. Plug an ethernet cable in and they can reach each other. As to why, just think of it as "the same way the computer would figure out how to send a packet to the gateway, just to another client in the network segment instead"
You only need a router set up to go to a different subnet. If both hosts are in the same subnet then it's just a neighbor resolution (well, you can do neighbor discovery manually too if you really want... but, since it's automatic, no reason too) followed by ethernet bridging.
Two hosts with nothing else just plugged into each other should actually already have assigned themselves IPs you could use for this though. They are known as IPv6's link local addresses and are explicitly meant for communication on the local subnet.
Ethernet & IP are fun abstractions to really get into the weeds about. When it comes to running networks it's actually a bit of a fight to try to make sure only the addresses the router allows can be used! A whole bevy of technologies address that for the different protocols.