When an Ubuntu machine connected via Ethernet to a Windows host loses internet access, the issue typically stems from incorrect IP configuration, disabled Internet Connection Sharing (ICS), or firewall rules blocking traffic. Ensuring both systems are on the same subnet and that the Windows gateway is correctly configured for NAT is essential for restoring connectivity.
Understanding the Network Topology
In this scenario, the Ubuntu machine relies entirely on the Windows machine to route traffic to the external network. This setup requires the Windows PC to act as a router or gateway. The physical connection is direct, meaning there is no intermediate switch or router managing the IP assignment. Consequently, the Windows machine must be configured to share its own internet connection with the Ubuntu system. If this sharing mechanism is inactive or misconfigured, the Ubuntu machine will have link-local addresses but no path to the wider internet. The most common architecture involves enabling Internet Connection Sharing (ICS) on Windows. This feature automatically assigns a static IP address, typically192.168.137.1, to the Ethernet adapter that connects to the Ubuntu machine. It also sets up a DHCP server to handle requests from clients. Without this, the Ubuntu machine may not receive a valid IP address or, if it does, it will lack a default gateway pointing back to the Windows host.
Connecting to Ubuntu using ssh over Ethernet demonstrates how stable networking is crucial for remote access, which often fails when basic routing is broken. Similarly, understanding How do Ubuntu-server network interfaces work? helps diagnose why an interface might appear up but fail to route packets correctly.
Configuring Windows Internet Connection Sharing
To resolve the connectivity issue, you must first verify that Windows is correctly sharing its internet source. Start by identifying which network adapter has active internet access, such as Wi-Fi or a primary Ethernet port connected to your modem. Open the Network Connections control panel by pressingWin + R, typing ncpa.cpl, and hitting Enter.
Right-click the adapter with internet access and select Properties. Navigate to the Sharing tab. Check the box that says "Allow other network users to connect through this computer's Internet connection." In the dropdown menu below, ensure the home networking connection is set to the specific Ethernet adapter linked to the Ubuntu machine. Click OK to apply changes. Windows will reconfigure the selected adapter to use the static IP 192.168.137.1 with a subnet mask of 255.255.255.0.
If you have previously configured this setting manually, uncheck the box, click OK, and then re-check it to force Windows to reset the IP configuration. This action clears any stale DHCP leases or conflicting static assignments that might prevent the Ubuntu machine from communicating properly.
Verifying Ubuntu Network Configuration
Once Windows is configured, log into the Ubuntu machine. You can check the current network status by opening a terminal and runningip addr show. Look for the Ethernet interface, usually named eth0 or enp.... If ICS is working, the interface should have an IP in the 192.168.137.x range, and the output should show a default route pointing to 192.168.137.1.
If the IP address starts with 169.254, the machine is using a Link-Local address, indicating it failed to obtain an IP from the Windows DHCP server. To fix this, you can manually configure the network settings in Ubuntu. Go to Settings > Network, select the Ethernet connection, and change the IPv4 method from Automatic (DHCP) to Manual.
Enter the following details:
- Address:
192.168.137.100 - Netmask:
255.255.255.0 - Gateway:
192.168.137.1
ping 192.168.137.1. A successful reply confirms that the local link between the two machines is functional.
Troubleshooting Firewall and DNS Issues
If you can ping the gateway but cannot browse websites, the issue likely lies with DNS resolution or Windows Firewall rules. First, try pinging an external IP address like8.8.8.8. If this works but domain names fail, update the DNS settings on Ubuntu. In the manual IPv4 configuration mentioned above, add 8.8.8.8 and 1.1.1.1 as DNS servers.
If pinging 8.8.8.8 fails, the Windows Firewall may be blocking the forwarded traffic. On the Windows machine, open Windows Defender Firewall with Advanced Security. Ensure that "File and Printer Sharing" and "Network Discovery" are allowed on private networks. Additionally, check that the "Internet Connection Sharing" rule is enabled. Sometimes, resetting the firewall to default settings resolves obscure blocking issues.
Finally, restart the NetworkManager service on Ubuntu by running sudo systemctl restart NetworkManager. This clears any cached network states that might persist after changing configurations.
Frequently Asked Questions
Why does my Ubuntu machine show a 169.254 IP address?
This indicates that the machine could not reach a DHCP server to obtain a valid IP address. In this setup, it means the Windows ICS feature is either disabled or the Ethernet cable is faulty. Verify that ICS is enabled on the Windows side and that the physical link light is on.
Can I use a different subnet than 192.168.137.x?
While Windows ICS defaults to 192.168.137.0/24, you can manually assign static IPs on both machines within a different subnet, such as 10.0.0.0/24. However, this requires disabling the automatic DHCP role of ICS and manually configuring routing tables on both ends, which is more complex.
Does Windows Firewall block SSH connections from Ubuntu?
By default, Windows allows inbound SSH only if the profile is set to Private. If your Ethernet connection is classified as Public, Windows may block incoming ports. Change the network profile to Private in Windows Settings to allow standard management protocols like SSH.
What if I can ping the gateway but get no internet?
This suggests a DNS resolution failure rather than a routing problem. Configure Ubuntu to use public DNS servers like Google's 8.8.8.8 or Cloudflare's 1.1.1.1 in the network settings. This bypasses any potential DNS filtering issues on the Windows host.
Is it possible to connect multiple Ubuntu machines to one Windows PC?
Yes, as long as they are on the same subnet and the Windows machine has sufficient bandwidth. Each additional Ubuntu machine will need a unique static IP or must rely on the Windows DHCP server if ICS remains active. Ensure the subnet mask allows for enough available addresses.