Silicon ChipUsing Linux To Share An Internet Connection; Pt.1 - May 2001 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Australia's economy is far healthier than most people think
  4. Feature: Global Hawk: America's Advanced Unmanned Aircraft by Bob Young
  5. Feature: Using Linux To Share An Internet Connection; Pt.1 by Greg Swain
  6. Feature: Computer Tips: Tweaking Windows With Tweak UI by Peter Smith
  7. Project: Powerful 12V Mini Stereo Amplifier by John Clarke
  8. Project: Microcontroller-Based 4-Digit Counter Modules by Peter Crowcroft & Frank Crivelli
  9. Order Form
  10. Project: Two White-LED Torches To Build by John Clarke
  11. Project: A Servo With Lots Of Grunt by Ross Tester
  12. Product Showcase
  13. Book Store
  14. Vintage Radio: The magnificent 7-banders from AWA by Rodney Champness
  15. Project: PowerPak: A Multi-Voltage Power Supply by Peter Smith
  16. Feature: Help Reform Electrical Legislation by Silicon Chip
  17. Back Issues
  18. Notes & Errata
  19. Market Centre
  20. Advertising Index

This is only a preview of the May 2001 issue of Silicon Chip.

You can view 33 of the 104 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Articles in this series:
  • Unmanned Air Vehicles: A Force To Be Reckoned With (April 2001)
  • Unmanned Air Vehicles: A Force To Be Reckoned With (April 2001)
  • Global Hawk: America's Advanced Unmanned Aircraft (May 2001)
  • Global Hawk: America's Advanced Unmanned Aircraft (May 2001)
  • Weird & Wonderful: New Generation Pilotless Aircraft (June 2001)
  • Weird & Wonderful: New Generation Pilotless Aircraft (June 2001)
Items relevant to "Using Linux To Share An Internet Connection; Pt.1":
  • Linux script files for Internet Connection Sharing (Software, Free)
Articles in this series:
  • Using Linux To Share An Internet Connection; Pt.1 (May 2001)
  • Using Linux To Share An Internet Connection; Pt.1 (May 2001)
  • Using Linux To Share An Internet Connection; Pt.2 (June 2001)
  • Using Linux To Share An Internet Connection; Pt.2 (June 2001)
  • Using Linux To Share An Internet Connection; Pt.3 (August 2001)
  • Using Linux To Share An Internet Connection; Pt.3 (August 2001)
  • Using Linux To Share An Internet Connection; Pt.4 (September 2001)
  • Using Linux To Share An Internet Connection; Pt.4 (September 2001)
Articles in this series:
  • Computer Tips: Tweaking Internet Connection Sharing (April 2001)
  • Computer Tips: Tweaking Internet Connection Sharing (April 2001)
  • Computer Tips: Tweaking Windows With Tweak UI (May 2001)
  • Computer Tips: Tweaking Windows With Tweak UI (May 2001)
  • Computer Tips: Backing Up Your Email (July 2001)
  • Computer Tips: Backing Up Your Email (July 2001)
  • Dual Booting With Two Hard Disk Drives (January 2009)
  • Dual Booting With Two Hard Disk Drives (January 2009)
  • A Look At The MacBook 2010 (March 2010)
  • A Look At The MacBook 2010 (March 2010)
Items relevant to "Powerful 12V Mini Stereo Amplifier":
  • Powerful 12V Mini Stereo Amplifier PCB pattern (PDF download) [01105011] (Free)
  • Panel artwork for the Powerful 12V Mini Stereo Amplifier (PDF download) (Free)
Items relevant to "Two White-LED Torches To Build":
  • Two White LED Torch PCB patterns (PDF download) [11105011/11205011] (Free)
Items relevant to "PowerPak: A Multi-Voltage Power Supply":
  • PowerPak PCB pattern (PDF download) [11305011] (Free)
  • PowerPak front panel artwork (PDF download) (Free)

Purchase a printed copy of this issue for $10.00.

Using Linux To Share An Internet Connection; Pt.1 Using a Linux-based PC is a great way to provide shared Internet access for Windows (and Mac) machines on a network. It’s easy to set up, you don’t need fancy hardware and you don’t have to spend big dollars on a Microsoft operating system. By GREG SWAIN Almost everyone with a few computers on a small-office or home-office (SOHO) network faces the same problem – how to give all machines simultaneous access to the Internet via a shared modem. Usually, the main requirement is to give everyone email access. However, you don’t want everyone dialling out to the Internet on separate lines – that’s expensive and ties up lines that should be kept open for voice connections. The answer is to use one machine as a “gateway” to the Internet and have the other machines connect via this gateway. That way, everyone on the network can share the Internet connec­tion via a common modem and phone line. If you have only a couple of computers on a home network, Microsoft’s ICS (Internet Connection Sharing) utility – included with Windows 98SE, Windows Me and The Linux KDE desktop presents a Windows-like interface that’s easy to use. Programs are launched by clicking the “K” button and by clicking the icons on the “K panel”. 14  Silicon Chip Windows 2000 – is the way to go. It’s a snack to set up and you only have to install it on the gateway (or host) machine. The “client” machines don’t require ICS and can run other operating systems such as Windows 95 and Windows NT. If you want to know more about ICS, take a look at the article on home networking in the December 2000 issue of SILICON CHIP. The Linux alternative Although ICS will work in an office situation, you’ll even­tually find yourself wishing for something a bit more “robust” than Windows 98SE or Windows Me. This is where Linux shines as an operating system – it exhibits a rock-like stability that rivals Windows NT/2000 but you save big dollars on the licence fee. A Linux box configured as an Internet gateway will run for weeks or even months on end, without the need for regular reboots – in fact, you often don’t have to reboot until there’s a power interruption! Try doing that on a Win98 or WinMe box and see how far you get! But Linux has a few other advantages as well. For starters, it costs next to nothing and is sometimes even included on the CD-ROMs stuck to computer magazines. In any case, $15-20 will get you a “newsagent’s special”, consisting of a book and a set of CD ROMs with one or more Linux distributions. What’s more, a Linux distribution includes an amazing range of utilities – including a web server, an FTP server, a DHCP server and a mail server – plus lots of applications. Want a free office suite? Linux distributions invariably include Sun Star Office and sometimes even Wordperfect 8.0. Which Linux distribution should you use for the job? Well, that’s a matter of personal preference. The procedure outlined here is based on the author’s experience with Red Hat 6.2 and Red Hat 7.0 but should also work Fig.1: the basic details for setting up a small network to share an Internet connection. TCP/IP is used as the networking protocol and each machine is given it’s own IP address. Both Windows and Mac boxes will work through the Linux gateway, as will any other Linux boxes connected to the network. without modification on Mandrake Linux (although it hasn’t been tested). Other distributions keep some of their configuration and script files in different locations to Red Hat Linux, so you may have to modify the procedure slightly. You’ll figure it out. Hardware requirements You don’t need fancy hardware for a Linux gateway but forget the guff about running later distributions of Linux on an old 386. A 486 can be used at a pinch and will run perfectly as a gateway once set up has been completed. However, if you want to run X Windows (the graphical interface that comes with Linux) at a fair clip, you really need a Pentium machine with at least 32MB of memory. What’s more, distributions like Linux Mandrake 7.2 are optimised for Pentium machines and won’t even install on a 486. By contrast, Red Hat Linux 7.0 will install on a 486 and this will function perfectly as a Linux gateway – it’s just that X Windows will run very slowly, so you will have to be patient when setting up the gateway. That won’t matter once setup is complete – in fact, you don’t even have to start X Windows for the gateway to function. Anyway, this is all really just a long-winded way of saying that you can scrounge the hardware for your Linux gateway. A Pentium 120 or 133 will do just fine but don’t be afraid to fire up an old 486 if that’s what you have on hand. Naturally, the machine will have to be fitted with a net­ work card and (preferably) an external modem, although these items can also be added after Linux has been installed. And depending on the installation, you’ll also need about 1GB of hard disk space, although 1.6-2GB gives a bit more elbow room. Just about any modem should work OK with Linux but steer clear of so-called “Winmodems” – these normally rely on Windows-based software to work properly and will cause you grief with Linux. The basic network Fig.1 shows the details for a simple home or office net­work. You don’t need much in the way of networking hardware – just a few network interface cards (one for each computer), a hub and some Cat.5 ethernet cables to connect it all together. For a home network, you probably won’t need anything faster than a 10Mb/s hub and a 4 or 5-port model should cost no more than about $60. However, if purchasing network cards, go for 10/100Mb/s models so that the network can later be easily upgraded. Buy a 100Mb/s hub if speed is a requirement (eg, if transferring large files across the network). As shown in Fig.1, TCP/IP is used as the networking proto­col (NetBEUI won’t work across the gateway), which MAY 2001  15 network to the Internet – after all, if your network can “see out”, it’s always possible for a hacker to “see in” unless precautions are taken. Internet serving is not the only “trick” that we can per­ form with our Linux box. Want to make it into a file and print server as well? We’ll show you how to do just that in future articles but for now, let’s concentrate on our Internet gateway. Network cards & modems You don’t need much in the way of hardware for a Linux gateway machine. This rebuilt 120MHz Pentium PC with 64MB of RAM and a 1.6GB hard disk drive works fine but you can use a 486 if you have to. means that each machine is issued with a unique IP address. We’ll show you how to set up the network parameters later in this article. Note that Fig.1 shows two Windows clients and a Mac client – yes, that’s right, you can add Mac clients or even Linux clients to the network and they will all access the Internet via the Linux gateway. That’s because all three systems communicate with the Internet using TCP/IP and it’s the networking protocol that’s important here, not the operating system. However, sharing a common networking protocol is not sufficient for Windows and Mac clients to share files and other resources. For that, you need additional software (eg, MACLAN) but that’s another story. Demand dialling & firewalling To make our gateway easy to use, we’re going to show you how configure the Linux box for demand dialling. This means that it will automatically dial out whenever a client machine requests Internet access. The link will then stay up while ever there is TCP/IP “traffic” through it and will automatically disconnect after a preset (idle) time when traffic ceases. Another thing we’re going to do is construct a basic fire­wall. A firewall makes good sense when you connect a Linux supports a wide range of PCI Plug’n’Play network cards, including those based on the RealTek RTL81398 chip (ne2k-pic driver). 16  Silicon Chip Before installing Linux, it’s a good idea to take a look at the “Ethernet Howto” (one of many Linux “howto” articles included on the disk with your distribution). This has a list of supported network interface cards (NICs) and their drivers. As it stands, Linux supports a wide range of network cards out of the box. In general, it should have no trouble with Plug’n’Play (PnP) PCI cards, particularly those based on SMC, Western Digital, Intel, Via, Digital and RealTek/ Winbond (ne2k-pci) chips. A lot of Netgear cards aren’t directly supported, however. Many older ISA-based cards are also supported by Linux, including those from SMC, D-Link and 3Com. These include the popular SMC Ultra, D-Link 250 and 3Com 3c509 cards. If you are using an ISA-based card, it will be necessary to manually configure the IRQ and I/O address settings using either on-board jumpers (try I/O = 0x340 and IRQ = 10) or a setup utility. You can download the setup utility from the manufacturer’s website if you don’t already have it. If you have an ISA PnP card, the best advice is to first turn off the PnP support using the setup utility, then manual­ly assign the I/O address and IRQ settings as before. Make a note of these settings – you’ll need to specify them in a configura­tion file later on. If you know nothing about I/O address and IRQ settings, buy a supported PCI network card. Of course, if you’re using a 486, then you’re stuck with an ISA card but that really shouldn’t cause problems. Propellers not needed Getting Linux up and running was once a job for propeller-heads but not any more. The latest distributions have graphical install interfaces which make the job easy. You don’t need to be a rocket scientist and if you’ve successfully installed Windows before, you should have no problems. Older ISA-based network cards like this 3Com 3c509 are also supported by Linux. The card’s IRQ and I/O memory range are usually assigned using a setup utility. Fig.2: a non-destructive partitioning program such as PartitionMagic can be used to shrink an existing Windows partition if you want a dual-boot Windows/Linux system. Back up any critical data first, though. Fig.3: choose the custom install option if you want a dual-boot system. It also let’s you install what you want. Linux also comes with a choice of X Windows interfaces – either KDE or Gnome. If you’re used to Windows, go for the KDE interface; it’s the one that’s most like Windows, although both interfaces do much the same job. You even get a taskbar and programs are launched in almost identical fashion to Windows. That said, don’t expect Linux to behave like Windows. It’s really quite different and there’s a bit of a learning curve if you want to become really familiar with it. However, you don’t have to be an expert to set up a gateway since most of the job involves editing a few simple configuration files using a text editor. Installing Linux No, we’re not going to give you a blow-by-blow account on installing Linux. That will all be set out in the book that comes with your distribution. We’ll confine ourselves to a few basic tips. First, be aware that it’s possible to set up a dual-boot Windows/ Linux system – usually by installing Windows first and then Linux. If you do this, the Linux boot manager, called LILO (for Linux Loader), will allow you to choose between the two operating systems during boot-up. Note that it will be necessary to use a non-destructive disk partitioning program, such as PartitionMagic (Fig.2), to shrink the existing Windows partition, to make room for the Linux installa­tion. Alternatively, you can use the FIPS partitioning program that comes with Linux to do the job, although its interface is not particularly user friendly. Don’t try to use the MS-DOS fdisk utility to resize parti­tions as it will destroy any existing data on the hard disk. Also, back up any critical files before attempting to resize partitions. Of course, you don’t have to worry about any of this if Linux is to be the only operating system. Booting directly from the Linux installation CD is by far the easiest way to start the installation process – assuming that your PC is capable of booting directly from CD-ROM. You will have to change the boot order in the system BIOS to do this. Alternatively, you can boot from Fig.4: Disk Druid is used during installation to create the Linux native and swap partitions. Fig.5: the Network Configuration window appears if a network card is detected during the installation process. The network can also be configured later on. a DOS floppy with CD-ROM support (eg, a Windows 98 Startup Disk) and start the installation process from there. MAY 2001  17 that isn’t detected (eg, a sound­card or a ZIP drive) can be added later on, usually with the aid of the relevant Linux “how-to”. Network configuration Fig.6: you can choose which packages to install here. The KDE desktop is the one that’s most like Windows but go for the Gnome desktop if you prefer it’s appearance. After that, it’s literally a matter of following the bounc­ ing ball by filling in the blanks in the dialog boxes and click­ing the appropriate options. During the install process, you will be asked to choose the installation type, either Workstation, Server System or Custom (Fig.3). Don’t choose the Server System option if you want a dual-boot system, as this will wipe out any existing partitions on the hard disk. Similarly, don’t choose the Workstation option if you want to dual-boot with Windows NT. If you do, LILO will overwrite NT’s boot loader in the master boot record (MBR) and NT will no longer boot. Check out the “Linux/ Windows NT Howto” if you want a dual-boot Linux/ Windows NT setup. The best bet is to choose the Custom install option, as this lets you install what you want. It also lets you choose where to write LILO – either to the MBR or to the first sector of the Linux partition. Normally, you would choose to write LILO to the MBR and this applies to both standalone and Linux/Win98 dual-boot systems – but not for a Linux/NT dual-boot system. Selecting the Custom install will also bring up “Disk Druid” (Fig.4), which lets you set the size of the Linux partition and the size of the “Linux Swap” partition. A swap size of 120MB is plenty for most installations. You should choose “Linux Native” for the main Linux partition and set the mount point to / (that’s a single forward slash). Be sure to elect to create a Linux boot floppy at the LILO Configuration window. You should also write down your user name and the passwords chosen for your root and user accounts, as set up under Account Configuration. It’s probably best not to select the “Use Graphical Login” option during X Configuration. Once the gateway has been set up, you don’t need to run X Windows for the system to function. And, of course, you can always start X Windows manually after login. Despite being non-Plug’n’Play, the latest versions of Linux do a great job when it comes to “probing” and identifying your hardware. This includes video cards, mice, disk drives, CD-ROM drives and modems. Any hardware 18  Silicon Chip If a network card is detected during installation, the network configuration dialog box will appear (Fig.5). If the card isn’t detected, the details can be added in after installation has been completed. As shown in Fig.1, we’ve named the Linux box “penguin” and given it a domain name of “antarctic.work” (don’t use an Internet domain name). We’re also using 192.168.0.0 as our network address and given the Linux gateway an IP of 192.168.0.1. Note that IP addresses ranging from 192.168.0.0 to 192.168.255.255 are re­served for “private” networks. Do not use an arbitrary address from outside this range – stick to the addresses shown here. Assuming that you’re following our scheme, your networking parameters should look like this: IP Address: 192.168.0.1 Netmask: 255.255.255.0 Network: 192.168.0.0 Broadcast: 192.168.0.255 Hostname: penguin Gateway: Primary DNS: IP as provided by your ISP Secondary DNS: IP as provided by your ISP Note that the gateway address should be left blank. That’s because the Linux box is itself the gateway, but we do have to hand out the gateway address details to the clients. The Domain Name Server (DNS) IP numbers are as specified by your Internet Service Provider (ISP). Don’t worry if you don’t have all the necessary Fig.7: you can test the network card in the Linux box by entering the command ifconfig eth0 at a terminal window. You should get a response like this. Fig.8: local and remote network connections can also be tested by pinging IP addresses (eg, ping 192.168.0.1). informa­tion; it can be added to or altered later on. Startin’ up and shuttin’ down When installation is complete, boot Linux, log on as root and enter your password. If you’re now staring at a DOS-like terminal prompt and you’re new to Linux, you’re probably wonder­ing “how the hell do I launch X Windows?” Answer: type “startx” and press <Enter>. Conversely, to shutdown from the terminal prompt (or console), type shutdown -h now and press <Enter> or shutdown -r now to reboot. If you are in X Windows, you have to log out first before shutting down. Assuming that you are using KDE, click the K button and click Logout. Testing the network card Fig.9: the linux.conf utility (K -> Red Hat -> System -> LinuxConf) can be used for setting up the networking details on the Linux box. It is especially useful if the network card wasn’t detected during installation. If you used a PCI card, the chances are that it was recog­nised during the Linux install process and that it’s already working. The Linux kernel refers to your network card as eth0, while a second network card (if present) will be designated as eth1. There’s a very simple way of finding out if a network card is working correctly. Just launch a terminal session by clicking the console icon on the K panel (or Gnome panel) and type: /sbin/ifconfig eth0 You should see a response like that shown in Fig.7. Another useful test is to try pinging the local IP address. To do this, type the following from the console: ping 192.168.0.1 If the card is working, you should get a response similar to that shown in Fig.8. Hit <Ctrl>-C to stop the pinging. If the card isn’t being recognised (eg, if it’s an ISA card), then you have to tell the kernel where to find it and which driver to load. This is done by entering its I/O address and IRQ settings into a configuration file, along with the name of the driver. The relevant file to edit is /etc/conf.modules in Red Hat 6.2 and /etc/modules.conf in Red Hat 7.0. You can use the Advanced Text Editor to edit this file – just click the pencil icon on the “K panel” (taskbar). For a 10MB NE2000 clone at I/O address 0x340 and IRQ10, it should look like this: alias parport_lowlevel parport_pc alias eth0 ne options eth0 io=0x340 irq=10 Create the conf.modules file if it isn’t already there. The first line configures the parallel port and should be left as is; the second line instructs Linux to use the “ne” driver for eth0; and the third line tells the driver where to find the card. You will have to change the driver designation and the I/O and IRQ numbers to suit your card. The driver name will be listed in the “Linux Ethernet Howto”, which also tells you how to con­figure conf.modules if you have two network cards (eg, for a cable connection). You should check out the “Home-Network-Mini-Howto” as well – this has some really good information. Be prepared to play around with the conf.modules file if necessary. For example, a 3Com 3c509 PnP ISA card that we tested refused to work if its IRQ and I/O address were specified in the options line – this despite the fact that we disabled the PnP feature and specified those parameters using the setup utility. Conversely, it worked quite happily with just “alias eth0 3c509” entered into conf.modules. After editing conf.modules, try ifconfig eth0 again. Pro­ vided there’s a driver for your card, it should work. Using linux.conf Experienced Linux gurus will sneer at this, so we’ll just whisper it – in Red Hat 6.2 & 7.0, you can also use the graphical configuration utility linux.conf to enter your network set­tings (and lots of other things as well). Linux.conf is launched by clicking K -> Red Hat -> System -> LinuxConf. You then click the “Basic Host Information” entry under “Networking” to bring up the configuration box shown in Fig.9. Basically, any entries you make here are reflected in the corresponding configuration files: ie, conf.modules, resolve.conf and hostname. It’s really just an alternative to editing the configuration files. By the way, Linux stores most of its configuration files in the /etc folder and in sub-folders under this folder. And yes, that is a forward slash, unlike DOS which uses back slashes to designate folder paths. Setting up the Windows boxes You now have to assign the TCP/IP, gateway and DNS address­es on the Windows boxes (1) TCP/IP: TCP/IP is installed by default on Windows 98 and Windows Me machines when the network card is installed but if it isn’t there, you will have to launch the MAY 2001  19 Fig.10: each Windows machine is given a unique IP address, while the Subnet Mask is always 255.255.255.0. Fig.11: the IP address of the Linux gateway (192.168.0.1) must be entered at the Gateway tab. Network configuration utility from Control Panel and add it yourself. After the customary Windows reboot, launch the Network configuration utility again and check that TCP/IP is bound to the network card. Next, double-click the TCP/IP entry for the network card to launch the TCP/IP Properties configuration box shown in Fig.10. Give the first machine an IP addresses of 192.168.0.2, the next 192.168.0.3 and so on. The subnet mask is the same for each machine; ie, 255.255.255.0. (2) Gateway Configuration: click the Gateway tab on each machine, enter the IP address of the Linux box (192.168.0.1) into the “New gateway” field and click “Add”. In each case, the dialog box should be the same as Fig.11. (3) DNS Configuration: click the DNS Configuration tab, click Enable DNS and enter the computer’s name into the Host field (Fig.12). Now add your ISP’s primary and secondary DNS IP numbers to the DNS server Search Order (don’t use the numbers shown). This is done so that when you try to access a non-local machine, the Windows box sends out a name-server lookup which triggers the Linux box to dial out. (4) Identification: each machine must be correctly identi­fied on the network. First, click the Identification tab and enter a unique name for each machine ; eg orange1, orange2, etc. In each case, the name should agree with the name entered into the Host field under the DNS tab (Fig.13). Now type in the name of the Workgroup. This can be anything you like (eg, Homenet) but must be the same on all machines. Testing the network You can now reboot all the Windows boxes and check that the network is functioning. You can do that by pinging each IP address in turn from your Linux box and then doing the same from the Windows boxes (do this from a DOS box). If you get return packets similar to those shown in Fig.8, then “whoppeeee” – your network is functioning. Remember to press <Ctrl>-C to stop pinging from the Linux box. 20  Silicon Chip Fig.12: the IP address of the gateway should be first in the DNS search list, followed by the ISP’s nameservers. Fig.13: each of the Windows machines must be given its own name and assigned to a workgroup, so that it can be identified on the network. Finally, use a text editor to create an “lmhosts” file. This file contains a list of all the IP addresses and names of the machines on the network. It will look like this: # lmhosts 192.168.0.1 192.168.0.2 192.168.0.3 192.168.0.4 penguin orange1 orange2 apple1 Save the file as lmhosts (ie, no extension) and place a copy into the Windows folder of each machine. Once that’s done, the lmhosts file will be used for resolving names on the local network (ie, for translating names into IP addresses), rather than forcing the machines to broadcast nameserver queries. Your network is now functioning and you can set up file and printer sharing on your Windows boxes in the usual manner . That’s all for this month. In Pt.2 next month, we’ll show you how to connect your Linux box to the Internet and SC configure it for demand dialling.