📄 486-488.html
字号:
<HTML>
<HEAD>
<TITLE>Special Edition Using Linux, Fourth Edition:Configuring a TCP/IP Network</TITLE>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!--ISBN=0789717468//-->
<!--TITLE=Special Edition Using Linux, Fourth Edition//-->
<!--AUTHOR=Jack Tackett//-->
<!--AUTHOR=Jr.//-->
<!--AUTHOR=Steve Burnett//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Que//-->
<!--CHAPTER=24//-->
<!--PAGES=486-488//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="483-486.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="488-491.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P>Table 24.2 lists the command-line arguments for ifconfig.
</P>
<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 24.2</B> Command-Line Arguments for <I>ifconfig</I>
<TR>
<TH COLSPAN="2"><HR>
<TR>
<TH WIDTH="30%" ALIGN="LEFT">Argument
<TH WIDTH="70%" ALIGN="LEFT">Description
<TR>
<TD COLSPAN="2"><HR>
<TR>
<TD VALIGN="TOP"><I><TT>interface</TT></I>
<TD>The name of the network interface, usually the name of the device driver followed by an identification number. This argument is required.
<TR>
<TD VALIGN="TOP"><I><TT>aftype</TT></I>
<TD>The address family that should be used for decoding and displaying all protocol addresses. Now, the inet (TCP/IP), ddp (Appletalk Phase 2), ipx (Novell), and AX.25 and netrom (both amateur packet radio) address families are supported. The inet family is the default.
<TR>
<TD><TT>up</TT>
<TD>Activates the specified interface.
<TR>
<TD><TT>down</TT>
<TD>Deactivates the specified interface.
<TR>
<TD VALIGN="TOP"><TT>[-]arp</TT>
<TD>Turns on or off the use of the ARP protocol on the specified interface. The minus sign is used to turn off the flag.
<TR>
<TD VALIGN="TOP"><TT>[-]trailers</TT>
<TD>Turns on or off trailers on Ethernet frames. This isn’t currently implemented in the Linux networking system.
<TR>
<TD VALIGN="TOP"><TT>[-]allmulti</TT>
<TD>Turns on or off the promiscuous mode of the interface. Turning this mode on tells the interface to send all traffic on the network to the kernel, not just traffic addressed to your machine.
<TR>
<TD VALIGN="TOP"><TT>metric <I>N</I></TT>
<TD>Sets the interface metric to the integer value <I>N.</I> The metric value represents the “cost” of sending a packet on this route. Route costing isn’t currently used by the Linux kernel but is to be implemented at a future date.
<TR>
<TD VALIGN="TOP"><TT>mtu <I>N</I></TT>
<TD>Sets the maximum number of bytes the interface can handle in one transfer to the integer value <I>N.</I> The current networking code in the kernel doesn’t handle IP fragmentation, so make sure that the MTU (Maximum Transmission Unit) value is set large enough.
<TR>
<TD VALIGN="TOP"><TT>dstaddr <I>addr</I></TT>
<TD>Sets the IP address of the other end of a point-to-point link. It has been made obsolete by the <TT>pointopoint</TT> keyword.
<TR>
<TD><TT>netmask <I>addr</I></TT>
<TD>Sets the IP network mask for the specified interface.
<TR>
<TD VALIGN="TOP"><TT>irq <I>addr</I></TT>
<TD>Sets the interrupt line used by this device. Remember that many devices don’t support dynamic IRQ setting.
<TR>
<TD VALIGN="TOP"><TT>[-]broadcast[<I>addr</I>]</TT>
<TD>Sets the broadcast address for the interface when an address is included. If no address is given, the <TT>IFF_BROADCAST</TT> flag for the specified interface is turned on. A leading minus sign turns off the flag.
<TR>
<TD VALIGN="TOP"><TT>[-]pointopoint[<I>addr</I>]</TT>
<TD>Turns on point-to-point mode on the specified interface. This tells the kernel that this interface is a direct link to another machine. The address, when included, is assigned to the machine on the other end of the list. If no address is given, the <TT>IFF_POINTOPOINT</TT> flag for the interface is turned on. A leading minus sign turns off the flag.
<TR>
<TD VALIGN="TOP"><TT>hw</TT>
<TD>Sets the hardware address for the specified interface. The name of the hardware class and the ASCII equivalent of the hardware address must follow this keyword. Ethernet (<TT>ether</TT> ), AMPR AX.25 (<TT>ax25</TT> ), and PPP (<TT>ppp</TT> ) are now supported.
<TR>
<TD VALIGN="TOP"><TT>address</TT>
<TD>The host name or IP address to be assigned to the specified interface. Host names used here are resolved to their IP address equivalents. This parameter is required.
<TR>
<TD COLSPAN="2"><HR>
</TABLE>
<P>You normally don’t need to use all the options. <TT>ifconfig</TT> can set everything needed from just the interface name, netmask, and IP address assigned. You only need to explicitly set most parameters when <TT>ifconfig</TT> misses or you have a complex network.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>CAUTION: </B><BR>If your Linux machine is on a network, the <TT>ifconfig</TT> program must be kept secure from unauthorized use. Setting a network interface to promiscuous mode allows a person to snoop in your network and get sensitive data such as passwords. This is a serious breach of security.<HR></FONT>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR>• <B>See</B> “Handling Physical Security,”<B>p. 236</B><HR></FONT>
</BLOCKQUOTE>
<H4 ALIGN="LEFT"><A NAME="Heading6"></A><FONT COLOR="#000077">Using <I>ifconfig</I> to Inspect a Network Interface
</FONT></H4>
<P>Running <TT>ifconfig</TT> with no arguments causes it to output the status of all network interfaces the kernel knows about. Running <TT>ifconfig</TT> with just an interface name on the command line prints the status of the interface:</P>
<!-- CODE SNIP //-->
<PRE>
$ <B>ifconfig lo</B>
lo Link encap Local Loopback
inet addr 127.0.0.1 Bcast 127.255.255.255 Mask 255.0.0.0
UP LOOPBACK RUNNING MTU 2000 Metric 1
RX packets 0 errors 0 dropped 0 overruns 0
TX packets 1658 errors 10 dropped 0 overruns 0
</PRE>
<!-- END CODE SNIP //-->
<P>This example uses <TT>lo,</TT> the software loopback interface. You can see the assigned IP address (<TT>inet</TT> <TT>addr</TT> ), broadcast address (<TT>Bcast</TT> ), and netmask (<TT>Mask</TT> ). The interface is <TT>UP</TT> with an <TT>MTU</TT> of 2000 and a <TT>Metric</TT> of 1. The last two lines give statistics on the number of packets received (<TT>RX</TT> ) and transmitted (<TT>TX</TT> ), along with packet error, dropped, and overrun counts.</P>
<H4 ALIGN="LEFT"><A NAME="Heading7"></A><FONT COLOR="#000077">Configuring the Software Loopback Interface</FONT></H4>
<P>All Linux machines with the networking layer installed in the kernel have a software loopback interface. This interface is used to test networking applications and to provide a network for local TCP/IP services when the machine isn’t connected to a real network.
</P>
<P>The network interface name for the loopback system is <TT>lo.</TT> Enter the following to run <TT>ifconfig</TT> :</P>
<!-- CODE SNIP //-->
<PRE>
<B>ifconfig lo 127.0.0.1</B>
</PRE>
<!-- END CODE SNIP //-->
<P>This activates the loopback interface and assigns the address 127.0.0.1 to it. This is the address traditionally used for the loopback because the class A network, 127.0.0.0, will never be assigned to anyone by InterNIC.
</P>
<P>To make the loopback system fully operational, you need to add a route for it with the <TT>route</TT> command, which is discussed later in the section “Understanding TCP/IP Routing.”</P>
<H4 ALIGN="LEFT"><A NAME="Heading8"></A><FONT COLOR="#000077">Configuring a Network Interface</FONT></H4>
<P>Configuring an Ethernet network interface takes a little bit more work, especially if you’re using subnetworks. The basic call to <TT>ifconfig</TT> looks like this for linux1.burwell.com:</P>
<!-- CODE SNIP //-->
<PRE>
ifconfig eth0 linux1
</PRE>
<!-- END CODE SNIP //-->
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="483-486.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="488-491.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -