Connecting Two Raspberry Pi 4s via Ethernet Ports: A Step-by-Step Guide

Abstract: Configure static IPs on two Raspberry Pi 4s to establish a direct Ethernet link for file sharing and SSH without a router.

Created: 2026-09-24 by

Connect two Raspberry Pi 4s directly via Ethernet by assigning static IP addresses on the same subnet and disabling conflicting services like dhcpcd. This creates a stable point-to-point link for file sharing or SSH access without requiring a router, switch, or complex network configuration.

Hardware Requirements and Physical Connection

To establish a direct connection between two Raspberry Pi 4 models, you need minimal hardware. Both devices must have their built-in Gigabit Ethernet ports available. You will also need an Ethernet cable. Modern switches and routers often support Auto-MDI/MDIX, which allows standard patch cables to work regardless of wiring order. However, when connecting two devices directly without intermediate networking gear, it is safest to use a crossover cable to ensure the transmit pins on one device align with the receive pins on the other. If you only have a standard straight-through cable, many modern network interface controllers (NICs) can automatically detect the polarity and adjust internally, but a crossover cable guarantees compatibility across all hardware revisions. Connect one end of the cable to the Ethernet port of the first Raspberry Pi and the other end to the second Pi. Ensure both devices are powered on and connected to their respective power supplies. The link LEDs on the Ethernet ports should illuminate, indicating a physical layer connection has been established. If the lights do not turn on, check the cable integrity and ensure the ports are not obstructed by dust or debris.

Configuring Static IP Addresses

The most critical step in this setup is assigning static IP addresses. By default, Raspberry Pi OS uses dhcpcd to request an IP address from a DHCP server via DHCP. Since there is no router or DHCP server in a direct peer-to-peer connection, the devices will fail to obtain an address unless we override this behavior. We must configure a static IP for each Pi on a private subnet that does not conflict with your main home or office network. A common choice for a direct link is the 192.168.50.x range. Assign 192.168.50.1 to the first Pi and 192.168.50.2 to the second. Do not assign a gateway or DNS server, as these are irrelevant for local-only communication and can cause routing conflicts if the Pi attempts to reach the internet through the wrong interface. Edit the network configuration file using a text editor with root privileges:
sudo nano /etc/dhcpcd.conf
Add the following lines at the bottom of the file, replacing eth0 with your actual interface name if different (check with ip addr):
interface eth0
static ip_address=192.168.50.1/24
nohook wpa_supplicant
Repeat this process on the second Pi, changing the ip_address to 192.168.50.2/24. The /24 suffix denotes the subnet mask 255.255.255.0, ensuring both devices recognize each other as being on the same local network segment. After saving the file, restart the networking service or reboot the device for changes to take effect:
sudo systemctl restart dhcpcd
Verify the configuration by running ip addr show eth0. You should see your assigned static IP listed under the interface.

Testing Connectivity and SSH Access

Once both Pis have their static IPs configured, test the connection from one device to the other. Open a terminal on Pi 1 and ping Pi 2:
ping 192.168.50.2
If you receive replies, the physical and network layers are functioning correctly. You can now establish an SSH session to transfer files or manage the remote device. Use the following command from Pi 1:
ssh [email protected]
Replace pi with your actual username if you changed it during setup. Enter the password when prompted. For enhanced security and convenience, consider setting up SSH key-based authentication so you do not need to type passwords repeatedly. This direct link is ideal for low-latency tasks, such as transferring large datasets between devices or running distributed computing tasks locally. Note that if you intend to share internet from one Pi to the other over this same cable, you would need to enable IP forwarding and set up NAT (Network Address Translation). However, for simple peer-to-peer communication, no additional routing configuration is required. Adding a default gateway in this scenario would be incorrect, as it might cause traffic intended for the local link to be routed out to your main internet connection incorrectly. For more complex networking scenarios involving multiple devices, see Modem/Router: One to Multiple Computers via Ethernet.

Troubleshooting Common Issues

If the ping fails, verify that firewalls are not blocking ICMP packets. On Debian-based systems, UFW (Uncomplicated Firewall) may be active. Check its status with sudo ufw status. If it is enabled, allow incoming ICMP traffic or SSH connections temporarily for testing:
sudo ufw allow from 192.168.50.0/24
Another common issue is interface naming. While eth0 was standard in older versions, newer Raspberry Pi OS releases may use end0 or similar names due to systemd-networkd integration. Always confirm the correct interface name using ip link before editing configuration files. Additionally, ensure that dhcpcd is not being overridden by NetworkManager or systemd-networkd, which can happen if multiple network management tools are installed simultaneously. Stick to one management tool to avoid conflicts. For issues related to network masks or PoE configurations that might interfere with standard Ethernet links, refer to Flashed a wrong network mask in a PoE device.

Frequently Asked Questions

Can I use a standard straight-through Ethernet cable instead of a crossover cable?

Yes, most modern Raspberry Pi 4 Ethernet controllers support Auto-MDI/MDIX, which automatically detects the cable type and adjusts the pinouts accordingly. This means a standard patch cable will work just as well as a dedicated crossover cable for direct device-to-device connections.

Why did my previous attempt result in "Destination Host Unreachable"?

This error typically occurs because the devices are on different subnets or lack a valid route to each other. Ensure both Pis have static IPs within the same subnet (e.g., 192.168.50.x) and that the subnet masks match exactly. Also, verify that no firewall rules are blocking ICMP echo requests.

Is the Raspberry Pi 4 Ethernet port limited to 100Mbps?

No, the Raspberry Pi 4 features a Gigabit Ethernet controller capable of speeds up to 1Gbps. The limitation to 100Mbps often seen in older models like the Pi 3 is not present here. Ensure your crossover cable is Cat5e or higher to support gigabit speeds.

How do I stop these Pis from trying to connect to my main Wi-Fi network?

You can disable Wi-Fi entirely by adding dtoverlay=disable-wifi to the /boot/firmware/config.txt file. Alternatively, you can configure wpa_supplicant to ignore known networks or simply remove the Wi-Fi credentials if they are not needed for this isolated setup.

Can I share internet from one Pi to the other over this link?

Yes, but it requires additional configuration beyond static IPs. You must enable IP forwarding in /etc/sysctl.conf and set up iptables rules to perform NAT (Masquerading) on the Pi acting as the gateway. This turns the direct link into a routed connection rather than a simple peer-to-peer link.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More