Transfer files over an ethernet patch cable
Transfer files over an ethernet patch cable
通过以太网跳线传输文件
Technical note: transfer files over an ethernet patch cable 2026-08-29 技术笔记:通过以太网跳线传输文件 2026-08-29
It’s possible to just connect two computers together with Ethernet and do a bit of IP configuration: 只需用以太网线将两台计算机连接起来,并进行简单的 IP 配置即可实现:
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
After a few seconds, pings should work: 几秒钟后,ping 命令应该就能通了:
On receiver…
在接收端…
ping fd42:dead:beef::1
64 bytes from fd42:dead:beef::1: icmp_seq=1 ttl=64 time=0.649 ms 64 bytes from fd42:dead:beef::1: icmp_seq=2 ttl=64 time=0.376 ms 64 bytes from fd42:dead:beef::1: icmp_seq=3 ttl=64 time=0.414 ms 64 bytes from fd42:dead:beef::1: icmp_seq=4 ttl=64 time=0.340 ms
… and so should this: … 接下来执行此命令也可以:
On receiver…
在接收端…
socat - TCP6-LISTEN:1234 | dd status=progress > big_file.tar.gz
On sender…
在发送端…
socat - ‘TCP6-CONNECT:[fd42:dead:beef::2]:1234’ < big_file.tar.gz
These commands assume you are using Linux, but this trick works everywhere. A nothing-special patch cable and ethernet jack should have no problem hitting ~900 Mbits/second, which is 6.7 GB per minute. Fancy network cards will allow speeds orders of magnitude faster, but it’s already much faster than USB flash or cloud storage. 这些命令假设你使用的是 Linux,但这个技巧在任何地方都适用。普通的跳线和以太网接口可以轻松达到约 900 Mbits/秒的速度,即每分钟 6.7 GB。高端网卡可以实现快几个数量级的速度,但这已经比 USB 闪存或云存储快得多了。
Other options … for transferring a file larger than 10 GB or so between two machines a few meters apart. 在相距几米的设备间传输超过 10 GB 的文件时,还有其他选择:
Cloud storage: upload it to a server and download it from the other machine. In most cases, this will be glacially slow, both because of slow internet connections and cloud providers throttling traffic. Worse, the file has to be transferred over the network twice which doubles the time it takes. Also, it can be expensive unless you already have a suitable server. 云存储:上传到一个服务器,再从另一台机器下载。在大多数情况下,这会慢得像蜗牛一样,原因在于互联网连接速度慢以及云服务商的流量限制。更糟糕的是,文件必须在网络上传输两次,这使所需时间翻倍。此外,除非你已经拥有合适的服务器,否则这可能会很昂贵。
Direct TCP over LAN is better, but WiFi is still quite slow and with random dropouts: those multi-gigabit speed claims are dubious at best and certainly won’t be reached in a typical home networking environment (walls, interference, long distances, etc). However, if your house is wired for gigabit Ethernet, this can work great. 通过局域网进行直接 TCP 传输更好,但 WiFi 仍然很慢且存在随机掉线问题:那些所谓的“多千兆”速度声明充其量是值得怀疑的,在典型的家庭网络环境(墙壁、干扰、长距离等)中肯定无法达到。不过,如果你的房子预埋了千兆以太网线,这种方法效果会很好。
Removable storage is quite slow unless you are willing to spend a lot of money. Even if you do, it’s often limited by the cable: USB theoretically supports high speeds… with a (near mythical) perfect cable and pristine connectors. I have only single cable and peripheral pair that actually reaches gigabit speeds, which has an MSRP of ~2300$. (and that only works if plugged into the right USB port at the right angle). Also, it has the same problem as cloud storage, having to copy data on and off the drive effectively halves the speed. Unlike Ethernet, directly connecting two computers together won’t work because USB is based around a host/device distinction. 可移动存储设备非常慢,除非你愿意花大价钱。即使你愿意,它也经常受到线缆的限制:USB 在理论上支持高速……前提是拥有一根(近乎神话般的)完美线缆和原始状态的接口。我只有一套线缆和外设组合能真正达到千兆速度,其建议零售价约为 2300 美元(而且只有在以正确的角度插入正确的 USB 接口时才有效)。此外,它和云存储有同样的问题,必须将数据拷入再拷出驱动器,这实际上使速度减半。与以太网不同,直接连接两台计算机是行不通的,因为 USB 基于主机/设备(host/device)的区分。
Really, Ethernet is the only common connection that can reliably reach gigabit speeds between two random devices using inexpensive cables. It’s also truly differential (with transformers!) which makes it resistant to RFI and ground level shifts. I think it’s underappreciated for non-internet applications and doesn’t even need a local network: point to point wiring is perfectly fine. It also doesn’t need a TCP/IP stack: raw link-layer frames are perfectly fine even on a switched LAN. This makes for a very simple way to move data to and from a microcontroller. 事实上,以太网是唯一一种能够使用廉价线缆在任意两个设备之间可靠地达到千兆速度的通用连接方式。它也是真正的差分信号传输(带有变压器!),这使其能够抵抗射频干扰(RFI)和地电位偏移。我认为它在非互联网应用中被低估了,甚至不需要本地网络:点对点布线完全没问题。它也不需要 TCP/IP 协议栈:即使在交换式局域网中,原始链路层帧也完全适用。这为微控制器之间的数据传输提供了一种非常简单的方法。
Related: ethtransfer.sh: A simple shell script for file copies 相关内容:ethtransfer.sh:一个用于文件拷贝的简单 Shell 脚本