# Tutorial: Connecting linux box to the internet through windows ICS



## Supernoobs (Aug 13, 2002)

Hey guys, I've written a short tutorial on how to connect a linux computer (Debian) to the internet with only one internet connection available on a windows box.

In this article I'm going to explain how to connect two computers to the internet with one internet connection. I needed to do this because I have one Linux box on my room and one Windows XP computer. The problem is that I have only one network cable leading to my room. Luckily Windows XP has a nifty feature called Internet Connection Sharing.

I had to install a second network card first to get a connection between the linux and windows computer. I used a cross bridged cable to connect them. Once the physical connections were made, I booted into my windows XP computer and opened the Network Connections window. I double clicked on the card I want to use for the actual internet connection and activated ICS in the advanced tab. Make sure the TCP/IP settings are set to "obtain an IP address automatically". This makes sure it uses the DHCP server to get the IP address.

This is what you should see:










Next I double clicked the card I want to use for the connection between the windows and linux computer and made the IP address 192.168.0.1. Make sure this address doesn't exist on your network otherwise you'll get problems.

Then on the linux box, open "/etc/network/interfaces" in your favourite text editor. This is what you should see (nevermind the loopback connection):

auto lo eth0
iface eth0 inet dhcp

Change this to:

auto lo eth0
iface eth0 inet static
address 192.168.0.2 
netmask 255.255.255.0 
network 192.168.0.0 
broadcast 192.168.0.255 
gateway 192.168.0.1

So this is what you should see now:










Save everything and now open "/etc/resolv.conf" in the text editor. Comment out all the lines and add this line "nameserver 192.168.0.1". Now it should like something like this:










Save the changes and exit the text editor. Back in the shell reboot the network by typing "/etc/init.d/networking restart". When the network has been rebooted, try ifconfig to check your settings:










Now "ping 192.168.0.2". If you are getting results your loopback connection is good. Press CTRL-C to stop the pinging. Now "ping 192.168.0.1". If this works your connection between the linux and windows box is established. And as for the last test, "ping www.google.com". If this gives results your internet connection has been shared and you can now access the internet with two computers!


----------



## I Fix 4 U (Jul 19, 2004)

Thanx for the info, lotsa people may use it. :up: maybe you will get a sticky or a link to this post mentioned in the linux faq sticky.


----------



## lynch (Aug 3, 2002)

Maybe you could scale down the 1st image so everybody does'nt have scroll sideways to read this thread.
lynch


----------



## Supernoobs (Aug 13, 2002)

ok, sorry, I scaled the first image down.


----------



## I Fix 4 U (Jul 19, 2004)

Nice now it's perfect.


----------



## Supernoobs (Aug 13, 2002)

thanks for the kind replies iXneonXi, it always feel good to get a positive feedback


----------



## lynch (Aug 3, 2002)

Looking good, supernoobs.


----------



## Squashman (Apr 4, 2003)

Why not just let the Linux box get an IP address from the Windows Box. When you run ICS, it acts as a DHCP server as well. Are you sharing a Broadband connection? Why not just buy a router?


----------



## I Fix 4 U (Jul 19, 2004)

Why buy a router when u can save money and do it this way?


----------



## Squashman (Apr 4, 2003)

Speed and Stability. 
1) You are slowing down the computer that is running ICS.
2) We all know ICS is a pain in the @$$ and tends to crap out alot.
3) A less than $20 router is well worth my time.


----------



## I Fix 4 U (Jul 19, 2004)

Most decent routers I find are over $40.


----------



## Squashman (Apr 4, 2003)

iXneonXi said:


> Most decent routers I find are over $40.


More power to you then. I am cheap and none of my routers have failed me in over two years. Maybe I am just lucky.


----------



## I Fix 4 U (Jul 19, 2004)

I like to go with popular names like dlink and linksys.


----------



## Supernoobs (Aug 13, 2002)

Squashman said:


> Why not just let the Linux box get an IP address from the Windows Box. When you run ICS, it acts as a DHCP server as well. Are you sharing a Broadband connection? Why not just buy a router?


I am sharing a broadband connection, but i already got it hooked on a router. What I am doing now is splitting an internet connection once at router level and then a second time in my room using ICS. 
I have a spare router lying around but I didn't want to use it because of the instability of the router. It's a dlink but it tends to overheat. I have had nothing but problems with routers and if I would have the room and extra computer I would replace the router with a linux box that acts as a router.

I'm using a static ip address simply because I can. It's easier to remember the static ip address then having to look it up first. Certainly when you plan on connection multiple computers using ICS. But you are correct, I should include the option to use DHCP, I haven't tried this yet though.



Squashman said:


> Speed and Stability.
> 1) You are slowing down the computer that is running ICS.
> 2) We all know ICS is a pain in the @$$ and tends to crap out alot.
> 3) A less than $20 router is well worth my time.


I don't agree with you that a router brings more stability and speed, at least not for the routers i have tried (a dlink and a linksys, so they should be good?). I believe a well configure linux box can bring more stability and speed then most of the routers can, not to mention the extra options.
I haven't had any problems with ICS yet, but I agree with you that the ICS function included in windows XP is not very configurable and could, sooner or later, lead to problems when trying more advanced things.

I haven't noticed a slow down on my windows box yet, but my main purpose is to give the debian computer internet access to download updates and sometimes browse the web. I don't intend to use it for heavy downloading tasks, but I'll let you know if I find a slow down.


----------



## I Fix 4 U (Jul 19, 2004)

No, a linux box as a router should be great and due to the OS and GUI given, should have much more features than a standard router, which is good and is why companies use linux servers over the choice of using a large router box. My school once had one giant router box but the server now sits there and has many ethernet cables connected to it and the network experiences no slowdowns unless the principal happens to be downloading something.

I just say I've never had problems with my D-Link router, it does get warm, as does my friend's d-link, but we have never had any problems with them.


----------



## Squashman (Apr 4, 2003)

What I meant by speed was you would be slowing down the person using the Windows PC, but yes a router should also be faster networking wise then a pc with ICS. All you really need is a switch, not another router. I have run 8 port linksys routers on our school's library when we needed extra network jacks. They are still running after two years. Have never had to power cycle them.

You have to be the first person I met who thinks ICS is better then a dedicated router. Well, I guess there are firsts for everything.


----------



## I Fix 4 U (Jul 19, 2004)

Yes, I will agree to you there, I am a multi-sided person. For his case I'd just say a switch would be good, but at the front (tho quite unnecessary unless you have a larger network) a computer would be better IMO instead of just a router, unless it is a *very* pro router.


----------



## codejockey (Feb 11, 2002)

Add my vote to the router/switch side of the discussion. Among other advantages, you don't have to run (in this case) the Windoze computer just to access the (remote or local) network. I've done it both ways, and will choose a router/switch solution every time, given the choice. That said, however, the info in the original post (tutorial) is still valuable -- it never hurts to have another tool in your toolbox.


----------



## jiml8 (Jul 3, 2005)

I used to connect my LAN to the net through my Linux box. Worked well.

I switched to a router appliance only because I am all the time messing with my computer and, when my messing would break it, my home LAN internet connection would go down, thus causing the rest of my family to give me dirty looks and say nasty things to me.

By going with a router appliance, they no longer threaten to poison me in my sleep.

That said, a Linux box makes a fine router - far better than an XP box.

I do believe that most of the router appliances that you can purchase are running an embedded Linux.


----------



## I Fix 4 U (Jul 19, 2004)

or some proprietary system maybe a *nix variant.


----------

