How do I connect Ubuntu 10.04 and Windows 7 with an Ethernet cable?

Solution 1:

Most modern computers come with an ethernet adapter that has the capability to connect to another ethernet adapter without a crossover cable. This is called Auto-MDIX. Simply connect the network interface from one computer to the network interface on the other computer.

Once they're plugged in, there might be some sort of automatically-configured network setup. That may work in some cases, but not others. For fun and extra credit, let's create a new subnet for you to use just between the two computers.

First, we need to pick a "subnet" to use. It's easiest to use one different from your internal network. Let's choose 192.168.253.0/24. When you connect the two systems together, you'll need to give each system an IP address, as well as configure host names. Make sure you're configuring the wired, ethernet interface and not the wireless interface. All of this configuration can be done through the GUI.

Here's your network configuration for the Windows machine ("Use the following IP address"):

IP Address: 192.168.253.1

Subnet Mask: 255.255.255.0

Default Gateway: blank

While we're at it, don't configure DNS either, we'll do that later.

Here's your network configuration for the Ubuntu machine (Probably want to use some sort of "static" option, not sure on Ubuntu...)

IP Address: 192.168.253.2

Subnet Mask: 255.255.255.0

Default Gateway: blank

If everything's hooked up, you should be able to address each computer by their respective IP addresses. This lets you ensure that you are connecting to the wired, and not wireless interface. If you want to add hostname resolution, let's just make a change to the hosts file:

On Windows:

edit %SystemRoot%\system32\drivers\etc\hosts, notepad will do.

Add the following line:

192.168.253.2 ubuntu-wired

You can replace ubuntu-wired with whatever name you want to use for that system.

And save.

On Linux:

edit /etc/hosts, you'll need to do this as root with sudo or su.

Add the following line:

192.168.253.1 windows-wired

To test whether this works, ping each system using the name. The syntax is the same on both OSes. Open up a terminal window, and run the following:

ping HOSTNAME, where HOSTNAME is the name you used above for the opposite machine.

Solution 2:

Actually, I did some more poking around and found some answers myself, and it's really easy. There are two ways to do it: share the connection from Windows to Ubuntu, or from Ubuntu to Windows. Importantly, only one of these will work at a time, but doing both won't break anything. It just won't share the connection until you reverse one of them.

Windows 7 as the host

To share a wifi connection over ethernet directly to another computer from Windows 7:

  1. Open Network and Sharing Center.
  2. Right click Wireless Network Connection, click Properties.
  3. Click on the Sharing tab.
  4. Check the box next to "Allow other network users to connect through this computer's Internet connection."
  5. Click OK.
  6. Plug the Ethernet cable into both computers.

Ubuntu 10.04 as the host

To share a wifi connection over ethernet directly to another computer from Ubuntu 10.04:

  1. Right click on the Network Manager applet, click Edit Connections...
  2. In the Wired tab, click Auto eth0, then click Edit...
  3. In the IPv4 Settings tab, change Method: to Shared to other computers.
  4. Click Apply and enter your password when it asks you.
  5. Close everything and reboot.
  6. Plug the Ethernet cable into both computers.

Now both computers should have IP addresses different from those assigned by the wireless router, regardless of whether the host computer is connected to wifi. The host computer should have an IP address ending in .1, and the guest computer should have an automatically assigned address.

Solution 3:

Actually, you don't even need a crossover cable. Modern year 2000-ish network cards can support switching without a crossover cable; it's all internal.

Just plug-em' in and go. All of the networking will be automatically handled.