|[Home] [Credit Search] [Category Browser] [Staff Roll Call]||The LINUX.COM Article Archive|
|Originally Published: Friday, 17 September 1999||Author: David Raufeisen|
|Published to: news_learn_firststep/Firststep News||Page: 1/1 - [Printable]|
Setting Up Ethernet
One may want to use Ethernet for a number of reasons: for a home network, for a connection to the Internet, for internal use within your business, or whatever else you can think of that a network has use for. Cable/*DSL also uses ethernet.
|Page 1 of 1|
Configuring Your Card and Getting it Detected
The hardest part of getting your machine set up for Ethernet would probably be getting the card detected in the first place. You'll probably have to enable support for your network card by checking with your kernel configuration, or, more conveniently, recompiling your kernel with support for your Ethernet card enabled, as well as other stuff you might need in compiling your kernel.
My Ethernet card is labeled as NE2000-compatible; it's jumperless and I had to set the IRQ and all that other stuff in its diagnostic program under MS-DOS. That was found in the A:\UTILITY directory on the floppy, where the information was stored. Because it was jumperless, I had no option but to use the software to set the IRQ and I/O base address stuff there.
I can't predict all the possible configurations people might have on their individual systems, but the standard IRQ for Ethernet cards is 10 and the standard I/O base address is 0x300. If you don't know what these are, please don't hit the back button on your browser; you'll find out soon enough that this isn't really all that hard.
To enable support for your Ethernet card in your kernel, use make config, make menuconfig, or make xconfig. I recommend make menuconfig so that you can go back and fix your mistakes later. And yes, this is part of recompiling your kernel. NE2000 cards should be under "Other ISA Cards" or whatever; the only thing you need to enable it is choose the card that you need and nothing else. Choosing cards that you won't need really won't hurt you, but it will make your kernel a little bigger. But hey, if you want to play it safe and just include support for everything there, go ahead, I'm not stoppin' ya. Note that the more devices you support in your kernel, the larger it will be, and the more memory (RAM) it will use up when loaded.
If you're not sure whether your card is supported, read the Ethernet-HOWTO.That has mostly hardware information about Ethernet cards. Look at the index of the HOWTO for the information you need.
With my card, I had to use boot parameters to specify which IRQ, I/O base address, and device that my card used. In order to do that, I had to tell the kernel what to look for (known as passing arguments to the kernel). Since I had my card set to work on IRQ 10, on I/O base address 0x300, and it was my only Ethernet card, I would stick these to the "linux" part when LILO popped up:
Up there, I'm telling Linux that my Ethernet device is on IRQ 10, I/O base address is 0x300, and the device created for the Ethernet card is eth0. Again, you should type that when you boot with LILO; when LILO boot: pops up, type "linux ether=10,0x300,eth0". When you boot up, it should read something like this, with perhaps a few changes depending on what settings you choose to use:
ne.c:v1.10 9/23/94 Donald Becker (firstname.lastname@example.org) NE*000 ethercard probe at 0x300: 00 40 05 48 2e 83 eth0: NE2000 found at 0x300, using IRQ 10.
Assigning an IP Address to Your Machine
Once the card is detected, you have stuff to do. The first step, I think, would be to assign an IP address (a series of 4 numbers separated by dots representing a host or a group of hosts) to your machine. Let's just say that you're going to assign the address 192.168.0.1 to your machine. You would do this by typing the following:
ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up
The "netmask" part is pretty standard: it doesn't change if you're using Ethernet. The "up" at the end is simply telling Linux that you're setting your machine active, so it's up. And if you're not paying attention, the "eth0" part after "ifconfig" is representing the device that your Ethernet card uses.
I worried about issues like how the card would contact the hub (because I use RJ-45 cabling--you know, the kind that has connectors that look like giant phone jacks) before I tried setting up Ethernet for the first time. At first I tried to use Red Hat's netcfg tool that came bundled with the rest of the distribution; that got my IP address assigned to me correctly, but I couldn't get a ping from my sister's computer, a Windows 95 machine. For a while (to me it seems like a long while) I had to load Windows 95 first, and then use LOADLIN to load Linux in order to get a ping. I think on the same day I decided to start this section of my Linux guide, I read up a bit on routing.
As stated in the NET-3 HOWTO, it is possible to write large volumes about routing; I, however, don't like reading unnecessary information so I'll try to summarize it into what you really need to know. Let's say you use a hub. You have an IP address of 192.168.0.1 and your younger sister has her computer set to 192.168.0.2. In order to get a ping from her machine (and not have to load Windows 95 first) you'll have to tell your machine that a hub is ready and waiting to have information passed through it.
If the machines on your network have the IP addresses 192.168.0.*, then the entire network is represented by 192.168.0.0 (192.168.0.255 officially). Since 192.168.0.0 stands for the entire network (even if you're 192.168.0.3, 192.168.0.4, 22.214.171.124, and so on), you want to contact the entire network, which, again, is 192.168.0.0. You would do this using route as root:
route add -net 192.168.0.0 netmask 255.255.255.0 eth0
Basically, if your network has machines that are assigned IP addresses that are 192.168.0.*, you represent the whole network with 192.168.0.0. If your network's machines have IP addresses of 192.168.1.*, then your whole network would be represented by 192.168.1.0 and you would type route add -net 192.168.1.0 netmask 255.255.255.0 eth0 in order to get your Linux machine to contact the rest of the network.
That should also work for networks with no hubs, if you connect the computers all to each other using those RJ-58 cables (the ones that look like TV wiring).
That will allow you to contact hosts within your network. Now you have to be able to contact hosts outside your own local network, especially those on the Internet. You'll have to configure a gateway, a machine that's connected to the Internet and that is willing to share its connection with you. For example, if the machine with the IP address 192.168.0.5 is your gateway to the Internet, you would type this (as root) to send requests for addresses that are out of your network:
route add default gw 192.168.0.5 eth0
If you are connected to the Internet through a dialup connection using PPP (which most people are), you would do something different, depending on what machine the Internet connection is running off of. If the machine you're working on is the machine that's connected to the Internet through PPP, then you would type something like this:
route add default ppp0
That will configure your system to send requests for packets that are not in your network to the Internet through your modem. (I hope you're still following along; if you don't understand I'm not doing a good job...)
You might want to use IP Masquerading, a way to share your Internet connection with others on your network. The way it basically works is when a request is sent from a machine within your network, your machine takes a look at it and if it's "addressed" to an Internet address, your machine sends the packet out through your connection, whether it be Ethernet or PPP.
If you've got a host within your LAN that's your gateway to the Internet, then you would use route add default gw 192.168.0.5, if 192.168.0.5 is the IP address of the gateway. When your connection is shared this way instead of IP masquerading, each machine on the network (known as a node) has it's own IP address on the Internet.
Putting IP Assignment and Routing in Startup
The information about routing and your IP address on your Ethernet network would be very inconvenient to type in every single time you want to be connected to the rest of the network, so we'll put it in your system startup files.
One easy way is to put the following example lines in the file /etc/rc.d/rc.sysinit:
route add -net 192.168.0.0 eth0 ifconfig eth0 192.168.0.1 up
I have that at the bottom of the file. The other files you can modify are /etc/rc.d/rc.local (if you want to do it this way for Slackware) and the files in /etc/sysconfig/network-scripts/. I think the correct way to do it would be to change or create the appropriate files in /etc/sysconfig/network-scripts, but I find it much easier to just put in the lines that I already have in /etc/rc.d/rc.sysinit.
Something nifty I found on Slackware was that you can just edit /etc/rc.d/rc.inet1 (or the other rc.inet* file) and it will set it for you automatically. You specify the values of certain things like your IP address and broadcast address (and more, of course).
So if you're going to edit one of those files, just go ahead and use your favorite text editor (pico, vim, vi, emacs, joe, jed; the list goes on).
Windows 95 Configuration
On the Windows 95 machine, if you have one on the network, start by clicking on the Start button, then going to Settings, then Control Panel, and finally Network.
In the Network dialog box, if you haven't already, add a TCP/IP service for your Ethernet card, if you haven't already. Highlight TCP/IP for your Ethernet adapter, and click on the Properties button. Fill in the information that you need, such as the gateway IP address (the Linux box if it's running IP masquerading), the nameserver (your ISP's nameserver), the IP address assigned to your machine within your network (such as 192.168.0.2), and any other stuff you might have to fill in.
You can also run winipcfg to see if you currently have an IP address on the network.
That's about all I know about setting up the Windows box, so let's move on. Hopefully you have whatever other machines (nodes) on the network already set up.
Testing Your Connection
To test if your connection works, try pinging another host on your network. Let's say your machine is 192.168.0.1 and the other machine, the one you're going to ping, is 192.168.0.2. This is what you'd type to start pinging the host:
If lines periodically appear and look something like this, your connection works:
64 bytes from 192.168.0.2: icmp_seq=0 ttl=32 time=1.2 ms 64 bytes from 192.168.0.2: icmp_seq=1 ttl=32 time=1.0 ms 64 bytes from 192.168.0.2: icmp_seq=2 ttl=32 time=1.0 ms 64 bytes from 192.168.0.2: icmp_seq=3 ttl=32 time=1.0 ms 64 bytes from 192.168.0.2: icmp_seq=4 ttl=32 time=1.1 ms
To stop pinging, type Control-C (Ctrl+C) to get back to the prompt.
Other Sources of Information
If you have trouble and are wondering how to solve your problem, either solve it yourself and give me a summary of your scenario, or alternatively, ask for help. And, as usual, suggestions are always welcome.
Copyright © 1997-1999 Joshua Go (email@example.com). All rights reserved. Permission to use, distribute, and copy this document is hereby granted. You may modify this document as long as credit to me is given.
|Page 1 of 1|