ifconfig Command
The ifconfig command displays information about the configuration of an interface that you specify. Refer to the ifconfig(1M) man page for details. The syntax of ifconfig follows:
ifconfig interface-name [protocol_family]
ifconfig Command Task Map
Table 4-7 ifconfig Command Task Map
Task | Description | For Instructions, Go To ... |
---|---|---|
Get information about a specific interface | Involves using the ifconfig command | |
Get information about all interfaces on a network | Involves using the -a option of the ifconfig command | "nsswitch.conf File -- Specifying Which Name Service to Use" |
How to Get Information About a Specific Interface
For an le0 interface, your output resembles the following:
le0: flags=863<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 129.144.44.140 netmask ffffff00 broadcast 129.144.44.255 ether 8:0:20:8:el:fd |
The previous flags section shows that the interface is configured "up," capable of broadcasting, and not using "trailer" link-level encapsulation. The mtu field tells you that this interface has a maximum transfer size of 1500 octets. Information on the second line includes the IP address of the host you are using, the netmask being currently used, and the IP broadcast address of the interface. The third line gives the machine address (Ethernet, in this instance) of the host.
How to Get Information About All Interfaces on a Network
A useful ifconfig option is -a, which provides information on all interfaces on your network.
This command produces, for example:
le0: flags=49<UP,LOOPBACK,RUNNING> mtu 8232 inet 127.144.44.140 netmask ff000000 le0:flags=863<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 129.144.44.140 netmask ffffff00 broadcast 129.144.44.255 ether 8:0:20:8:el:fd |
Output that indicates an interface is not running might mean a problem with that interface. In this instance, see the ifconfig(1M) man page.
netstat Command
The netstat command generates displays that show network status and protocol statistics. You can display the status of TCP and UDP endpoints in table format, routing table information, and interface information.
netstat displays various types of network data, depending on the command-line option that is selected. These displays are the most useful for system administration. The syntax for this form follows:
netstat [-m] [-n] [-s] [-i | -r] [-f address_family]
The most frequently used options for determining network status are s, r, and i. See the netstat(1M) man page for a description of the options.
netstat Command Task Map
Table 4-8 netstat Command Task Map
Task | Description | For Instructions, Go To ... |
---|---|---|
Display statistics by protocol | Involves using the -s option of the netstat command | |
Display network interface status | Involves using the -i option of the netstat command | |
Display routing table status | Involves using the -r option of the netstat command |
How to Display Statistics by Protocol
The netstat -s option displays by protocol statistics for the UDP, TCP, ICMP, and IP protocols.
The result resembles the display that is shown in the following example. (Parts of the output have been truncated.) The information can indicate areas where a protocol is having problems. For example, statistical information from ICMP can indicate where this protocol has found errors.
UDP udpInDatagrams = 39228 udpOutDatagrams = 2455 udpInErrors = 0 TCP tcpRtoAlgorithm = 4 tcpMaxConn = -1 tcpRtoMax = 60000 tcpPassiveOpens = 2 tcpActiveOpens = 4 tcpEstabResets = 1 tcpAttemptFails = 3 tcpOutSegs = 315 . . IP ipForwarding = 2 ipDefaultTTL = 255 ipInReceives = 4518 ipInHdrErrors = 0 . . ICMP icmpInMsgs = 0 icmpInErrors = 0 icmpInCksumErrs = 0 icmpInUnknowns = 0 . . IGMP: 0 messages received 0 messages received with too few bytes 0 messages received with bad checksum 0 membership queries received 0 membership queries received with invalid field(s) 0 membership reports received 0 membership reports received with invalid field(s) 0 membership reports received for groups to which we belong 0 membership reports sent |
How to Display Network Interface Status
The i option of netstat shows the state of the network interfaces that are configured with the machine where you ran the command.
netstat -i produced the following sample display:
Name Mtu Net/Dest Address Ipkts Ierrs Opkts Oerrs Collis Queue le0 1500 b5-spd-2f-cm tatra 14093893 8492 10174659 1119 2314178 0 lo0 8232 loopback localhost 92997622 5442 12451748 0 775125 0 |
Using this display, you can determine the number of packets a machine transmits and receives on each network. For example, the input packet count (Ipkts) that are displayed for a server can increase each time a client tries to boot, while the output packet count (Opkts) remains steady. This outcome suggests that the server is seeing the boot request packets from the client, but does not realize that the server is supposed to respond to them. This confusion might be caused by an incorrect address in the hosts, ipnodes, or ethers database.
However, if the input packet count is steady over time, then the machine does not see the packets at all. This outcome suggests a different type of failure, possibly a hardware problem.