Windows to Linux Internet Sharing

August 28th, 2005

After an afternoon of programming, I started to mess around trying to get my laptop to act as a webserver to our home “intranet” of two computers. Surprisingly enough, it worked. This is unusual, since I find the more you tinker with something the more it screws up–especially on Linux.

First off you need to give your NIC hardware an IP address. For reasons I will explain later, I made mine 192.168.0.2. In other words, the second computer on the local private network.

ifconfig eth0 192.168.0.2 netmask 255.255.255.0 up

Now given you are running Apache, you can access your webserver on both Windows and a different Linux machine. For Linux enter in the above command, but instead of 192.168.0.2 change it to 192.168.0.1. Windows XP as usual has a nice GUI to change your IP address. You’ll find it by going “My Computer” → “My Network Places” → “View Network Connections” right click on your “Local Area Connection” → “Properties” select “Internet Protocol (TCP/IP)” → “Properties” tick “Use the following IP address” and enter in:

192.168.0.1
255.255.255.0

Leave everything else blank and OK through the dialogs. Now by using your favourite browser you should be able to access your website by entering 192.168.0.2 in the address bar. It may not seem a big thing, but since I haven’t really tried anything like that before, it was quite enjoyable to see it working. You can then have fun messing around with iptables (Linux firewall) to prevent your other computers from using ethernet to connect, like for instance to Apache’s port 80. I noticed that by entering in something like:

iptables -A INPUT -i eth0 -j DROP

Causes the browser to hang without seeing “Connection Refused” (as is the nature of DROP; to just drop the packet and not send back any message) while:

iptables -A INPUT -i eth0 -j REJECT

Causes the browser to instantly throw “Connection Refused” (as is the nature of REJECT). I knew that already, but only by reading books, not by seeing it live.

It was at this point I decided to have a go at sharing the Windows internet connection with Slackware. I have a winmodem, so haven’t ever connected Slack up to the internet until now. Windows XP provides an easy dialog to activate Internet Connection Sharing or “ICS”. You can activate it by going back to your “Network Connections” window and right clicking on the icon under “Dial Up”, which in my case is called “Wanadoo Anytime”. Once you have this dialog up, click onto “Advanced” and check the boxes under “Internet Connection Sharing”. This will tell you something about becoming 192.168.0.1, thinking it’d probably cause conflict, that’s why I told you to call your Linux box 192.168.0.2.

Now here’s the tricky part: configuring Slackware to access the internet through Windows. After some trial and error I managed to get it working by using “netconfig” that is included with Slackware, maybe its in your distro too, but I’m sure you can find some other way of configuring it with these settings:

Hostname: monolith
Domain: example.net
Static IP (1)
IP Address:  192.168.0.2
Netmask:     255.255.255.0
Gateway:     192.168.0.1 (2)
Nameserver (3)
  1. My guessing is that you won’t need DHCP as you’ve only got two computers, so assigning IP addresses manually won’t be cumbersome.
  2. This is your Windows box that is connected to the internet.
  3. Just typing in numbers, I don’t think I need it. Not sure, but it still works.

As root make your Windows box the default gateway, and you’re done:

route add default gw 192.168.0.1

Until broadband comes, using internet on Slackware like this isn’t too bad!

9 Responses to “Windows to Linux Internet Sharing”

  1. Pascal Says:
    August 29th, 2005 at 8:18 am

    There are much easier ways to configure such home networks, especially if you have YaST on Suse. :-) And if you mess up there is a nice revert to defaults button.

    At our lug, Andrew Tridge recently showed us what he was hackin’ on - Samba 4. He created Samba, and my, my, it is just going to flykick Windows server software out the Windows. It will use Javascript so you can do *all* configuration pretty much with your browser - Firefox for example.

    The next few months till the end of the year are just going to rock. Just look at the list:
    Ubuntu - “Breezy Badger” release
    Gnome 2.12!
    KDE 3.5 and 4 (!!)
    Suse 10!
    Mum’s birthday :-)
    Freedom Software Day.

    And right now there are some folks who are definitely enjoying aKademy, whilst GUADEC is on shortly afterwards. Action, eh?

    Pascal

  2. Alex Says:
    August 29th, 2005 at 10:54 am

    On Slackware we like doing things the hard way. ;)

    Looking forward to GNOME 2.12. When I was first getting into Linux I can remember how I found GNOME’s versioning system odd. My sense of maths was that version 2.8 was > 2.10, but I suppose I’m just being awkward.

  3. Alex Says:
    August 29th, 2005 at 11:03 am

    Yay, added a screenshot.

    gFTP is much better than my antiquated Windows ftp client.

  4. Pascal Says:
    August 30th, 2005 at 7:43 am

    I must say since Konqueror and Krusader have been giving me the shites whenever I try to open an ftp connection with the nuxified.com server, I’ve actually resorted to doing it the hard way there. I use ftp from the cli for that. :-)

    Yay for the cli.

    Btw, you need to change your system font and theme! Too blocky, un-antialiased and imho ugly! :D

    Pascal

  5. Alex Says:
    August 30th, 2005 at 10:33 am

    Heh, at least you tell it how it is. :)

    I actually recompiled the Freetype libraries with BYTE_CODE_INTERPRETER on, and changed the system’s font DPI to get that effect.

    I quite like it, although I think the next distro I install I’ll just leave aliasing on.

  6. Pascal Says:
    August 30th, 2005 at 11:44 am

    I generally leave my fonts be. I think KDE has a bit of a problem, once you fiddle with your KDE fonts too much things can get really screwed up, and *very* ugly.

    Anyway, I love them how they are. :)

    Btw - Can I get your Jabber/MSN/ICQ/AIM/whatever contact details?

    Cheers.
    Pascal

  7. Alex Says:
    August 31st, 2005 at 9:51 pm

    Yes, sorry I didn’t get back to you on that…I’ve been…busy…

    Erm, I don’t have IM details, because I don’t use them. I hang out in an IRC room sometimes, but generally don’t chat on the ‘net.

    I’ll look into Jabber though.

  8. Timothy Says:
    October 5th, 2005 at 11:16 am

    Hi
    I found the article very useful. I already have a small 2 machine network and was trying to share my internet connection. I was wondering why it wasn’t working as planned.

    I might experiment later with changing some settings and see what happens.

    BTW I found that setting the nameserver to the ip address of the gateway i.e. 192.168.0.1 was necessary on my connection to allow DNS resolution.

  9. Alex Says:
    October 8th, 2005 at 11:34 am

    It’s nice that it was helpful to someone :)