I wanted to reach an Ubuntu machine from Windows with one Ethernet cable between them. The first suggestion was to give the Windows Ethernet port the address 192.168.1.1 and the Ubuntu port 192.168.1.2. That raised my next question. Both addresses and the network they belonged to were already in use. Would changing just the last number help?
Why does the cable need its own address range?
Suppose the Windows Wi-Fi address is 192.168.1.30 with a subnet mask of 255.255.255.0. The mask tells Windows which addresses it can reach directly on that connection. Here the first three numbers identify the network, so Windows treats 192.168.1.2 and 192.168.1.92 alike: both belong to the Wi-Fi subnet, written 192.168.1.0/24. Giving Ethernet an address in that same subnet creates two possible paths to those destinations. Windows can end up looking for Ubuntu on Wi-Fi.
Choose a private subnet that is free on both machines.1 To check, keep your usual connections active, including any work VPN (virtual private network). Run route print -4 on Windows and ip -4 route on Ubuntu. These commands list the address ranges each machine already knows how to reach. For example, a work route covering 10.0.0.0/8 covers every address starting with 10., so choose a range outside it. The default route (0.0.0.0/0, or default on Ubuntu) is the fallback for other destinations and can stay in place.
What do I enter on each machine?
Plug the cable into the two Ethernet ports. With no router on the cable to hand out addresses, you can enter a fixed IPv4 address on each end. Assuming 10.10.10.0/24 is free, use these settings:
| Ethernet setting | Windows | Ubuntu |
|---|---|---|
| IPv4 address | 10.10.10.1 | 10.10.10.2 |
| Subnet mask | 255.255.255.0 | 255.255.255.0 |
| Default gateway | Leave blank | Leave blank |
| DNS servers | Leave blank | Leave blank |
A default gateway forwards traffic to other networks. Both addresses are on the cable, so the machines can send directly to each other. DNS translates names to addresses, and we'll connect using Ubuntu's address. Wi-Fi can keep its existing gateway and DNS settings.
On Windows, press Win + R, enter ncpa.cpl, and press Enter. Right-click the Ethernet adapter connected to Ubuntu, open Properties, then double-click Internet Protocol Version 4 (TCP/IPv4). Select Use the following IP address, enter the Windows values above, and click OK. Run ipconfig and check that 10.10.10.1 appears under Ethernet.2
On Ubuntu Desktop, open Settings → Network and click the gear beside the Wired connection. Under IPv4, choose Manual and enter the Ubuntu address and mask. Click Apply, then turn the wired connection off and on to activate the saved settings.3 Run ip -br -4 addr in a terminal. The wired interface should now show 10.10.10.2/24.
How do I check that Windows is reaching Ubuntu over the cable?
From Windows PowerShell, run:
ping -4 10.10.10.2
A reply from 10.10.10.2 means Ubuntu received the request and Windows received its reply. If it times out, run Test-NetConnection 10.10.10.2 -DiagnoseRouting in PowerShell. Look for SelectedSourceAddress: with the example settings it should be 10.10.10.1. A Wi-Fi source address is a reason to recheck the two subnets. If Windows selected Ethernet, check that the wired connection shows a physical link at both ends and that Ubuntu has the expected address.
For a remote terminal, Ubuntu needs to be running a Secure Shell (SSH) server. If one is already running, try ssh username@10.10.10.2 from Windows, using your Ubuntu login name. You can also run Test-NetConnection 10.10.10.2 -Port 22 to test the usual SSH port while keeping both firewalls enabled. If TcpTestSucceeded is True even though ping timed out, the SSH port is reachable; the two tests use different kinds of traffic.
This gives Windows a direct path to Ubuntu while Wi-Fi can still carry internet traffic. I wrote about the additional goal of giving the development machine internet access in Bridging Wi-Fi and Ethernet in Windows.
Footnotes
-
Rekhter, Y., Moskowitz, B., Karrenberg, D., de Groot, G. J., & Lear, E. (1996, February). Address allocation for private internets (RFC 1918, §3). RFC Editor. Private address space. ↩
-
Microsoft. (n.d.). ipconfig. Microsoft Learn. Command and output fields. ↩
-
Ubuntu Documentation Team. (n.d.). Manually set network settings. Ubuntu Desktop Guide. Wired connection and manual IPv4 settings. ↩