📄 0170-0172.html
字号:
<HTML>
<HEAD>
<TITLE>Sams Teach Yourself Linux in 24 Hours:Connecting to the Internet:EarthWeb Inc.-</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=0672311623 //-->
<!-- TITLE=Sams Teach Yourself Linux in 24 Hours//-->
<!-- AUTHOR=Bill Ball//-->
<!-- PUBLISHER=Macmillan Computer Publishing//-->
<!-- IMPRINT=Sams//-->
<!-- CHAPTER=10 //-->
<!-- PAGES=0161-0172 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="0167-0169.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="../ch11/0173-0175.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-170"><P>Page 170</P></A>
<P>The netstat command is the definitive command for checking your network
activity, connections, routing tables, and other network messages and statistics. You'll want to
try this command if you're interested in a flexible listing of what's going on. For example,
you can try (the following example output is abbreviated):
</P>
<!-- CODE //-->
<PRE>
# netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 1 0 localhost:1644 localhost:1322 CLOSE_WAIT
tcp 0 0 localhost:2579 localhost:6000 ESTABLISHED
...
tcp 0 0 serial52.staffnet.:4216 megan.staffnet.com:pop ESTABLISHED
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ] STREAM CONNECTED 417
...
unix 2 [ ] STREAM 419 /dev/log
unix 2 [ ] STREAM CONNECTED 1982
unix 2 [ ] STREAM 1983 /dev/log
</PRE>
<!-- END CODE //-->
<P>The netstat command has more than a dozen different command-line options. See the
netstat manual page for more information.
</P>
<P><B>
Using the ping Command
</B></P>
<P>The ping command is useful for verifying that your ISP's IP addresses are valid and
for testing the response times of your ISP's host servers.
Ping sends test packets of data and measures the time it takes for the host to send back the information—for example:
</P>
<!-- CODE //-->
<PRE>
# ping staffnet.com
PING staffnet.com (207.226.80.1): 56 data bytes
64 bytes from 207.226.80.1: icmp_seq=0 ttl=254 time=176.9 ms
64 bytes from 207.226.80.1: icmp_seq=1 ttl=254 time=180.0 ms
64 bytes from 207.226.80.1: icmp_seq=2 ttl=254 time=170.0 ms
64 bytes from 207.226.80.1: icmp_seq=3 ttl=254 time=170.0 ms
64 bytes from 207.226.80.1: icmp_seq=4 ttl=254 time=170.0 ms
64 bytes from 207.226.80.1: icmp_seq=5 ttl=254 time=170.0 ms
64 bytes from 207.226.80.1: icmp_seq=6 ttl=254 time=169.7 ms
...
-- staffnet.com ping statistics --
7 packets transmitted, 7 packets received, 0% packet loss
round-trip min/avg/max = 169.7/172.3/180.0 ms
</PRE>
<!-- END CODE //-->
<P>By default, ping will continue to send and receive information until you tell it to quit
with a Ctrl+C. You should also know that using the
-f, or flood, option isn't a nice thing to do to your ISP (or any other host computer for that matter), as it creates network overhead
and unnecessary network traffic.
</P>
<P><B>
Using the route Command
</B></P>
<P>The route command, generally used to set up or delete networking routes for interfaces,
may also be useful in showing you what's going on with your
ppp0 interface. You can try the following:
</P>
<A NAME="PAGENUM-171"><P>Page 171</P></A>
<!-- CODE //-->
<PRE>
# /sbin/route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
pm2.staffnet.co * 255.255.255.255 UH 0 0 0 ppp0
127.0.0.0 * 255.0.0.0 U 0 0 2 lo
default pm2.staffnet.co 0.0.0.0 UG 0 0 3 ppp0
</PRE>
<!-- END CODE //-->
<P>For more details about the route command, see its manual page.
</P>
<P><B>
Reading Your System Log
</B></P>
<P>If you'd like to read in detail about what's going on while your scripts are executing,
take a look through your system log, a file called
messages, under the /var/log directory. Try
</P>
<!-- CODE SNIP //-->
<PRE>
# less /var/log/messages
</PRE>
<!-- END CODE SNIP //-->
<P>Look for the start of the pppd daemon in the ppp-on
script. Notice that your dialer script uses the
chat program, which does most of the work and then quits, followed by
pppd getting and setting the network IP addresses.
</P>
<!-- CODE //-->
<PRE>...
Nov 5 16:29:49 localhost pppd[370]: pppd 2.2.0 started by root, uid 0
Nov 5 16:29:51 localhost chat[371]: timeout set to 3 seconds
Nov 5 16:29:51 localhost chat[371]: abort on (\nBUSY\r)
Nov 5 16:29:51 localhost chat[371]: abort on (\nNO ANSWER\r)
Nov 5 16:29:51 localhost chat[371]: abort on (\nRINGING\r\n\r\nRINGING\r)
Nov 5 16:29:51 localhost chat[371]: send (rAT^M)
Nov 5 16:29:51 localhost chat[371]: expect (OK)
Nov 5 16:29:51 localhost chat[371]: rAT^M^M
Nov 5 16:29:51 localhost chat[371]: OK -- got it
Nov 5 16:29:51 localhost chat[371]: send (ATH0^M)
Nov 5 16:29:51 localhost chat[371]: timeout set to 30 seconds
Nov 5 16:29:51 localhost chat[371]: expect (OK)
Nov 5 16:29:51 localhost chat[371]: ^M
Nov 5 16:29:51 localhost chat[371]: ATH0^M^M
Nov 5 16:29:51 localhost chat[371]: OK -- got it
Nov 5 16:29:51 localhost chat[371]: send (ATDT659-9041^M)
Nov 5 16:29:51 localhost chat[371]: expect (CONNECT)
Nov 5 16:29:51 localhost chat[371]: ^M
Nov 5 16:30:10 localhost chat[371]: ATDT659-9041^M^M
Nov 5 16:30:10 localhost chat[371]: CONNECT -- got it
Nov 5 16:30:10 localhost chat[371]: send (^M)
Nov 5 16:30:10 localhost chat[371]: expect (ogin:)
Nov 5 16:30:10 localhost chat[371]: 57600^M
Nov 5 16:30:12 localhost chat[371]: ^M
Nov 5 16:30:12 localhost chat[371]: ^M
Nov 5 16:30:12 localhost chat[371]: Staffnet PM0 login: -- got it
Nov 5 16:30:12 localhost chat[371]: send (username^M)
Nov 5 16:30:12 localhost chat[371]: expect (assword:)
</PRE>
<!-- END CODE //-->
<A NAME="PAGENUM-172"><P>Page 172</P></A>
<!-- CODE //-->
<PRE>
Nov 5 16:30:12 localhost chat[371]: username ^M
Nov 5 16:30:12 localhost chat[371]: Password: -- go it
Nov 5 16:30:12 localhost chat[371]: send (Password: -- ^M)
Nov 5 16:30:12 localhost pppd[370]: Serial connection stablished.
Nov 5 16:30:13 localhost pppd[370]: Using interface ppp0
Nov 5 16:30:13 localhost pppd[370]: Connect: ppp0 <--> /dev/modem
Nov 5 16:30:16 localhost pppd[370]: local IP addrees 207.226.80.171
Nov 5 16:30:16 localhost pppd[370]: remore IP addrees 207.226.80.214
</PRE>
<!-- END CODE //-->
<P>You can look at portions of your log to troubleshoot whether your modem is working,
or your ISP's modems are working. Hopefully
everything will go well, but if you have a hard time connecting or setting up your scripts, take the time to read the
chat and pppd manual pages, along with the PPP-HOWTO and PPP-FAQ.
</P>
<TABLE BGCOLOR=#FFFF99><TR><TD>JUST A MINUTE</TD></TR><TR><TD>
<BLOCKQUOTE>
If you're still having trouble, be sure to read Robert Hart's PPP-HOWTO,
along with Al Longyear's PPP-FAQ, which go into much more detail about setting
up PPP connections. You'll find a lot of handy hints about setting up, testing,
and troubleshooting your connection. If security is a big issue for you, be sure
to read these documents. You should also check with the
comp.os.linux.networking, comp.os.linux.setup, or comp.protocols.
ppp Usenet newsgroups for specific information or tips on using PPP.
</BLOCKQUOTE>
</TD></TR></TABLE>
<P>The next two hours show you how to set up your email and newsreader programs so
you can send and receive email, and read some favorite Usenet newsgroups.
</P>
<P><CENTER>
<a href="0167-0169.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="../ch11/0173-0175.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -