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

36,429

Solution 1

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 2

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 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.

Share:
36,429
Elle Mundy
Author by

Elle Mundy

Updated on September 18, 2022

Comments

  • Elle Mundy
    Elle Mundy almost 2 years

    I'm looking for a way to directly connect my Windows 7 laptop and my headless Ubuntu 10.04 server. (Desktop edition is installed, for my own reasons.) I have a regular Ethernet cable. My problem is that I keep trying to use Windows Backup to a shared folder on Ubuntu, but the wifi connection keeps dropping intermittently for all my devices at the same time before the backup completes. I want to use the cable to connect the two computers directly, independent of whether or not they're connected to wifi. This will create a much more reliable connection, and it will allow the backup to complete without worrying about the wifi dropping.

    It would be best if I could create this connection using an ad-hoc network (or similar) on Windows 7 without touching the configuration on the Ubuntu server, as the server has no input devices or displays connected to it. I mostly access it through SSH and sometimes VNC, and if the connection is lost, the only thing I can do to get it back is a hard reboot.

    So the current configuration is this:

    Windows 7-------wireless-----\
                                  \
                                   Wifi router
                                  /
    Ubuntu 10.04----wireless-----/
    

    But I want it to be like this:

    Windows 7-------wireless-----\
       |                          \
       |cable                      Wifi router
       |                          /
    Ubuntu 10.04----wireless-----/
    
    • dbasnett
      dbasnett almost 13 years
      What happens when you plug them in using a cross over cable?
  • light24bulbs
    light24bulbs over 8 years
    The question isn't how to share an internet connection from one computer to another, it is how to join the two computers into one ad-hoc network. The internet connection is totally irrelevant to the problem
  • fikr4n
    fikr4n about 8 years
    If it's not automatically handled, change IPv4 address settings in gnome control center to Link-Local Only, the default value is DHCP.