<<

. 30
( 69 .)



>>

server exchange information and a connection is established. You can
connection, a system is
view established connections using a netstat command.
communicating via a port. A
port is an address associated
Information provided by the netstat “a command includes the
with a service requester on
names or addresses of the systems at both ends of each connection as
the client end and a service
well as the port or service address that is being used. Viewing netstat
on the server end. Ports
output can help you determine how many connections your system is
enable software such as
supporting and how well it is performing under the load.
Microsoft's Internet Explorer
to communicate with a
RESULT:
TYPE THIS:
service such as Apache.
[ferro:˜] netstat -a | grep ESTABLISHED
The screen displays
The netstat command
a list of established
allows you to view which
connections.
systems are communicating
and which ports they are
using in the process.




– The screen displays a – The screen displays a
‹ Type netstat -a followed ˇ Type netstat -s followed
by a space. listing of your current by a space. listing of your network
network connections. statistics.
› Type | more and press Á Type | more and press
Return. Return.




141
UNIX FOR MAC


CHECK THAT ANOTHER
COMPUTER IS REACHABLE
connection. If your system receives a reply for every

Y
ou can check whether a remote system is reachable
request, you probably have a good connection.
using the ping command, and trace routes using
traceroute. Whenever you have trouble making a
Another useful command for testing network connections is
connection to a system, you can test the connection using
traceroute. The traceroute command attempts to time
ping ” a deceptively simple command that sends a small
the connection between your system and each successive
request in the form of a packet to the remote system,
router in the route between you and the target host. The
requesting a reply. The ping command was named after
result is a list of each hop, along with reports on how long it
the sound that sonar makes when locating an object.
took to reach each system. This timing information can be
used to interpret the quality of the connection.
If the remote system is running and capable of replying, it
responds to the request that ping generates, and you see
Both ping and traceroute rely on a protocol called the
the response on your screen. On Mac OS X systems, ping
Internet Control Message Protocol (ICMP) that is sometimes
generates requests until you press Control + C. Then it
blocked on routers. Because of this blocking, you might
displays a summary of the responses, including how many
get inaccurate results if you ping or run traceroute on
requests the remote system answered and how long each
a system. The results may suggest that the system is
round trip took. This reply tells you whether you were able
unreachable, but you may be able to reach it with a
to reach the remote system and indicates the quality of the
telnet or ssh command.

CHECK THAT ANOTHER COMPUTER IS REACHABLE




– The ping command
‹ Press Control + C after › Type ping followed by a
Note: You must be connected to the
Internet for this task. waiting 10 seconds or more. space. displays a summary of its
responses.
– The ping command
„ Type ping followed by a ˇ Type www.microsoft.com
– If no replies were received,
space. displays a summary of its and press Return.
responses. the ICMP protocol is
¤ Type the domain name of Á Press Control + C after probably being blocked.
– No packets were lost or
a remote system and press waiting 10 seconds or more.
Return. unanswered.
142
10
WORK WITH INTERNET COMMANDS

You can often make your TYPE THIS:
troubleshooting easier by reducing
ping 192.74.137.5
the complexity of your commands. Like
many networking commands, ping
relies on the services of DNS to resolve
RESULT:
domain names into IP addresses. If you
are having trouble reaching your DNS PING 192.74.137.5 (192.74.137.5): 56 data bytes
server, your ping and traceroute 64 bytes from 192.74.137.5: icmp_seq=0 ttl=240 time=157.03 ms
64 bytes from 192.74.137.5: icmp_seq=1 ttl=240 time=166.589 ms
commands will be affected. To rule out
name resolution when you are ^C
troubleshooting a network connection, ”- 192.74.137.5 ping statistics ”-
2 packets transmitted, 2 packets received, 0% packet loss
use ping and traceroute with an IP
round-trip min/avg/max = 131.532/157.241/191.94 ms
address instead of a domain name. Of
course, this only works if you know the
TYPE THIS:
IP addresses for the systems you want
to reach. netstat -an | grep ESTABLISHED
Similarly, commands such as netstat
usually run faster if they are not
RESULT:
required to look up IP addresses and
translate port addresses into names. [ferro:screenshots] user% netstat -a | grep ESTABLISHED
You can turn off lookups by adding n tcp4 0 0 east-18-34.dynam.49218 fajita.toad.
net.http ESTABLISHED
to the argument list.




– Traceroute responds – Traceroute returns lines
‡ Type traceroute followed · Type traceroute followed
by a space. with a header line and a by a space. of data describing the route
single route timing line. taken to reach the remote
° Type the domain name of ‚ Type the domain name of system.
a system on the same network a remote system and press
– An asterisk in place of a
as your computer, or the IP Return.
address of your default time means that the response
gateway. did not come back in time to
be counted.
143
UNIX FOR MAC



LOG ON TO ANOTHER COMPUTER
Another tool for logging on to remote systems is rlogin.

Y
ou can take advantage of accounts and applications
This tool is much like telnet, but less common. You are
on other systems. You can log on to a remote system
likely to find it only on Unix systems, and even then, it may
using telnet or rlogin. Unix systems, such as
be disabled. The rlogin command requires that you log
Mac OS X, provide several ways for you to log on to other
on with the same username that you are using on the local
systems. The most established of these is a tool called
system unless you add the -l newname argument to the
telnet that has been available longer than the Internet.
end of the command.
Telnet establishes a terminal-like connection to another
system. If the remote system has telnet services enabled,
To use any of these tools, you must have an account on a
it asks you for a username and password and logs you on.
remote system. If you do not have a shell account on another
system, however, you can try telnet or rlogin by logging
Most telnet servers give you the option of logging on
on to your Mac OS X system. The logon will only work if you
with the username you are using on your local system,
have enabled remote access. See the section "Enable Remote
but you are free to enter a different username at the
Access to Your Computer" later in this chapter.
prompt. You end a telnet session by logging out. For
most systems, you can press Control + D or type the
command logoff to exit.




LOG ON TO ANOTHER COMPUTER




– The screen displays your
¤ Type the domain name of › Type who am i and press
USING TELNET
a system on which you have Return if the remote system is logon on the list of logged on
Note: You must be connected to the
a shell account. a Unix host. users.
Internet for this task.
Note: Type telnet localhost if you do
„ In the Terminal window, not have a remote system account.
type telnet followed by a
‹ Type your username and
space.
password at the prompts.
144
10
WORK WITH INTERNET COMMANDS



You can use telnet to test TYPE THIS:
connections to other
[ferro:˜] telnet <servername> 110
systems by supplying a port
number in addition to the Use the name of a server from which you receive
system name on the e-mail using POP3. After the system responds,
command line. If you want enter the following lines, replacing the text in
to check how many brackets with your account information:
messages are in your inbox
user <your username>
on a system that supports pass <your password>
POP3, you can connect to stat
quit
the port that services the
POP3 server and ask for this
information using telnet.
You can also use telnet to
RESULT:
determine whether a mail
server is responding. POP3 After the stat command, the system displays a
is a simple protocol used to number telling you how many messages are in
download e-mail from the your inbox.
mail server.




¤ Type the name or IP Note: Alternatively, you can press
USING RLOGIN LOG OFF
Control + D.
address of the remote system
„ In a Terminal window, „ Type logout and press
and press Return.
– The remote system logs
type rlogin followed by a Return.
‹ Type your password to
space. you off.
log on.



145
UNIX FOR MAC



TRANSFER FILES
One popular form of ftp is called anonymous ftp. When

Y
ou can often obtain needed files and applications
using anonymous ftp, you type the word anonymous as if
from other systems. You can move files between your
it were your username and your e-mail address (or
system and others using ftp. Approximately as old as

<<

. 30
( 69 .)



>>