Monday, December 29, 2008

Windows ICS 192.168.0.1 Conflict

These instructions will tell you how to use Windows Internet Connection Sharing to extend an Internet connection to a GNU/Linux system when there is another network node that wants the same IP address that Windows ICS does (192.168.0.1.) In my case, I wanted to connect to a WAP+NAT machine that insisted on that same IP address, but I had no wireless adapters for my GNU/Linux system which could get a reception (due mostly to damaged antennae.)

First enable internet connection sharing on the interface you want by right clicking the interface with your internet connection and choosing 'Properties.' Navigate to the 'Advanced' tab and enable 'Share this Connection.'

Next open a command line interface (CLI) by choosing Start Menu/Run, or just hit "Microsoft key"+R. Enter the command 'cmd' and hit enter or 'Ok.'

From that CLI you'll want to enter another CLI with the 'netsh' command. You should now have a 'netsh' prompt. Enter the command 'interface ip' and hit enter. This should have expanded your netsh prompt a bit. Next type 'dump' to get a look at the current settings of your network interfaces. The information dump is delivered in a convenient form: a series of commands you could theoretically copy and paste verbatim, but it makes this guide a little harder to read.

netsh interface ip>dump
# Interface IP Configuration for "Local Area Connection"

set address name="Local Area Connection" source=static addr=192.168.1.1 mask=255.255.255.0
set dns name="Local Area Connection" source=static addr=none register=PRIMARY
set wins name="Local Area Connection" source=static addr=none

# Interface IP Configuration for "Wireless Network Connection"

set address name="Wireless Network Connection" source=dhcp
set dns name="Wireless Network Connection" source=dhcp register=PRIMARY
set wins name="Wireless Network Connection" source=dhcp

popd
# End of interface IP configuration
netsh interface ip>

Those 'name' descriptors in there identify the network interfaces we are to work with. Since my internet connection is through "Wireless Network Connection," I will be making my changes to "Local Area Connection." Next you'll want to use the 'set' command to assign a new IP address to the sharing end (as opposed to the internet end) which will look something like this:

netsh interface ip> set address name="Local Area Connection" source=static addr=192.168.1.1 mask=255.255.255.0

That should be it on the Windows end. Ping google.com or something to make sure your connection is still working! (If you're connecting a Windows system to the net via ICS, you can use a similar procedure to set the IP address on the client system. However the GUI route will work just as well on the client system.)

Onto the GNU/Linux end. Debian and Ubuntu users can edit their /etc/network/interfaces file (read `man 5 interfaces` for more info) so that it has an entry looking something like this:

iface eth0 inet static
address 192.168.1.8
netmask 255.255.255.0
pointopoint 192.168.1.1
gateway 192.168.1.1
post-up echo nameserver 192.168.1.1 > /etc/resolv.conf

Then you can make sure the changes take effect:

# ifdown eth0
# ifup eth0

If you can't or won't use /etc/network/interfaces, you can do things a bit more manually:

# ifconfig eth0 up 192.168.1.8 pointopoint 192.168.1.1
# echo nameserver 192.168.1.1 > /etc/resolv.conf

These instructions will assign the IP address 192.168.1.8 to your GNU/Linux system, but you can just as easily use another address. Be careful to spell pointopoint correctly -- it's POINT O POINT, not POINT TO POINT!!! The error message for that mistake is not very helpful at all!

Try to ping your Windows system to make sure the connection is up. We'll need to alter the kernel routing table next, adding a default gateway (gw) like this:

# route add default gw 192.168.1.1

Now try to ping an IP address out there on the 'net (try 208.67.222.222: an OpenDNS server.) If that's all working, go ahead and modify your /etc/resolv.conf file to match the IP address of your Windows system! It should read something like this:

nameserver 192.168.1.1

Once that's done, you should be able to ping google.com and expect a response! If anything doesn't work, remember to double-check that it's still working from your Windows system before you waste any time thinking you did something wrong on the GNU/Linux end! If something did go wrong on that end, use `route -n` to make sure the routing table looks how you wanted it to. Happy trails!

2 Comments:

Blogger TearsFall said...

Windows7 Internet Connection Sharing (ICS) with Ubuntu 9.04 box

Dell Dimension 8300 desktop running Win7 and using a USB N-band WLAN adapter as the connection to the internet (the N-band WLAN router is at the other end of the house and diagonally downstairs). A 5-port networking switch connects the Dell's 10/100 LAN card via standard CAT5 cables to a homebuilt AMD desktop running Ubuntu 9.04, freshly installed and yet to be updated. Had I not had an available switch sitting around, I would have used a cross-over CAT5 LAN cable - it should provide the same experience as the switch as long as one is only using two systems.

Preparations:

The Dell's WLAN connection was established and verified working and able to browse the internet.

Both the WIN7 and the Linux box have identical "name and password" accounts and are running using those same accounts. Convenience over security has both machines automatically defaulting to the desktop of that account at boot.

The LAN cards on both boxes are lit and seeing the connection between the units. The lights on the switch confirm the network handshake.

ALL connections are set to be automatically assigned an IP and DNS... except for the one exception listed below, and only then if auto mode doesn't work.


The Necessary Steps:

1) In the system tray of the Dell, I left-clicked the networking icon (right-click would work too). I chose "OPEN NETWORK AND SHARING CENTER" from the bottom of the popup.

2) Under "View Your Active Networks" and to the right of "Connections" (the first one in my case), I left-clicked on "WIRELESS NETWORK CONNECTION", then chose the "PROPERTIES" button at the bottom of the popup.

3) I chose the "SHARING" tab, then put a check in the first of the two available boxes - that enables ICS. I clicked "OK" on the popup that tells me that it will automatically assign an address of 192.168.137.1 to the LAN connection. I then click "OK" at the bottom of the "SHARING" page. This will bring you back to the NETWORK AND SHARING CENTER where you should see the Wireless and the Local Area connections showing "INTERNET" as each one's Access Type (it sometimes is delayed a few seconds). If not, try repeating step 2, deselecting the check box and again clicking "OK", then repeating steps 2 and 3. If it proves stubborn, reboot and try steps 1 through 3 again.

4) Final step: I then turned to the Linux box, opened the Network icon, and left-clicked on its "auto eth0" connection icon to force it to recognize the new connection. Once reconnected, I could browse the internet and perform updates.

October 25, 2009 10:54:00 AM EDT  
Blogger TearsFall said...

Windows7 Internet Connection Sharing (ICS) with Ubuntu 9.04 box (continued...)

If this still doesn't work, try turning off any and all virusscan and firewall and anti-spyware software running in the system tray and try again. Your router should provide enough firewall protection until you figure it out. Just FYI, I use the standard WIN7 firewall, AVAST AV, and no anti-spyware program that runs in the background, and needed to turn off nothing for this to work.

If this still isn't working, check the assigned IP address of the Linux LAN card... it has to be 192.168.137.xxx something - where XXX is NOT equal to "1". If it is not, try manually assigning a static IP address in that format, and make xxx something between 2-254, subnet 255.255.255.0, default route AND primary DNS 192.168.137.1 each. Then attempt to activate ICS again using steps 1 through 3. This is the "one exception" where automatically assigning IP and DNS may not function correctly - but did in my case.


Be aware and BEWARE - ICS [in the WIN7 RC Build 7100 I have, at least] is very unstable and disconnects a LOT. When it does, remove the ICS on the first machine by following steps 1-2, uncheck, "OK", then repeat steps 1-3, and it should reconnect - for another short time, at least.

ICS is really only suitable for quick and dirty temporary connections for the purpose of doing experimental work and quickie system updates for friends, for instance, and only when it just isn't practical to run cable to the main router and the computer you are connecting simply doesn't have a WLAN card. A cheap and simple WLAN USB adapter would be much much easier. So would a CAT5 connection to the main router if the distance is short. I only used it in this circumstance because the router is all the way on the other side of the house and impractical to stretch a wire to, and my only USB WLAN adapters are not Linux compatible. I had a couple short cables and a switch, so decided to use them. It took me 2 weeks of off and on research and trial and error... it would have been vastly easier to drag the Linux box downstairs or buy something compatible. Just call me stubborn.

October 25, 2009 10:59:00 AM EDT  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home