Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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-----/
share|improve this question
What happens when you plug them in using a cross over cable? – dbasnett Jul 5 '11 at 19:55

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

Subnet Mask:

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:

Subnet Mask:

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

share|improve this answer
Very good post, +1 – n0pe Jul 7 '11 at 15:02
up vote 4 down vote accepted

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.

share|improve this answer
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 – light24bulbs Feb 3 at 3:35

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|improve this answer
If it's not automatically handled, change IPv4 address settings in gnome control center to Link-Local Only, the default value is DHCP. – BornToCode May 15 at 5:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .