?? linux tutorial - linux network administration.mht
字號:
<TD>8</TD>
<TD>4</TD>
<TD>2</TD>
<TD>1</TD></TR>
<TR>
<TD>Example: 192</TD>
<TD>1</TD>
<TD>1</TD>
<TD>0</TD>
<TD>0</TD>
<TD>0</TD>
<TD>0</TD>
<TD>0</TD>
<TD>0</TD></TR></TBODY></TABLE>
<P>Example 192=3D128+64=20
<P>Some addresses are reserved and outside this scope. Loopback=20
(127.0.0.1), reserved class C 192.168.XXX.XXX, reserved class B=20
172.31.XXX.XXX and reserved class A 10.XXX.XXX.XXX.=20
<P><B>Subnet Example:</B>=20
<DL>
<DD>Your ISP assigns you a subnet mask of 255.255.255.248 for =
your=20
office.=20
<UL>
<LI>208.88.34.104 Network Base address=20
<LI>208.88.34.105 Computer 1=20
<LI>208.88.34.106 Computer 2=20
<LI>208.88.34.107 Computer 3=20
<LI>208.88.34.108 Computer 4=20
<LI>208.88.34.109 Computer 5=20
<LI>208.88.34.110 DSL router/Gateway=20
<LI>208.88.34.111 Broadcast address </LI></UL>Of the eight =
addresses,=20
there are six assigned to hardware systems and ultimately only =
five=20
usable addresses. </DD></DL>
<P><B>Links:</B>=20
<UL>
<LI><A =
href=3D"http://www.johnscloset.net/primer/subnet.html">What's A=20
Netmask And Why Do I Need One?</A>=20
<LI><A =
href=3D"http://www.tangent.org/~brian/dict/subnet.html">Subnet=20
Cheat Sheet</A>=20
<LI><A=20
=
href=3D"http://www.telusplanet.net/public/sparkman/netcalc.htm">Subnet=20
calculator</A>=20
<LI><A=20
=
href=3D"http://www.reynolds.k12.or.us/~rsdweb/tech/tutorials/cidr.htm">CI=
DR=20
Converstion Table</A>=20
<LI><A href=3D"http://info.his.com/utilities/subnets.html">Table =
of=20
subnets</A>=20
<LI><A href=3D"http://www.gtoal.com/subnet.html">IP Subnetting, =
Variable=20
Subnetting, and CIDR (Supernetting)</A>=20
<LI><A=20
=
href=3D"http://www.cisco.com/univercd/cc/td/doc/product/iaabu/pix/pix_v42=
/pix42cfg/pix42ape.htm">CISCO.com:=20
Subnet Masking and Addressing</A> </LI></UL>
<P><A name=3DCLASSES></A>
<P>
<HR SIZE=3D5>
<TABLE cellSpacing=3D0 cellPadding=3D2 width=3D"100%" border=3D0>
<TBODY>
<TR bgColor=3D#ffcc33>
<TD><B><BIG>Network =
Classes:</BIG></B></TD></TR></TBODY></TABLE>
<P>The concept of network classes is a little obsolete as subnets =
are now=20
used to define smaller networks. These subnets may be part of a =
class A,=20
B, C, etc network. For historical reference the network classes =
are=20
defined as follows:=20
<UL>
<LI><B>Class A:</B> Defined by the first 8 bits with a range of =
0 - 127.=20
<BR>First number (8 bits) is defined by Internic i.e. =
77.XXX.XXX.XXX=20
<BR>One class A network can define 16,777,214 hosts. <BR>Range: =
0.0.0.0=20
- 127.255.255.255=20
<LI><B>Class B:</B> Defined by the first 8 bits with a range =
from 128 -=20
191 <BR>First two numbers (16 bits) are defined by Internic i.e. =
182.56.XXX.XXX <BR>One class B network can define 65,534 hosts.=20
<BR>Range: 128.0.0.0 - 191.255.255.255=20
<LI><B>Class C:</B> Defined by the first 8 bits with a range =
from 192 -=20
223 <BR>First three numbers (24 bits) are defined by Internic =
i.e.=20
220.56.222.XXX <BR>One class B network can define 254 hosts. =
<BR>Range:=20
192.0.0.0 - 223.255.255.255=20
<LI><B>Class D:</B> Defined by the first 8 bits with a range =
from 224 -=20
239 <BR>This is reserved for multicast networks (RFC988) =
<BR>Range:=20
224.0.0.0 - 239.255.255.255=20
<LI><B>Class E:</B> Defined by the first 8 bits with a range =
from 240 -=20
255 <BR>This is reserved for experimental use. <BR>Range: =
240.0.0.0 -=20
247.255.255.255 </LI></UL>
<P><A name=3DFORWARDING></A>
<P>
<HR SIZE=3D5>
<TABLE cellSpacing=3D0 cellPadding=3D2 width=3D"100%" border=3D0>
<TBODY>
<TR bgColor=3D#ffcc33>
<TD><B><BIG>Enable=20
Forwarding:</BIG></B></TD></TR></TBODY></TABLE>Forwarding allows =
the=20
network packets on one network interface (i.e. <TT>eth0</TT>) to =
be=20
forwarded to another network interface (i.e. <TT>eth1</TT>). This =
will=20
allow the Linux computer to conect ("ethernet bridge") or route =
network=20
traffic.=20
<P>The bridge configuration will merge two (or several) networks =
into one=20
single network topology. IpTables firewall rules can be used to =
filter=20
traffic.=20
<P>A router configuration can support multicast and basic IP =
routing using=20
the "<TT>route</TT>" command. IP masquerading (NAT) can be used to =
connect=20
private local area networks (LAN) to the internet or load balance =
servers.=20
<UL>
<LI>Turn on IP forwarding to allow Linux computer to act as a =
gateway or=20
router. <BR><TT>echo 1 > /proc/sys/net/ipv4/ip_forward</TT>=20
<BR>Default is 0. One can add firewall rules by using <A=20
=
href=3D"http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=3Dipchains=
">ipchains</A>.=20
<P>Another method is to alter the Linux kernel config file:=20
/etc/sysctl.conf Set the following value:=20
<DL>
<DD>
<TABLE cellSpacing=3D1 cellPadding=3D4 width=3D"100%" =
bgColor=3D#000000=20
border=3D0>
<TBODY>
<TR bgColor=3D#c0c0c0>
<TD><PRE>net.ipv4.ip_forward =3D 1
</PRE></TD></TR></TBODY></TABLE></DD></DL>
<P>See file <TT>/etc/sysconfig/network</TT> for storing this=20
configuration.=20
<DL>
<DD>
<TABLE cellSpacing=3D1 cellPadding=3D4 width=3D"100%" =
bgColor=3D#000000=20
border=3D0>
<TBODY>
<TR bgColor=3D#c0c0c0>
<TD><PRE>FORWARD_IPV4=3Dtrue
</PRE></TD></TR></TBODY></TABLE></DD></DL>Change the default "false" =
to "true". </LI></UL>
<P>All methods will result in a proc file value of "1". Test: =
<TT>cat=20
/proc/sys/net/ipv4/ip_forward</TT>=20
<P>The <A=20
=
href=3D"http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=3Dtcp">TCP=
Man=20
page - Linux Programmer's Manual</A> and <A=20
=
href=3D"file:///usr/src/linux/Documentation/proc.txt">/usr/src/linux/Docu=
mentation/proc.txt</A>=20
(Kernel 2.2 RH 7.0-) <A=20
href=3D"http://www.linuxhq.com/kernel/v2.2/doc/proc.txt.html">[alt =
link]</A>=20
cover <TT>/proc/sys/net/ipv4/*</TT> file descriptions.=20
<P><B>Alos see:</B> (YoLinux tutorials)=20
<UL>
<LI>Configure Linux as an internet gateway router: <A=20
=
href=3D"http://www.yolinux.com/TUTORIALS/LinuxTutorialIptablesNetworkGate=
way.html">Using=20
Linux and iptables/ipchains to set up an internet gateway for =
home or=20
office</A> (<TT>iptables</TT>)=20
<LI><A=20
=
href=3D"http://www.yolinux.com/TUTORIALS/LinuxTutorialWebSiteConfig.html#=
VIRTUALSERVER">Load=20
balancing servers using LVS (Linux Virtual Server)</A>=20
(<TT>ipvsadm</TT>) </LI></UL>
<P><A name=3DADDNIC></A>
<P>
<HR SIZE=3D5>
<TABLE cellSpacing=3D0 cellPadding=3D2 width=3D"100%" border=3D0>
<TBODY>
<TR bgColor=3D#ffcc33>
<TD><B><BIG>Adding a network interface card=20
(NIC):</BIG></B></TD></TR></TBODY></TABLE>
<P><B>Manual method:</B> This does not alter the permanent =
configuration=20
and will only configure support until the next reboot.=20
<UL>
<LI><TT>cd /lib/modules/2.2.5-15/net/ </TT><B><I>- Use kernel =
version=20
for your system. This example uses 2.2.5-15</I></B> <BR>Here you =
will=20
find the modules supported by your system. <BR>It can be =
permanently=20
added to <TT>/etc/modules.conf</TT> (or for older systems:=20
<TT>/etc/conf.modules</TT>) <BR>Example: <PRE> alias eth0 =
3c59x
</PRE>
<LI>/sbin/<A=20
=
href=3D"http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=3Dinsmod">=
insmod</A>=20
-v 3c59x <I>(For a 3Com ethernet card)</I>=20
<LI>ifconfig ... </LI></UL>
<P><B>The easy way:</B> Red Hat versions 6.2 and later, ship with =
Kudzu, a=20
device detection program which runs during system initialization.=20
(/etc/rc.d/init.d/kudzu) This can detect a newly installed NIC and =
load=20
the appropriate driver. Then use <TT>/usr/sbin/netconfig</TT> to =
configure=20
the IP address and network settings. The configuration will be =
stored so=20
that it will be utilized upon system boot. <A =
name=3DROUTETWONICS></A>
<P><B>Systems with two NIC cards:</B> Typically two cards are used =
when=20
connecting to two networks. In this case the device must be =
defined using=20
one of three methods:=20
<OL>
<LI>Use the Red Hat GUI tool <TT>/usr/bin/netcfg</TT>=20
<P><B>OR</B>=20
<P></P>
<LI>Define network parameters in configuration files:=20
<P>Define new device in file (Red Hat/Fedora)=20
<TT>/etc/sysconfig/network-scripts/ifcfg-eth1</TT> <BR>(S.u.s.e =
9.2:=20
=
<TT>/etc/sysconfig/network/ifcfg-eth-id-<I>XX:XX:XX:XX:XX</I></TT>)=20
<DL>
<DD>
<TABLE cellSpacing=3D1 cellPadding=3D4 width=3D"100%" =
bgColor=3D#000000=20
border=3D0>
<TBODY>
<TR bgColor=3D#c0c0c0>
<TD><PRE>DEVICE=3Deth1
BOOTPROTO=3Dstatic
IPADDR=3D192.168.10.12
NETMASK=3D255.255.255.0
GATEWAY=3D<B><I>XXX.XXX.XXX.XXX</I></B>
HOSTNAME=3D<I>node-name.name-of-domain.com</I>
DOMAIN=3D<I>name-of-domain.com</I>
</PRE></TD></TR></TBODY></TABLE></DD></DL>Special routing information=20
may be specified, if necessary, in the file <BR>(Red =
Hat/Fedora):=20
<TT>/etc/sysconfig/static-routes</TT> <BR>(S.u.s.e. 9.2:=20
<TT>/etc/sysconfig/network/routes</TT>)=20
<P>Example:=20
<DL>
<DD><PRE>eth1 net <B><I>XXX.XXX.XXX</I></B>.0 netmask =
255.255.255.0 gw <B><I>XXX.XXX.XXX.XXX</I></B>
</PRE></DD></DL>
<P><B>OR</B>=20
<P></P>
<LI>Define network parameters using Unix command line interface: =
<P>Define IP address: <PRE> ifconfig eth0 XXX.XXX.XXX.XXX =
netmask 255.255.255.0 broadcast XXX.XXX.XXX.255
ifconfig eth1 192.168.10.12 netmask 255.255.255.0 broadcast =
192.168.10.255
</PRE>
<P>If necessary, define route with with the <A=20
=
href=3D"http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=3Dicmp"><T=
T>route</TT></A>=20
command: <BR>Examples: <PRE> route add default gw =
<B><I>XXX.XXX.XXX.XXX</I></B> dev eth0
route add -net <B><I>XXX.XXX.XXX.0</I></B> netmask 255.255.255.0 gw =
<B><I>XXX.XXX.XXX.XXX</I></B> dev eth0=20
</PRE>Where <B><I>XXX.XXX.XXX.XXX</I></B> is the gateway to the internet =
as defined by your ISP or network operator.=20
<P>If a mistake is made just repeat the route command =
substituting "del"=20
in place of "add". </P></LI></OL>
<P>
<HR noShade>
<TABLE cellSpacing=3D0 cellPadding=3D2 width=3D"100%" border=3D0>
<TBODY>
<TR bgColor=3D#c0c0c0>
<TD><B><BIG>Configuring your NIC: Speed and Duplex=20
settings:</BIG></B></TD></TR></TBODY></TABLE>
<P>This is usually not necessary because most ethernet adapters =
can=20
auto-negotiate link speed and duplex setting.=20
<UL>
<LI><B>List NIC speed and configuration:</B> <TT>mii-tool</TT>=20
<BR><TT>eth0: negotiated 100baseTx-FD flow-control, link ok</TT> =
<P>Verbose mode: <TT>mii-tool -v</TT>=20
<DL>
<DD><PRE>eth0: negotiated 100baseTx-FD flow-control, link ok
product info: Intel 82555 rev 4
basic mode: autonegotiation enabled
basic status: autonegotiation complete, link ok
capabilities: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
advertising: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD =
flow-control
link partner: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD =
flow-control
</PRE></DD></DL>
<LI><B>Set NIC configuration:</B> <TT>mii-tool -F =
<I>option</I></TT>=20
<BR>
<DL>
<DD>
<TABLE border=3D1>
<TBODY>
<TR bgColor=3D#c0c0c0>
<TH>Option</TH>
<TH>Parameters</TH></TR>
<TR>
<TD vAlign=3Dtop>-F</TD>
<TD=20
=
vAlign=3Dtop>100baseTx-FD<BR>100baseTx-HD<BR>10baseT-FD<BR>10baseT-HD</TD=
></TR>
<TR>
<TD vAlign=3Dtop>-A</TD>
=
<TD>100baseT4<BR>100baseTx-FD<BR>100baseTx-HD<BR>10baseT-FD<BR>10baseT-HD=
</TD></TR></TBODY></TABLE></DD></DL>
<P></P>
<LI><B>Query NIC with ethtool:</B>=20
<DL>
<DD>
<TABLE cellPadding=3D2 border=3D1>
<TBODY>
<TR bgColor=3D#c0c0c0>
<TH>Command</TH>
<TH>Description</TH></TR>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -