Ubuntu Windows Networking – Connect Ubuntu 10.04 and Windows 7 with Ethernet Cable

networkingubuntu-10.04windows 7wired-networking

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

Best Answer

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.

Related Question