Skip to content

Instantly share code, notes, and snippets.

@CMCDragonkai
Last active October 27, 2022 22:29
Show Gist options
  • Save CMCDragonkai/59a61a3769835263ca84 to your computer and use it in GitHub Desktop.
Save CMCDragonkai/59a61a3769835263ca84 to your computer and use it in GitHub Desktop.
Network: Physical P2P Network

Physical P2P Network

It's possible to setup a direct ethernet connection, or a direct WLAN connection between 2 computers.

For direct ethernet, either get a ethernet crossover cable (different from the standard patch cable), and connect up the 2 computers. Or detect if both computer's NIC supports Auto-MDIX (using ethtool) feature (most modern NICs do), and just connect up a normal patch cable between the 2 computers. Then configure the new connection, in both computers, and setup a subnet and the 2 computer's respective IP address and now you have a personal direct network between the 2 computers. No DHCP required, no DNS required.

Note that the above configuration is pretty much equivalent to setting up a virtual ethernet pair when using network namespaces. Further iptables and routing tables fiddling would allow you to share an internet connection from one computer to another.

For WLAN, this is called Ad-hoc networking, and it's even more flexible. You can do funny things like 3 way P2P networking, mesh networking (allowing transitive networks), or non-transitive networks. See these resources to get started:

The advantages of all this is that you don't need a central controller, router, bridge or anything else to start a network. Now you should be able to simply share a file, or broadcast messages to other computers easily.

Try to run a simple commandline HTTP server to share files, or even use socat/netcat/ncat to send simple messages to each other. Try an echo server and telnet server too.

Things to try:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment