📄 config-network-setup.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="generator" content="HTML Tidy, see www.w3.org" /><title>Setting Up Network Interface Cards</title><meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /><link rel="HOME" title="FreeBSD Handbook" href="index.html" /><link rel="UP" title="Configuration and Tuning" href="config-tuning.html" /><link rel="PREVIOUS" title="Using rc under FreeBSD 5.X" href="configtuning-rcng.html" /><link rel="NEXT" title="Virtual Hosts" href="configtuning-virtual-hosts.html" /><link rel="STYLESHEET" type="text/css" href="docbook.css" /></head><body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"alink="#0000FF"><div class="NAVHEADER"><table summary="Header navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><th colspan="3" align="center">FreeBSD Handbook</th></tr><tr><td width="10%" align="left" valign="bottom"><a href="configtuning-rcng.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 11 Configuration and Tuning</td><td width="10%" align="right" valign="bottom"><a href="configtuning-virtual-hosts.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="CONFIG-NETWORK-SETUP" name="CONFIG-NETWORK-SETUP">11.8 SettingUp Network Interface Cards</a></h1><i class="AUTHORGROUP"><span class="CONTRIB">Contributed by</span> Marc Fonvieille.</i> <p>Nowadays we can not think about a computer without thinking about a networkconnection. Adding and configuring a network card is a common task for any FreeBSDadministrator.</p><div class="SECT2"><h2 class="SECT2"><a id="AEN16081" name="AEN16081">11.8.1 Locating the CorrectDriver</a></h2><p>Before you begin, you should know the model of the card you have, the chip it uses,and whether it is a PCI or ISA card. FreeBSD supports a wide variety of both PCI and ISAcards. Check the Hardware Compatibility List for your release to see if your card issupported.</p><p>Once you are sure your card is supported, you need to determine the proper driver forthe card. The file <tt class="FILENAME">/usr/src/sys/i386/conf/LINT</tt> will give youthe list of network interfaces drivers with some information about the supportedchipsets/cards. If you have doubts about which driver is the correct one, read the manualpage of the driver. The manual page will give you more information about the supportedhardware and even the possible problems that could occur.</p><p>If you own a common card, most of the time you will not have to look very hard for adriver. Drivers for common network cards are present in the <ttclass="FILENAME">GENERIC</tt> kernel, so your card should show up during boot, likeso:</p><pre class="SCREEN">dc0: <82c169 PNIC 10/100BaseTX> port 0xa000-0xa0ff mem 0xd3800000-0xd38000ff irq 15 at device 11.0 on pci0dc0: Ethernet address: 00:a0:cc:da:da:damiibus0: <MII bus> on dc0ukphy0: <Generic IEEE 802.3u media interface> on miibus0ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, autodc1: <82c169 PNIC 10/100BaseTX> port 0x9800-0x98ff mem 0xd3000000-0xd30000ff irq 11 at device 12.0 on pci0dc1: Ethernet address: 00:a0:cc:da:da:dbmiibus1: <MII bus> on dc1ukphy1: <Generic IEEE 802.3u media interface> on miibus1ukphy1: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto</pre><p>In this example, we see that two cards using the <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=dc&sektion=4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">dc</span>(4)</span></a> driver arepresent on the system.</p><p>To use your network card, you will need to load the proper driver. This may beaccomplished in one of two ways. The easiest way is to simply load a kernel module foryour network card with <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=kldload&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">kldload</span>(8)</span></a>. A moduleis not available for all network card drivers (ISA cards and cards using the <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=ed&sektion=4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">ed</span>(4)</span></a> driver, forexample). Alternatively, you may statically compile the support for your card into yourkernel. Check <tt class="FILENAME">/usr/src/sys/i386/conf/LINT</tt> and the manual pageof the driver to know what to add in your kernel configuration file. For more informationabout recompiling your kernel, please see <a href="kernelconfig.html">Chapter 8</a>. Ifyour card was detected at boot by your kernel (<tt class="FILENAME">GENERIC</tt>) you donot have to build a new kernel.</p></div><div class="SECT2"><h2 class="SECT2"><a id="AEN16106" name="AEN16106">11.8.2 Configuring the NetworkCard</a></h2><p>Once the right driver is loaded for the network card, the card needs to be configured.As with many other things, the network card may have been configured at installation timeby <b class="APPLICATION">sysinstall</b>.</p><p>To display the configuration for the network interfaces on your system, enter thefollowing command:</p><pre class="SCREEN"><samp class="PROMPT">%</samp> <kbd class="USERINPUT">ifconfig</kbd>dc0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 inet 192.168.1.3 netmask 0xffffff00 broadcast 192.168.1.255 ether 00:a0:cc:da:da:da media: Ethernet autoselect (100baseTX <full-duplex>) status: activedc1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 inet 10.0.0.1 netmask 0xffffff00 broadcast 10.0.0.255 ether 00:a0:cc:da:da:db media: Ethernet 10baseT/UTP status: no carrierlp0: flags=8810<POINTOPOINT,SIMPLEX,MULTICAST> mtu 1500lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 inet 127.0.0.1 netmask 0xff000000tun0: flags=8010<POINTOPOINT,MULTICAST> mtu 1500</pre><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> Old versions of FreeBSD may require the <var class="OPTION">-a</var>option following <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=ifconfig&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">ifconfig</span>(8)</span></a>, for moredetails about the correct syntax of <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=ifconfig&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">ifconfig</span>(8)</span></a>, pleaserefer to the manual page. Note also that entries concerning IPv6 (<varclass="LITERAL">inet6</var> etc.) were omitted in this example.</p></blockquote></div><p>In this example, the following devices were displayed:</p><ul><li><p><tt class="DEVICENAME">dc0</tt>: The first Ethernet interface</p></li><li><p><tt class="DEVICENAME">dc1</tt>: The second Ethernet interface</p></li><li><p><tt class="DEVICENAME">lp0</tt>: The parallel port interface</p></li><li><p><tt class="DEVICENAME">lo0</tt>: The loopback device</p></li><li><p><tt class="DEVICENAME">tun0</tt>: The tunnel device used by <bclass="APPLICATION">ppp</b></p></li></ul><p>FreeBSD uses the driver name followed by the order in which one the card is detectedat the kernel boot to name the network card. For example <tt class="DEVICENAME">sis2</tt>would be the third network card on the system using the <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=sis&sektion=4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">sis</span>(4)</span></a> driver.</p><p>In this example, the <tt class="DEVICENAME">dc0</tt> device is up and running. The keyindicators are:</p><ol type="1"><li><p><var class="LITERAL">UP</var> means that the card is configured and ready.</p></li><li><p>The card has an Internet (<var class="LITERAL">inet</var>) address (in this case <ttclass="HOSTID">192.168.1.3</tt>).</p></li><li><p>It has a valid subnet mask (<var class="LITERAL">netmask</var>; <ttclass="HOSTID">0xffffff00</tt> is the same as <tt class="HOSTID">255.255.255.0</tt>).</p></li><li><p>It has a valid broadcast address (in this case, <ttclass="HOSTID">192.168.1.255</tt>).</p></li><li><p>The MAC address of the card (<var class="LITERAL">ether</var>) is <ttclass="HOSTID">00:a0:cc:da:da:da</tt></p></li>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -