📄 linux-ethernet.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><HTML><HEAD><TITLE>Setting Up Ethernet</TITLE> <META NAME="description" CONTENT="A short guide on how to configure Linux to be a node (machine) on an Ethernet network."></HEAD><LINK REL="stylesheet" TYPE="text/css" HREF="default.css"><BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#7F007F"><H2><A NAME="0">Setting Up Ethernet</A></H2><FONT SIZE="-1"><B>Created on November 9, 1997</B></FONT><BR><FONT SIZE="-1"><B>Last modified: July 28, 2000</B></FONT><BR><FONT SIZE="-1"><B>Development stage: Alpha</B></FONT><BR><P>One may want to use Ethernet for a number of reasons: for a homenetwork, for a connection to the Internet, for internal use withinyour business, or whatever else you can think of that a network hasuse for.</P><P>Due to the nearly endless possibilities of an Ethernet network, Ican't cover EVERYTHING here.</P><P>Here are the sections I've divided this page up into:</P><OL><LI><A HREF="#config">Configuring Your Card and Getting it Detected</A></LI> <OL> <LI><A HREF="#kernelconfig">Configuring Your Kernel</A></LI> <LI><A HREF="#multiple">Multiple Ethernet Cards</A></LI> </OL><LI><A HREF="#assignaddress">Assigning an IP Address to Your Machine</A></LI> <OL> <LI><A HREF="#dhcp">DHCP</A></LI> </OL><LI><A HREF="#routing">Routing</A></LI><LI><A HREF="#startup">Putting IP Assignment and Routing in Startup</A></LI><LI><A HREF="#winconfig">Windows 95 Configuration</A></LI><LI><A HREF="#testconnect">Testing Your Connection</A></LI><LI><A HREF="#othersources">Other Sources of Information</A></LI></OL><A NAME="config"></A><H3>Configuring Your Card and Getting it Detected</H3><P>The hardest part of getting your machine set up for Ethernet wouldprobably be getting the card detected in the first place. You willprobably have to enable support for your network card by checking withhow your distribution is configured. Most modern distributions alreadyhave it enabled.</P><P>If you have an older Linux distribution, read up on <AHREF="linux-kernel.html">recompiling your kernel</A> with support foryour Ethernet card enabled, as well as other stuff you might need incompiling your kernel.</P><P>My Ethernet card is labeled as NE2000-compatible; it's jumperlessand I had to set the IRQ and all that other stuff in its diagnosticprogram under MS-DOS. That was found in the <TT>A:\UTILITY</TT>directory on the floppy, where the information was stored. Because itwas jumperless, I had no option but to use the software to set the IRQand I/O base address stuff there. In all likelihood, you probablywon't need to do this annoying little step.</P><P>I can't predict all the possible configurations people might have ontheir individual systems, but the standard IRQ for Ethernet cards is 10and the standard I/O base address is 0x300. If you don't know what theseare, please don't hit the back button on your browser; you'll find outsoon enough that this isn't really all that hard.</P><A NAME="kernelconfig"></A><H4>Configuring Your Kernel</H4><P>To enable support for your Ethernet card in your kernel, use <TT>makeconfig</TT>, <TT>make menuconfig</TT>, or <TT>make xconfig</TT>. Irecommend <TT>make menuconfig</TT> so that you can go back and fix yourmistakes later. And yes, this is part of <AHREF="linux-kernel.html">recompiling your kernel</A>. NE2000 cards shouldbe under "Other ISA Cards" or whatever; the only thing you needto enable it is choose the card that you need and nothing else. Choosingcards that you won't need really won't hurt you, but it <I>will</I> makeyour kernel a little bigger. But hey, if you want to play it safe and justinclude support for everything there, go ahead, I am not stopping you. Notethat the more devices you support in your kernel, the larger it will be,and the more memory (RAM) it will use up when loaded.</P><P>If you're not sure whether your card is supported, read the <AHREF="http://sunsite.unc.edu/LDP/HOWTO/Ethernet-HOWTO.html">Ethernet-HOWTO</A>. Thathas mostly hardware information about Ethernet cards. Look at theindex of the HOWTO for the information you need.</P><P>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, Ihad to tell the kernel what to look for (known as <B>passingarguments</B> to the kernel). Since I had my card set to work on IRQ10, on I/O base address 0x300, and it was my only Ethernet card, Iwould stick these to the "linux" part when LILO poppedup:</P><PRE>ether=10,0x300,eth0</PRE><P>Up there, I'm telling Linux that my <B>Ether</B>net device is on IRQ<B>10</B>, I/O base address is <B>0x300</B>, and the device created forthe Ethernet card is <B>eth0</B>. Again, you should type that when youboot with LILO; when <TT>LILO boot:</TT> pops up, type <B><TT>linux ether=10,0x300,eth0</TT></B>. When you boot up, it should read something likethis, with perhaps a few changes depending on what settings you choose touse:</P><PRE>ne.c:v1.10 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)NE*000 ethercard probe at 0x300: 00 40 05 48 2e 83eth0: NE2000 found at 0x300, using IRQ 10.</PRE><P>You can bypass having to type in those arguments all the time ifyou edit your <TT>/etc/lilo.conf</TT> file and use the <B>append</B>keyword to pass to the kernel while it starts on your machine:</P><PRE>image=/boot/vmlinuz-2.2.16 label=Linux append="ether=10,0x300,eth0" read-only</PRE><A NAME="multiple"></A><H4>Multiple Ethernet Cards</H4><P>Now, what if you have another card? (If you don't have one, skip onto the next section.) I got another NIC just recently, a Netgear 310txwhich uses the DEC Tulip chipset. I enabled the driver during mykernel configuration; it was under the "EISA, VLB, PCI and onboard controllers" section. So I recompiled and rebooted the newkernel with support for this card built in. It found it but couldn'tfind my old one, which I wanted it to. I wrote down the I/O baseaddress and the IRQ that it found, which were 0x6100 and 11,respectively. (I obtained this from <TT><B>dmesg | grep eth</B></TT>;you might have luck with that too.)</P><P>So, having something like that, I made changes to<TT>/etc/lilo.conf</TT> so it would detect both cards on the nextbootup. I know you're just dying to know how I did that.</P><PRE>image=/boot/vmlinuz-2.2.16 label=Linux append="ether=11,0x6100,eth0 ether=10,0x300,eth1" read-only</PRE><P>My little image section in there looks about the same as it didbefore, only now I've made the new PCI card be eth0 and the old one beeth1 but still with their hardware information so that Linux can findthem. Remember to re-run <B>lilo</B>, too.</P><A NAME="assignaddress"></A><H3>Assigning an IP Address to Your Machine</H3><P>Once the card is detected, you have stuff to do. The first step, Ithink, would be to assign an IP address (a series of 4 numbers separatedby dots representing a host or a group of hosts) to your machine. Let'sjust say that you're going to assign the address <TT>192.168.1.1</TT> toyour machine. You would do this by typing the following:</P><PRE>ifconfig eth0 192.168.1.1 netmask 255.255.255.0 up</PRE><P>The "netmask" part is pretty standard: it doesn't changeif you're using Ethernet. The "up" at the end is simplytelling Linux that you're setting your network connection active, soit's up. And if you're not paying attention, the "eth0" partafter "ifconfig" is representing the device that yourEthernet card uses.</P><A NAME="dhcp"></A><H4>DHCP</H4><P>If you happen to know for a fact that you are supposed to use DHCP,skip all the little <B>ifconfig</B> stuff and try running<B><TT>dhcpcd</TT></B>. This might be the case if you're in a companyoffice and plugged into their network. If you <I>really</I> know for afact that you use DHCP, you can configure your machine for networkingfor good.</P><A NAME="routing"></A><H3><A NAME="3">Routing</A></H3><P>As stated in the <AHREF="http://sunsite.unc.edu/LDP/HOWTO/NET-3-HOWTO.html">NET-3 HOWTO</A>,it is possible to write large volumes about routing; I, however, don'tlike reading unnecessary information so I'll try to summarize it into whatyou really need to know. Let's say you use a hub. You have an IP addressof <TT>192.168.1.0</TT> and your younger sister has her computer set to<TT>192.168.1.2</TT>. In order to get a ping from her machine (and nothave to load Windows 95 first) you'll have to tell your machine that a hubis ready and waiting to have information passed through it.</P><P>If the machines on your network have the IP addresses 192.168.1.*,then the entire network is represented by 192.168.1.0 (192.168.1.255officially). Since 192.168.1.0 gives you the entire network (even ifyou're 192.168.1.3, 192.168.1.4, 192.186.1.5, and so on), you want tocontact the entire network, which, again, is 192.168.1.0. You would dothis using <TT>route</TT> as root:</P><PRE>route add -net 192.168.1.0 netmask 255.255.255.0 eth0</PRE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -