netstat 명령어 (AIX 5.3·6.1)
https://archive.horanglab.com/posts/aix-cmd-netstat
핵심 정리
- 네트워크 관련 자료 구조(소켓, 인터페이스, 라우팅 표, 프로토콜 통계, 메모리)를 보여 줍니다.
- 자주 쓰는 것:
netstat -an(모든 소켓, 숫자로),netstat -rn(라우팅 표),netstat -in(인터페이스와 오류 수),netstat -s(프로토콜별 통계),netstat -v(어댑터 통계),netstat -m(mbuf 메모리). -n은 이름 풀이를 하지 않아 빠르고 DNS 문제에도 영향을 받지 않습니다.netstat 5처럼 간격(초)을 주면 인터페이스의 패킷 수를 계속 보여 줍니다.-Zi,-Zs,-Zm,-Zc로 통계를 0으로 되돌릴 수 있어, 문제를 재현하기 전에 비워 두면 비교하기 좋습니다.
| 항목 | 내용 |
|---|---|
| 버전 | AIX 5.3, AIX 6.1 (6.1에서 -@ WparName(WPAR별 통계·경로)과 라우팅 표의 WPAR 열, GIF 터널 통계 예가 더해짐) |
| 원문 | IBM Commands Reference — 5.3 Volume 4, 6.1 Volume 4 |
| 파일 | /bin/netstat, /etc/networks, /etc/protocols |
| 관련 명령어 | ifconfig, route, entstat, tokstat, no, arp |
목적
네트워크 상태를 보여 줍니다.
영어 원문
Shows network status.
구문
프로토콜별 활성 소켓이나 라우팅 표 정보:
/bin/netstat [ -n ] [ { -A -a } | { -r -C -i -I Interface } ] [ -f AddressFamily ]
[ [ -p Protocol ] | [ -@ WparName ] ] [ Interval ]
네트워크 자료 구조의 내용:
/bin/netstat [ -m | -M | -s | -ss | -u | -v ] [ -f AddressFamily ]
[ [ -p Protocol ] | [ -@ WparName ] ] [ Interval ]
가상 인터페이스 표와 멀티캐스트 전달 캐시: /bin/netstat -g
통신 하위 시스템 전체의 패킷 수: /bin/netstat -D
네트워크 버퍼 캐시 통계: /bin/netstat -c
DLPI 통계: /bin/netstat -P
통계 지우기:
/bin/netstat [ -Zc | -Zi | -Zm | -Zs ]
-@ WparName은 6.1 구문에만 있습니다.
설명
netstat 명령은 활성 연결에 대한 여러 네트워크 관련 자료 구조의 내용을 기호로 보여 줍니다. Interval 매개변수(초)를 주면 구성된 네트워크 인터페이스의 패킷 트래픽 정보를 계속 보여 줍니다. Interval 매개변수에는 플래그가 없습니다.
영어 원문
The netstat command symbolically displays the contents of various network-related data structures for active connections. The Interval parameter, which is specified in seconds, continuously displays information regarding packet traffic on the configured network interfaces. The Interval parameter takes no flags.
플래그
| 플래그 | 설명 |
|---|---|
-A |
소켓과 연결된 프로토콜 제어 블록의 주소를 보여 줍니다. 기본 화면과 함께 동작하며 디버깅용입니다. |
-a |
모든 소켓의 상태를 보여 줍니다. 없으면 인터페이스에 바인드되지 않은 서버 프로세스의 소켓은 보이지 않습니다. |
-c |
네트워크 버퍼 캐시(NBC) 통계를 보여 줍니다. NBC는 네트워크로 보낼 데이터 객체를 담은 네트워크 버퍼 목록으로, 객체를 더하고 지우면서 동적으로 커지며 일부 커널 인터페이스가 네트워크 I/O 성능을 높이려고 씁니다(아래 출력 예). |
-C |
라우팅 표를 경로마다 사용자 설정 비용과 현재 비용까지 보여 줍니다. 사용자 설정 비용은 route의 -hopcount로 정하고, 죽은 게이트웨이 감지(DGD)가 비용을 바꾸면 현재 비용이 달라질 수 있습니다. 다중 경로 라우팅을 쓸 때는 가중치와 정책(WRR 기본 가중 라운드 로빈, HSH 해시, RND 무작위, WRND 가중 무작위, LUT 최저 사용률)도 보여 줍니다. 같은 목적지의 경로가 여럿이면 하나만 정책을 보이고 나머지는 -"-로 같은 정책임을 나타냅니다. 가중치는 WRR과 WRND 정책에 쓰는 사용자 설정 값입니다. |
-D |
통신 하위 시스템에서 받은·보낸·버린 패킷 수를 보여 줍니다. N/A는 해당 없음입니다. NFS/RPC는 RPC를 지나는 들어오는 패킷이 NFS를 지나는 것과 같아 NFS/RPC Total에서 더하지 않고, NFS·RPC 고유의 나가는 패킷 카운터가 없어 개별 값은 N/A, 누계는 NFS/RPC Total에 둡니다. |
-f AddressFamily |
지정한 주소 패밀리로 통계나 제어 블록을 제한합니다. inet(AF_INET), inet6(AF_INET6), unix(AF_UNIX). |
-g |
가상 인터페이스 표와 멀티캐스트 전달 캐시 정보를 보여 줍니다. -s와 함께 쓰면 멀티캐스트 라우팅 정보를 보여 줍니다. |
-i |
구성된 모든 인터페이스의 상태를 보여 줍니다(아래 인터페이스 화면). 이더넷 인터페이스의 충돌 수는 지원하지 않습니다. |
-I Interface |
지정한 인터페이스의 상태를 보여 줍니다. |
-M |
네트워크 메모리의 mbuf 클러스터 풀 통계를 보여 줍니다. |
-m |
메모리 관리 루틴이 기록한 통계를 보여 줍니다. |
-n |
네트워크 주소를 숫자로 보여 줍니다. 없으면 되도록 이름으로 풀어 보여 줍니다. 어떤 화면 형식과도 함께 쓸 수 있습니다. |
-o |
-a와 함께 써서 소켓 옵션, 플래그, 버퍼 통계 같은 소켓의 자세한 데이터를 보여 줍니다. |
-p Protocol |
지정한 프로토콜(잘 알려진 이름이나 별칭)의 통계를 보여 줍니다. 일부 이름과 별칭은 /etc/networks에 있습니다. |
-P |
DLPI(Data Link Provider Interface) 통계를 보여 줍니다(아래 출력 예). DLPI가 올라와 있지 않으면 can't find symbol: dl_stats를 보여 줍니다. |
-r |
라우팅 표를 보여 줍니다. -s와 함께 쓰면 라우팅 통계를 보여 줍니다(아래 라우팅 표 화면). |
-s |
프로토콜별 통계를 보여 줍니다. |
-ss |
0이 아닌 프로토콜 통계만 간단히 보여 줍니다. |
-u |
도메인 소켓 정보를 보여 줍니다. |
-v |
CDLI 기반 통신 어댑터의 통계를 보여 줍니다. entstat, tokstat, fddistat 같은 장치 드라이버 통계 명령을 플래그 없이 실행합니다. 출력의 뜻은 각 명령을 봅니다. |
-Zc |
네트워크 버퍼 캐시 통계를 지웁니다. |
-Zi |
인터페이스 통계를 지웁니다. |
-Zm |
네트워크 메모리 할당자 통계를 지웁니다. |
-Zs |
프로토콜 통계를 지웁니다. 특정 프로토콜만 지우려면 -p 프로토콜을 함께 줍니다(예: netstat -Zs -p tcp). |
-@ WparName |
지정한 WPAR의 네트워크 통계를 보여 줍니다. 이름이 없으면 모든 WPAR의 통계를 보여 줍니다. 6.1부터 |
참고(6.1):
-C,-D,-c,-g,-m,-M,-P,-r,-v,-Z는 전역 환경에서-@ WparName과 함께 쓸 수 없습니다.- 같은 플래그들은 시스템 WPAR 안에서 지원하지 않습니다.
-c 출력 예(값은 모두 0으로 보임):
Network Buffer Cache Statistics:
Current total cache buffer size: 0
Maximum total cache buffer size: 0
Current total cache data size: 0
Maximum total cache data size: 0
Current number of cache: 0
Maximum number of cache: 0
Number of cache with data: 0
Number of searches in cache: 0
Number of cache hit: 0
Number of cache miss: 0
Number of cache newly added: 0
Number of cache updated: 0
Number of cache removed: 0
Number of successful cache accesses: 0
Number of unsuccessful cache accesses: 0
Number of cache validation: 0
Current total cache data size in private segments: 0
Maximum total cache data size in private segments: 0
Current total number of private segments: 0
Maximum total number of private segments: 0
Current number of free private segments: 0
Current total NBC_NAMED_FILE entries: 0
Maximum total NBC_NAMED_FILE entries: 0
-P 출력 예:
DLPI statistics:
Number of received packets = 0
Number of transmitted packets = 0
Number of received bytes = 0
Number of transmitted bytes = 0
Number of incoming pkts discard = 0
Number of outgoing pkts discard = 0
Number of times no buffers = 0
Number of successful binds = 0
Number of unknown message types = 0
Status of phys level promisc = 0
Status of sap level promisc = 0
Status of multi level promisc = 0
Number of enab_multi addresses = 0
기본 화면
활성 소켓의 기본 화면은 로컬·원격 주소, 송신·수신 큐 크기(바이트), 프로토콜, 프로토콜의 내부 상태를 보여 줍니다.
인터넷 주소는 host.port 형식이며, 소켓 주소가 네트워크만 가리키고 특정 호스트를 가리키지 않으면 network.port 형식입니다. 호스트 주소는 이름으로 풀리면 이름으로, 네트워크 주소는 /etc/networks에 따라 이름으로 보입니다. 이름을 모르거나 -n을 주면 주소 패밀리에 맞는 숫자로 보입니다. 정해지지 않은 주소와 포트는 *로 보입니다.
인터페이스 화면(netstat -i)
오류, 충돌(이더넷은 지원하지 않음), 전송한 패킷의 누적 통계 표를 보여 주고, 인터페이스 이름·번호·주소와 MTU도 보여 줍니다.
라우팅 표 화면(netstat -r)
쓸 수 있는 경로와 그 상태를 보여 줍니다. 경로는 목적지 호스트나 네트워크와 패킷을 전달할 게이트웨이로 이루어집니다. 경로는 A.B.C.D/XX 형식으로, A.B.C.D는 목적지 주소, XX는 넷마스크의 1인 비트 수입니다. 예를 들어 9.3.252.192/26의 넷마스크는 255.255.255.192입니다.
| 필드 | 뜻 |
|---|---|
WPAR |
경로가 속한 WPAR 이름. -r과 -@를 함께 줄 때만 나오며, 전역 시스템 경로는 Global로 보입니다(6.1). |
Flags |
경로 상태(아래 표). 로컬 호스트에 붙은 인터페이스마다 직접 경로가 만들어집니다. |
Gateway |
나가는 인터페이스의 주소. |
Refs |
경로를 지금 쓰는 수. 연결형 프로토콜은 연결 동안 경로 하나를 붙잡고, 비연결형은 같은 목적지로 보낼 때 경로를 얻습니다. |
Use |
그 경로로 보낸 패킷 수. |
PMTU |
경로 MTU. AIX 5.3은 이 열을 보여 주지 않습니다. |
Interface |
경로에 쓰는 네트워크 인터페이스. |
Exp |
경로가 만료되기까지 남은 시간(분). |
Groups |
경로와 연결된 그룹 ID 목록. |
Netmasks |
시스템에 적용된 넷마스크 목록. |
Route Tree for Protocol Family |
경로가 있는 주소 패밀리. 1은 UNIX, 2는 인터넷(TCP·UDP 등). 다른 값은 /usr/include/sys/socket.h를 봅니다. |
| Flags | 뜻 | Flags | 뜻 |
|---|---|---|---|
A |
능동 DGD가 켜진 경로 | U |
올라옴(Up) |
H |
네트워크가 아닌 호스트로 가는 경로 | G |
게이트웨이로 가는 경로 |
D |
리디렉트로 동적으로 만든 경로 | M |
리디렉트로 바뀐 경로 |
L |
링크 수준 주소가 경로 항목에 있음 | c |
접근하면 복제 경로를 만듦 |
W |
복제된 경로 | 1, 2, 3 |
프로토콜별 라우팅 플래그 1~3 |
b |
브로드캐스트 주소 | e |
바인딩 캐시 항목이 있음 |
l |
로컬 주소 | m |
멀티캐스트 주소 |
P |
고정(pinned) 경로 | R |
호스트나 네트워크에 닿을 수 없음 |
S |
수동으로 더함 | u |
쓸 수 있는 경로 |
s |
그룹 라우팅 stopsearch 옵션이 켜짐 |
(6.1) netstat -r에 이름 없이 -@를 주면 시스템 라우팅 표의 모든 경로를 보여 줍니다. WPAR 이름을 주면, 그 WPAR에 WPAR별 라우팅이 켜져 있으면 그 WPAR의 경로만, 꺼져 있으면 전역 시스템의 경로를 보여 줍니다.
Interval을 주면 네트워크 인터페이스 통계를 계속 보여 줍니다. 두 열로 나오며, 하나는 주 인터페이스(자동 구성 때 처음 찾은 인터페이스), 다른 하나는 모든 인터페이스의 합계입니다. 주 인터페이스는 -I로 바꿀 수 있습니다. 화면마다 첫 줄은 마지막 재시작 뒤 쌓인 합계이고, 다음 줄부터는 간격마다 쌓인 값입니다.
영어 원문
-A— Shows the address of any protocol control blocks associated with the sockets. This flag acts with the default display and is used for debugging purposes.-a— Shows the state of all sockets. If this flag is not specified, sockets that are used by server processes that are not bound to an interface are not shown.-c— Shows the statistics of the Network Buffer Cache. The Network Buffer Cache is a list of network buffers that contain data objects that can be transmitted to networks. The Network Buffer Cache grows dynamically as data objects are added to or removed from it. The Network Buffer Cache is used by some network kernel interfaces for performance enhancement on the network I/O. The netstat -c command prints the following statistic:Network Buffer Cache Statistics: Current total cache buffer size: 0 Maximum total cache buffer size: 0 Current total cache data size: 0 Maximum total cache data size: 0 Current number of cache: 0 Maximum number of cache: 0 Number of cache with data: 0 Number of searches in cache: 0 Number of cache hit: 0 Number of cache miss: 0 Number of cache newly added: 0 Number of cache updated: 0 Number of cache removed: 0 Number of successful cache accesses: 0 Number of unsuccessful cache accesses: 0 Number of cache validation: 0 Current total cache data size in private segments: 0 Maximum total cache data size in private segments: 0 Current total number of private segments: 0 Maximum total number of private segments: 0 Current number of free private segments: 0 Current total NBC_NAMED_FILE entries: 0 Maximum total NBC_NAMED_FILE entries: 0-C— Shows the routing tables, including the user-configured and current costs of each route. The user-configured cost is set by using the-hopcountflag of the route command. The current cost can be different than the user-configured cost if Dead Gateway Detection has changed the cost of the route. In addition to the costs of the route, it also shows the weight and policy information associated with each route. These fields are applicable only when the Multipath Routing Feature is used. The policy information displays the routing policy that has been currently selected to choose between the multiple routes available. The policies available are: • Default - Weighted Round Robin (WRR) • Hashed (HSH) • Random (RND) • Weighted Random (WRND) • Lowest Utilization (LUT) If multiple routes are present for the same destination (multipath routes), one of these routes display the policy value ofWRR,HSH,RND,WRND, orLUT. All the other routes in this set display the policy information as-"-. This means that all the routes in this set are using the same routing policy displayed by the first route. The weight field is a user-configured weight associated with the route that will be used for Weighted Round-Robin and Weighted Random Policies. For more information about these policies, see the no command.-D— Shows the number of packets received, transmitted, and dropped in the communications subsystem. Note: In the statistics output, aN/Adisplayed in a field value indicates the count is not applicable. For the NFS/RPC statistics, the number of incoming packets that pass through RPC are the same packets that pass through NFS, so these numbers are not summed in theNFS/RPC Totalfield, thus theN/A. NFS has no outgoing packet or outgoing packet drop counters specific to NFS and RPC. Therefore, individual counts have a field value ofN/A, and the cumulative count is stored in theNFS/RPC Totalfield.-fAddressFamily — Limits reports of statistics or address control blocks to those items specified by the AddressFamily variable. The following address families are recognized: inet Indicates theAF_INETaddress family. inet6 Indicates theAF_INET6address family. unix Indicates theAF_UNIXaddress family.-g— Shows Virtual Interface Table and Multicast Forwarding Cache information. If used in conjunction with the-sflag, it will show the multicast routing information.-i— Shows the state of all configured interfaces. See Interface Display Note: The collision count for Ethernet interfaces is not supported.-IInterface — Shows the state of the configured interface specified by the Interface variable.-M— Shows network memory's mbuf cluster pool statistics.-m— Shows statistics recorded by the memory management routines.-n— Shows network addresses as numbers. When this flag is not specified, the netstat command interprets addresses where possible and displays them symbolically. This flag can be used with any of the display formats.-o— Used in conjunction with the-aflag to display detailed data about a socket, such as socket options, flags, and buffer statistics.-pProtocol — Shows statistics about the value specified for the Protocol variable, which is either a well-known name for a protocol or an alias for it. Some protocol names and aliases are listed in the /etc/networks file.-P— Shows the statistics of the Data Link Provider Interface (DLPI). The netstat -P command prints the following statistic:DLPI statistics: Number of received packets = 0 Number of transmitted packets = 0 Number of received bytes = 0 Number of transmitted bytes = 0 Number of incoming pkts discard = 0 Number of outgoing pkts discard = 0 Number of times no buffers = 0 Number of successful binds = 0 Number of unknown message types = 0 Status of phys level promisc = 0 Status of sap level promisc = 0 Status of multi level promisc = 0 Number of enab_multi addresses = 0If DLPI is not loaded, it displays:can’t find symbol: dl_stats-r— Shows the routing tables. When used with the-sflag, the-rflag shows routing statistics. See Routing Table Display.-s— Shows statistics for each protocol.-ss— Displays all the non-zero protocol statistics and provides a concise display.-u— Displays information about domain sockets.-v— Shows statistics for CDLI-based communications adapters. This flag causes the netstat command to run the statistics commands for the netstat, tokstat, and fddistat commands. No flags are issued to these device driver commands. See the specific device driver statistics command to obtain descriptions of the statistical output.-Zc— Clear network buffer cache statistics.-Zi— Clear interface statistics.-Zm— Clear network memory allocator statistics.-Zs— Clear protocol statistics. To clear statistics for a specific protocol, use -p<protocol>. For example, to clear TCP statistics, type netstat -Zs -p tcp.-@WparName — Displays the network statistics associated with workload partition (WparName). If no WparName is specified, then show the network statistics for all workload partitions.- Notes:
The
-C,-D,-c,-g,-m,-M,-P,-r,-v, and-Zflags are not supported in the global environment when used in conjunction with the-@WparName option.The
-C,-D,-c,-g,-m,-M,-P,-r,-v, and-Zflags are not supported in system workload partitions.
Default Display
The default display for active sockets shows the following items:
Local and remote addresses
Send and receive queue sizes (in bytes)
Protocol
Internal state of the protocol
Internet address formats are of the form host.port or network.port if a socket's address specifies a network but no specific host address. The host address is displayed symbolically if the address can be resolved to a symbolic host name, while network addresses are displayed symbolically according to the /etc/networks file.
If a symbolic name for a host is not known or if the -n flag is used, the address is printed numerically, according to the address family. Unspecified addresses and ports appear as an * (asterisk).
Interface Display (netstat -i)
The interface display format provides a table of cumulative statistics for the following items:
Errors
Collisions
Note: The collision count for Ethernet interfaces is not supported.
- Packets transferred
The interface display also provides the interface name, number, and address as well as the maximum transmission units (MTUs).
Routing Table Display (netstat -r)
The routing table display indicates the available routes and their statuses. Each route consists of a destination host or network and a gateway to use in forwarding packets.
A route is given in the format A.B.C.D/XX, which presents two pieces of information. A.B.C.D indicates the destination address and XX indicates the netmask associated with the route. The netmask is represented by the number of bits set. For example, the route 9.3.252.192/26 has a netmask of 255.255.255.192, which has 26 bits set.
The routing table contains the following fields:
WPAR— Displays the name of the workload partition to which this route belongs. This field is only present when the-@flag is used with the-rflag. For routes belonging to the global system,Globalis displayed in this column.Flags— The flags field of the routing table shows the state of the route: A An Active Dead Gateway Detection is enabled on the route. U Up. H The route is to a host rather than to a network. G The route is to a gateway. D The route was created dynamically by a redirect. M The route has been modified by a redirect. L The link-level address is present in the route entry. c Access to this route creates a cloned route. W The route is a cloned route. 1 Protocol specific routing flag #1. 2 Protocol specific routing flag #2. 3 Protocol specific routing flag #3. b The route represents a broadcast address. e Has a binding cache entry. l The route represents a local address. m The route represents a multicast address. P Pinned route. R Host or net unreachable. S Manually added. u Route usable. s The Group Routing stopsearch option is enabled on the route. Direct routes are created for each interface attached to the local host.Gateway— The gateway field for these entries shows the address of the outgoing interface.Refs— Gives the current number of active uses for the route. Connection-oriented protocols hold on to a single route for the duration of a connection, while connectionless protocols obtain a route while sending to the same destination.Use— Provides a count of the number of packets sent using that route.PMTU— Gives the Path Maximum Transfer Unit (PMTU). AIX 5.3 does not display the PMTU column.Interface— Indicates the network interfaces utilized for the route.Exp— Displays the time (in minutes) remaining before the route expires.Groups— Provides a list of group IDs associated with that route.Netmasks— Lists the netmasks applied on the system.Route Tree for Protocol Family— Specifies the active address families for existing routes. Supported values for this field are: 1 Specifies the UNIX address family. 2 Specifies the Internet address family (for example, TCP and UDP). For more information on other address families, refer to the /usr/include/sys/socket.h file.
When the -@ flag is used with the netstat -r command and no WparName parameter is specified, all of the routes in the system’s route table are displayed. If the WparName parameter is specified and the WPAR-specific routing is enabled for that WPAR, only the routes associated with that WPAR are displayed. If the WparName parameter is specified and the WPAR specific routing is disabled for that WPAR, the routes associated with the global system are displayed.
When a value is specified for the Interval parameter, the netstat command displays a running count of statistics related to network interfaces. This display contains two columns: a column for the primary interface (the first interface found during autoconfiguration) and a column summarizing information for all interfaces.
The primary interface may be replaced with another interface by using the -I flag. The first line of each screen of information contains a summary of statistics accumulated since the system was last restarted. The subsequent lines of output show values accumulated over intervals of the specified length.
보안
RBAC 사용자와 Trusted AIX 사용자는 주의하세요. 이 명령은 특권 작업을 할 수 있으며, 특권 작업은 특권 사용자만 할 수 있습니다. 특권과 권한 목록은 lssecattr 명령이나 getcmdattr 하위 명령으로 봅니다(6.1 문서에만 있음).
영어 원문
Attention RBAC users and Trusted AIX users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand.
예제
- 인터넷 인터페이스의 라우팅 표 정보를 봅니다. 인터페이스 열에서
en은 표준 이더넷,tr은 토큰 링이며, 게이트웨이 주소는 점 10진수입니다. AIX 5.3은 PMTU 열을 보여 주지 않습니다.
netstat -r -f inet
Route Tree for Protocol Family 2:
default 129.35.38.47 UG 0 564 - tr0 -
loopback 127.0.0.1 UH 1 202 - lo0 -
129.35.32 129.35.41.172 U 4 30 - tr0 - +staff
129.35.32.117 129.35.41.172 UGHW 0 13 1492 tr0 30
192.100.61 192.100.61.11 U 1 195 - en0 -
- GRE 프로토콜 통계를 봅니다(
gre_input·gre_output호출 수, 지원하지 않는 프로토콜, 체크섬·라우팅·키·순서 번호가 있는 패킷, 버린 패킷, NAT로 받은 패킷 수 등).
netstat -s -p gre
- (6.1) IPv4 over IPv6 터널(GIF) 통계를 봅니다.
netstat -s -p gif
GIF Interface gif0
44 total packets received
50 total packets sent
0 packets received with protocol not supported
...
0 packets dropped due to error in ipv6 output routine
- 인터넷 인터페이스의 정보를 봅니다. Name 열의
lo는 루프백,en은 표준 이더넷,tr은 토큰 링입니다.
netstat -i -f inet
Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll
lo0 16896 Link#1 5161 0 5193 0 0
lo0 16896 127 localhost 5161 0 5193 0 0
lo0 16896 ::1 5161 0 5193 0 0
en1 1500 Link#2 8.0.38.22.8.34 221240 0 100284 0 0
en1 1500 129.183.64 infoserv.frec.bul 221240 0 100284 0 0
- 프로토콜별 통계를 봅니다.
ip는 인터넷 프로토콜,icmp는 인터넷 제어 메시지 프로토콜,tcp는 전송 제어 프로토콜,udp는 사용자 데이터그램 프로토콜입니다. AIX 5.3은 IP의 PMTU 통계를 보여 주지 않습니다. 전체 출력은 영어 원문에 있습니다.
netstat -s -f inet
ip:
44485 total packets received
0 bad header checksums
...
0 ipintrq overflows
tcp:
1393 packets sent
857 data packets (135315 bytes)
0 data packets (0 bytes) retransmitted
...
udp:
42886 datagrams received
...
0 socket buffer overflows
- 장치 드라이버 통계를 봅니다. 올라와 있는 CDLI 기반 장치 드라이버마다 통계를 보여 줍니다. 출력 예는
tokstat,entstat,fddistat을 봅니다.
netstat -v
- 멀티캐스트가 켜진 인터페이스의 정보와 그룹 가입 상태를 봅니다.
netstat -a -I interface
802.3 인터페이스면 다음과 비슷합니다.
Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll
et0 1492 <Link> 0 0 2 0 0
et0 1492 9.4.37 hun-eth 0 0 2 0 0
224.0.0.1
02:60:8c:0a:02:e7
01:00:5e:00:00:01
-I interface 대신 -i를 주면 구성된 모든 인터페이스가 나옵니다. Name 열의 lo는 루프백, et는 IEEE 802.3, tr은 토큰 링, fi는 FDDI입니다. Address 열에는 인터페이스마다 이름이 나오고, 그 아래에 가입한 멀티캐스트 그룹 주소가 나옵니다. 224.0.0.1은 모든 멀티캐스트 인터페이스가 속하는 특별한 all-hosts 그룹입니다. 그룹 주소 다음에는 인터페이스의 MAC 주소(콜론 표기)와 IP 멀티캐스트를 위해 켠 다른 MAC 수준 주소가 나옵니다.
- 통신 하위 시스템의 패킷 수를 봅니다. 장치, 드라이버, 디먹서, 프로토콜(IP, TCP, UDP), 네트워크 인터페이스, NFS/RPC 계층별로 Ipkts, Opkts, Idrops, Odrops와 합계가 나옵니다(
N/A는 해당 없음).
netstat -D
- 활성 소켓의 자세한 데이터를 봅니다. 소켓마다
so_options, 큐 길이, 송수신 버퍼(hiwat,lowat,mbcnt,mbmax), TCPmss등이 나옵니다.
netstat -aon
- 라우팅 표를 숫자로 봅니다. AIX 5.3은 PMTU 열을 보여 주지 않습니다.
netstat -rn
Routing tables
Destination Gateway Flags Refs Use If PMTU Exp Groups
Route Tree for Protocol Family 2 (Internet):
default 9.3.149.65 UG 0 24 en0 - -
9.3.149.64 9.3.149.88 UHSb 0 0 en0 - - =>
9.3.149.64/27 9.3.149.88 U 1 0 en0 - -
9.3.149.88 127.0.0.1 UGHS 0 1 lo0 - -
9.3.149.95 9.3.149.88 UHSb 0 0 en0 - -
127/8 127.0.0.1 U 11 174 lo0 - -
Route Tree for Protocol Family 24 (Internet v6):
::1 ::1 UH 0 0 lo0 - -
줄 끝의 =>는 그 줄이 다음 줄 경로와 겹친다는 뜻입니다. 루프백 경로(9.3.149.88, 127.0.0.1)와 브로드캐스트 경로(Flags에 b)는 인터페이스를 구성하면 자동으로 만들어집니다. 브로드캐스트 경로는 서브넷 주소와 서브넷 브로드캐스트 주소로 두 개가 더해지며, 루프백·브로드캐스트 경로는 성능을 높입니다.
- (6.1) WPAR
wpar1의 라우팅 표를 봅니다. 첫 열에 WPAR 이름이 나옵니다.
netstat -rn@ wpar1
자주 쓰는 형태:
netstat -an | grep LISTEN # 열려 있는 포트
netstat -an | grep "\.22 " # 22번 포트 연결
netstat -rn # 기본 게이트웨이 확인
netstat -in # 인터페이스별 오류(Ierrs, Oerrs)
netstat -s -p tcp | grep -i retrans # 재전송 통계
netstat -m | head # mbuf 부족 여부
영어 원문
- To display routing table information for an Internet interface, enter the following command:
netstat -r -f inet
This produces the following output:
Routing tables
Destination Gateway Flags Refs Use PMTU If Exp Groups Netmasks:
(root node)
(0)0 ffff f000 0
(0)0 ffff f000 0
(0)0 8123 262f 0 0 0 0 0
(root node)
Route Tree for Protocol Family 2:
(root node)
default 129.35.38.47 UG 0 564 - tr0 -
loopback 127.0.0.1 UH 1 202 - lo0 -
129.35.32 129.35.41.172 U 4 30 - tr0 - +staff
129.35.32.117 129.35.41.172 UGHW 0 13 1492 tr0 30
192.100.61 192.100.61.11 U 1 195 - en0 -
(root node)
Route Tree for Protocol Family 6:
(root node)
(root node)
The -r -f inet flags indicate a request for routing table information for all configured Internet interfaces. The network interfaces are listed in the Interface column; en designates a Standard Ethernet interface, while tr specifies a Token-Ring interface. Gateway addresses are in dotted decimal format.
Note: AIX 5.3 does not display the PMTU column.
- To display statistics for GRE Protocol, enter the following command:
netstat -s -p gre
This produces the following output:
GRE Interface gre0
10 number of times gre_input got called
8 number of times gre_output got called
0 packets received with protocol not supported
0 packets received with checksum on
0 packets received with routing present
0 packets received with key present
0 packets received with sequence number present
0 packets received with strict source route present
0 packets received with recursion control present
0 packets received where reserved0 non-zero
0 packets received where version non-zero
0 packets discarded
0 packets dropped due to network down
0 packets dropped due to protocol not supported
0 packets dropped due to error in ip output routine
0 packets got by NAT
0 packets got by NAT but not TCP packet
0 packets got by NAT but with IP options
- To display statistics for the IPv4 over IPv6 tunnel (GIF tunnel), enter the following command:
netstat -s -p gif
The command produces the following output:
GIF Interface gif0
44 total packets received
50 total packets sent
0 packets received with protocol not supported
0 packets received with checksum on
0 packets received with routing present
0 packets received with strict source route present
0 packets received where version non-zero
0 packets discarded
0 packets dropped due to network down
0 packets dropped due to protocol not supported
0 packets dropped due to error in ipv6 output routine
- To display interface information for an Internet interface, enter the following command:
netstat -i -f inet
This produces the following output:
Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll
lo0 16896 Link#1 5161 0 5193 0 0
lo0 16896 127 localhost 5161 0 5193 0 0
lo0 16896 ::1 5161 0 5193 0 0
en1 1500 Link#2 8.0.38.22.8.34 221240 0 100284 0 0
en1 1500 129.183.64 infoserv.frec.bul 221240 0 100284 0 0
The -i -f inet flags indicate a request for the status of all configured Internet interfaces. The network interfaces are listed in the Name column; lo designates a loopback interface, en designates a Standard Ethernet interface, while tr specifies a Token-Ring interface.
- To display statistics for each protocol, enter the following command:
netstat -s -f inet
This produces the following output:
ip:
:
44485 total packets received
0 bad header checksums
0 with size smaller than minimum
0 with data size < data length
0 with header length < data size
0 with data length < header length
0 with bad options
0 with incorrect version number
0 fragments received
0 fragments dropped (dup or out of space)
0 fragments dropped after timeout
0 packets reassembled ok
44485 packets for this host
0 packets for unknown/unsupported protocol
0 packets forwarded
0 packets not forwardable
0 redirects sent
1506 packets sent from this host
0 packets sent with fabricated ip header
0 output packets dropped due to no bufs, etc.
0 output packets discarded due to no route
0 output datagrams fragmented
0 fragments created
0 datagrams that can’t be fragmented
0 IP Multicast packets dropped due to no receiver
0 successful path MTU discovery cycles
0 path MTU rediscovery cycles attempted
0 path MTU discovery no-response estimates
0 path MTU discovery response timeouts
0 path MTU discovery decreases detected
0 path MTU discovery packets sent
0 path MTU discovery memory allocation failures
0 ipintrq overflows
icmp:
0 calls to icmp_error
0 errors not generated ’cuz old message was icmp
Output histogram:
echo reply: 6
0 messages with bad code fields
0 messages < minimum length
0 bad checksums
0 messages with bad length
Input histogram:
echo: 19
6 message responses generated
igmp:defect
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
tcp:
1393 packets sent
857 data packets (135315 bytes)
0 data packets (0 bytes) retransmitted
367 URG only packets
0 URG only packets
0 window probe packets
0 window update packets
170 control packets
1580 packets received
790 acks (for 135491 bytes)
60 duplicate acks
0 acks for unsent data
638 packets (2064 bytes) received in-sequence
0 completely duplicate packets (0 bytes)
0 packets with some dup. data (0 bytes duped)
117 out-of-order packets (0 bytes)
0 packets (0 bytes) of data after window
0 window probes
60 window update packets
0 packets received after close
0 discarded for bad checksums
0 discarded for bad header offset fields
0 connection request
58 connection requests
61 connection accepts
118 connections established (including accepts)
121 connections closed (including 0 drops)
0 embryonic connections dropped
845 segments updated rtt (of 847 attempts)
0 resends due to path MTU discovery
0 path MTU discovery terminations due to retransmits
0 retransmit timeouts
0 connections dropped by rexmit timeout
0 persist timeouts
0 keepalive timeouts
0 keepalive probes sent
0 connections dropped by keepalive
udp:
42886 datagrams received
:
0 incomplete headers
0 bad data length fields
0 bad checksums
0 dropped due to no socket
42860 broadcast/multicast datagrams dropped due to no
socket
0 socket buffer overflows
26 delivered
106 datagrams output
ip specifies the Internet Protocol; icmp specifies the Information Control Message Protocol; tcp specifies the Transmission Control Protocol; udp specifies the User Datagram Protocol.
Note: AIX 5.3 does not display the PMTU statistics for the IP protocol.
- To display device driver statistics, enter the following command:
netstat -v
The netstat -v command displays the statistics for each CDLI-based device driver that is up. To see sample output for this command, see the tokstat command, the entstat command, or the fddistat command.
- To display information regarding an interface for which multicast is enabled, and to see group membership, enter the following command:
netstat -a -I interface
For example, if an 802.3 interface was specified, the following output will be produced:
Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll
et0 1492 <Link> 0 0 2 0 0
et0 1492 9.4.37 hun-eth 0 0 2 0 0
224.0.0.1
02:60:8c:0a:02:e7
01:00:5e:00:00:01
If instead of -I interface the flag -i is given, then all configured interfaces will be listed. The network interfaces are listed in the Name column; lo designates a loopback interface, et designates an IEEE 802.3 interface, tr designates a Token-Ring interface, while fi specifies an FDDI interface. The address column has the following meaning. A symbolic name for each interface is shown. Below this symbolic name, the group addresses of any multicast groups that have been joined on that interface are shown. Group address 224.0.0.1 is the special all-hosts-group to which all multicast interfaces belong. The MAC address of the interface (in colon notation) follows the group addresses, plus a list of any other MAC level addresses that are enabled on behalf of IP Multicast for the particular interface.
- To display the packet counts in the communication subsystem, enter the following command:
netstat -D
The following output will be produced:
Source Ipkts Opkts Idrops Odrops
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
tok_dev0 720 542 0 0
ent_dev0 114 4 0 0
- - - - - - - - - - - - - - - - - - - - - - - - -
Devices Total 834 546 0 0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
tok_dd0 720 542 0 0
ent_dd0 114 4 0 0
- - - - - - - - - - - - - - - - - - - - - - - - -
Drivers Total 834 546 0 0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
tok_dmx0 720 N/A 0 N/A
ent_dmx0 114 N/A 0 N/A
- - - - - - - - - - - - - - - - - - - - - - - - -
Demuxer Total 834 N/A 0 N/A
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IP 773 767 0 0
TCP 536 399 0 0
UDP 229 93 0 0
- - - - - - - - - - - - - - - - - - - - - - - - -
Protocols Total 1538 1259 0 0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
lo_if0 69 69 0 0
en_if0 22 8 0 0
tr_if0 704 543 0 1
- - - - - - - - - - - - - - - - - - - - - - - - -
Net IF Total 795 620 0 1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NFS/RPC Client 519 N/A 0 N/A
NFS/RPC Server 0 N/A 0 N/A
NFS Client 519 N/A 0 N/A
NFS Server 0 N/A 0 N/A
- - - - - - - - - - - - - - - - - - - - - - - - -
NFS/RPC Total N/A 519 0 0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Note: N/A -> Not Applicable)
- To display detailed data of active sockets, enter the following command:
netstat -aon
Output similar to the following is displayed:
Active Internet connections (including servers)
Proto Recv-Q Send-Q Local Address Foreign Address (state)
tcp4 0 0 *.13 *.* LISTEN
so_options: (ACCEPTCONN|REUSEADDR)
q0len:0 qlen:0 qlimit:1000 so_state: (PRIV)
timeo:0 uid:0
so_special: (LOCKBALE|MEMCOMPRESS|DISABLE)
so_special2: (PROC)
sndbuf:
hiwat:16384 lowat:4096 mbcnt:0 mbmax:65536
rcvbuf:
hiwat:16384 lowat:1 mbcnt:0 mbmax:65536
sb_flags: (SEL)
TCP:
mss:512
tcp 0 0 *.21 *.* LISTEN
so_options: (ACCEPTCONN|REUSEADDR)
q0len:0 qlen:0 qlimit:1000 so_state: (PRIV)
timeo:0 uid:0
so_special: (LOCKBALE|MEMCOMPRESS|DISABLE)
so_special2: (PROC)
sndbuf:
hiwat:16384 lowat:4096 mbcnt:0 mbmax:65536
rcvbuf:
hiwat:16384 lowat:1 mbcnt:0 mbmax:65536
sb_flags: (SEL)
TCP:
mss:512
...................
...................
- To display the routing table, enter the following command:
netstat -rn
Output similar to the following is displayed:
Routing tables
Destination Gateway Flags Refs Use If PMTU Exp Groups
Route Tree for Protocol Family 2 (Internet):
default 9.3.149.65 UG 0 24 en0 - -
9.3.149.64 9.3.149.88 UHSb 0 0 en0 - - =>
9.3.149.64/27 9.3.149.88 U 1 0 en0 - -
9.3.149.88 127.0.0.1 UGHS 0 1 lo0 - -
9.3.149.95 9.3.149.88 UHSb 0 0 en0 - -
127/8 127.0.0.1 U 11 174 lo0 - -
Route Tree for Protocol Family 24 (Internet v6):
::1 ::1 UH 0 0 lo0 - -
Note: AIX 5.3 does not display the PMTU column.
The character => at the end of the line means the line is a duplicate route of the route on the next line. The loopback route (9.3.149.88, 127.0.0.1) and the broadcast routes (with the flags field containing b indicating broadcast) are automatically created when an interface is configured. Two broadcast routes are added: one to the subnet address and one to the broadcast address of the subnet. The presence of the loopback routes and broadcast routes improve performance.
- To display the routing table of a workload partition named
wpar1, enter the following command:
netstat -rn@ wpar1
Output similar to the following is displayed:
Routing tables
WPAR Destination Gateway Flags Refs Use If Exp Groups
Route Tree for Protocol Family 2 (Internet):
wpar1 default 9.4.150.1 UG 1 13936 en1 - -
wpar1 9.4.150.0 9.4.150.57 UHSb 0 0 en1 - - =>
wpar1 9.4.150/24 9.4.150.57 U 0 0 en0 - -
wpar1 9.4.150.57 127.0.0.1 UGHS 0 0 lo0 - -
wpar1 9.4.150.255 9.4.150.57 UHSb 0 3 en0 - -
Related information:
- protocols File Format for TCP/IP
- tokstat command
- vmstat command
- Naming command
- TCP/IP addressing
리눅스(GNU)와 다른 점
리눅스에서도 netstat(net-tools)을 쓸 수 있지만 지금은 ss와 ip를 주로 씁니다. netstat -an은 ss -an(ss -tlnp로 듣는 TCP 포트와 프로세스), netstat -rn은 ip route, netstat -in은 ip -s link, netstat -s는 nstat이나 ss -s에 해당합니다. 리눅스 netstat -p는 프로세스 이름을 보여 주는 옵션으로, AIX의 -p 프로토콜과 뜻이 다릅니다. AIX에서 소켓을 연 프로세스를 찾으려면 netstat -Aan으로 제어 블록 주소를 얻고 rmsock 주소 tcpcb를 씁니다.