Netstat

netstat
Developer(s)Various open-source and commercial developers
Initial release1983; 41 years ago (1983)
Written inPlan 9: C
Operating systemUnix, Unix-like, Plan 9, Inferno, OS/2, Microsoft Windows, ReactOS
PlatformCross-platform
TypeCommand
LicenseOS/2, Windows: Proprietary commercial software
net-tools, ReactOS: GPLv2
Plan 9: MIT License

In computing, netstat is a command-line network utility that displays open network sockets, routing tables, and a number of network interface (network interface controller or software-defined network interface) and network protocol statistics. It is available on Unix, Plan 9, Inferno, and Unix-like operating systems including macOS, Linux, Solaris and BSD. It is also available on IBM OS/2 and on Microsoft Windows NT-based operating systems including Windows XP, Windows Vista, Windows 7, Windows 8 and Windows 10.

It is used for finding problems in the network and to determine the amount of traffic on the network as a performance measurement.[1] On Linux this program is mostly obsolete, although still included in many distributions.

On Linux, netstat (part of "net-tools") is superseded by ss (part of iproute2). The replacement for netstat -r is ip route, the replacement for netstat -i is ip -s link, and the replacement for netstat -g is ip maddr, all of which are recommended instead.[2][3][4][5]

Statistics provided

Netstat provides statistics for the following:

  • Proto – The name of the protocol (TCP, UDP, etc.). On some systems, the protocol name may be followed by "4" or "6", depending on whether the protocol is running over IPv4 or IPv6.
  • Local Address – The IP address of the local computer and the port number being used. The name of the local computer that corresponds to the IP address and the name of the port is shown unless the -n parameter is specified. An asterisk (*) is shown for the host if the server is listening on all interfaces. If the port is not yet established, the port number is shown as an asterisk.
  • Foreign Address – The IP address and port number of the remote computer to which the socket is connected. The names that corresponds to the IP address and the port are shown unless the -n parameter is specified. If the port is not yet established, the port number is shown as an asterisk (*).
  • State – Indicates the state of a TCP connection. The possible states are as follows: CLOSE_WAIT, CLOSED, ESTABLISHED, FIN_WAIT_1, FIN_WAIT_2, LAST_ACK, LISTEN, SYN_RECEIVED, SYN_SEND, and TIME_WAIT. For more information about the states of a TCP connection, see RFC 793.

Parameters

Parameters used with this command must be prefixed with a hyphen (-) rather than a slash (/). Some parameters are not supported on all platforms.

Name Description Windows ReactOS macOS BSD NetBSD FreeBSD Linux Solaris OS/2
-a Displays all active connections and the TCP and UDP ports on which the computer is listening. Yes Yes Yes Yes Yes Yes
-b Displays the binary (executable) program's name involved in creating each connection or listening port. (Windows XP, Windows Server 2003 and newer Windows operating systems; not Microsoft Windows 2000 or older). Yes No No
-b Causes -i to report the total number of bytes of traffic. No Yes Yes No
-e Displays ethernet statistics, such as the number of bytes and packets sent and received. This parameter can be combined with -s. Yes Yes No
-f Displays fully qualified domain names <FQDN> for foreign addresses (only available on Windows Vista and newer operating systems). Yes No No
-f Address Family Limits display to a particular socket address family, unix, inet, inet6 No Yes No
-g Displays multicast group membership information for both IPv4 and IPv6 (may only be available on newer operating systems) No No Yes
-i Displays network interfaces and their statistics No No Yes Yes Yes Yes Yes
-m Displays the memory statistics for the networking code (STREAMS statistics on Solaris). No No Yes Yes Yes Yes Yes
-n Displays active TCP connections, however, addresses and port numbers are expressed numerically and no attempt is made to determine names. Yes Yes Yes Yes Yes Yes Yes Yes
-o Displays active TCP connections and includes the process id (PID) for each connection. You can find the application based on the PID in the Processes tab in Windows Task Manager. This parameter can be combined with -a, -n, and -p. This parameter is available on Microsoft Windows XP, Windows Server 2003, and Windows 2000 if a hotfix is applied.[6] Yes No No
-p protocol Shows connections for the protocol specified by protocol. In this case, protocol can be tcp, udp, tcpv6, or udpv6. If this parameter is used with -s to display statistics by protocol, protocol can be tcp, udp, icmp, ip, tcpv6, udpv6, icmpv6, or ipv6. Yes Yes Yes Yes Yes Yes
-p Show which processes are using which sockets (similar to -b under Windows) (you must be root to do this) No No Yes
-P protocol Shows connections for the protocol specified by protocol. In this case, protocol can be ip, ipv6, icmp, icmpv6, igmp, udp, tcp, or rawip. No No Yes
-r Displays the contents of the IP routing table. (This is equivalent to the route print command under Windows.) Yes Yes Yes Yes Yes Yes Yes Yes Yes
-s Displays statistics by protocol. By default, statistics are shown for the TCP, UDP, ICMP, and IP protocols. If the IPv6 protocol for Windows XP is installed, statistics are shown for the TCP over IPv6, UDP over IPv6, ICMPv6, and IPv6 protocols. The -p parameter can be used to specify a set of protocols. Yes Yes Yes Yes Yes Yes Yes Yes
-t Display only TCP connections. No Yes Yes
-u Display only UDP connections. No No Yes Yes
-W Display wide output - doesn't truncate hostnames or IPv6 addresses No No Yes No
-x Displays NetworkDirect connections, listeners, and shared endpoints. Yes
-y Displays the TCP connection template for all connections.Cannot be combined with the other options. Yes
-v When used in conjunction with -b it will display the sequence of components involved in creating the connection or listening port for all executables. Yes No No
Interval Redisplays the selected information every Interval seconds. Press CTRL+C to stop the redisplay. If this parameter is omitted, netstat prints the selected information only once. Yes Yes No
-h Displays help at the command prompt. Yes No Yes Yes Yes Yes Yes Yes No
-? Displays help at the command prompt. Yes No No No No No No No Yes
/? Displays help at the command prompt. Yes Yes No No No No No No No

Examples

Cross platform

On macOS, BSD systems, Linux distributions, and Microsoft Windows:

To display the statistics for only the TCP or UDP protocols, type one of the following commands:

netstat -sp tcp

netstat -sp udp

Unix-like

On Unix-like systems:

To display all ports open by a process with id pid:

netstat -aop | grep "pid"

To continuously display open TCP and UDP connections numerically and also which program is using them on Linux:

netstat -nutpacw

Windows

On Microsoft Windows:

To display active TCP connections and the process IDs every 5 seconds, type the following command (works on NT based systems only, or Windows 2000 with hotfix):

netstat -o 5

To display active TCP connections and the process IDs using numerical form, type the following command (works on NT based systems only, or Windows 2000 with hotfix):

netstat -no

*nix

Command Explanation
netstat -a Shows all sockets, both listening and non-listening, all protocols like TCP, UDP etc.
netstat -at Shows only TCP connections (-au shows only UDP connections)
netstat -ant Shows all TCP connections with no DNS resolution (show IP addresses instead).
netstat -al Shows only listening sockets.
netstat -aep Also show PID and to which program each socket belongs, e adds extra info like the user. Run as root to see all PIDs.
netstat -s Shows network statistics.
netstat -r Shows kernel routing information. This is the same output as route -e.
netstat -i Displays a table of all network interfaces. Add -e to get output similar to ifconfig.
netstat -ct Displays TCP connections continuously.
netstat -g Display multicast group membership information for IPv4 and IPv6.
netstat -lntu Display all services listening for TCP and UDP, all free open ports on the local machine.
netstat -atnp | grep ESTA Displays all currently "established" TCP connections.

Wildcards

Netstat uses an asterisk * as a wildcard which means "any". An example would be

Example output:

....Local Address Foreign Address State
... *:smtp          *:*   LISTEN

Under "Local Address" *, in *:smtp, means the process is listening on all of the network interfaces the machine has for the port mapped as smtp (see /etc/services for service resolution). This can also be shown as 0.0.0.0. The first *, in *:*, means connections can come from any IP address, and the second *, in *:*, means the connection can originate from any port on the remote machine.

Caveats

Some versions of netstat lack explicit field delimiters in their printf-generated output, leading to numeric fields running together and thus corrupting the output data.

Platform specific remarks

The ReactOS netstat command
The macOS netstat command

Under Linux, raw data can often be obtained from the /proc/net/dev to work around the printf output corruption arising in netstat's network interface statistics summary, netstat -i, until such time as the problem is corrected.[citation needed]

On the Windows platform, netstat information can be retrieved by calling the GetTcpTable and GetUdpTable functions in the IP Helper API, or IPHLPAPI.DLL. Information returned includes local and remote IP addresses, local and remote ports, and (for GetTcpTable) TCP status codes. In addition to the command-line netstat.exe tool that ships with Windows, GUI-based netstat programs are available.

On the Windows platform, this command is available only if the Internet Protocol (TCP/IP) protocol is installed as a component in the properties of a network adapter in Network Connections.

On the Windows platform running Remote Desktop Services (formerly Terminal Services) it will only show connections for the current user, not for the whole computer.

On macOS, the /System/Library/CoreServices/Applications folder (or /Applications/Utilities in OS X Mountain Lion and earlier) contains a network GUI utility called Network Utility, the Netstat tab of which runs the netstat command and displays its output in the tab.

See also

References

  1. ^ "IBM Systems Information Center". ibm.com. 8 May 2007.
  2. ^ "net-tools". linuxfoundation.org. Archived from the original on 2016-06-11. Retrieved 2014-08-02.
  3. ^ "Arch Linux". archlinux.org. 8 June 2011.
  4. ^ "Deprecated Linux networking commands and their replacements". Doug Vitale Tech Blog. 21 December 2011.
  5. ^ "netstat man page (notes section)". Retrieved 2 August 2014. This program is obsolete. Replacement for netstat is ss. Replacement for netstat -r is ip route. Replacement for netstat -i is ip -s link. Replacement for netstat -g is ip maddr.
  6. ^ "The netstat command can now display process IDs that correspond to active TCP or UDP connections in Windows 2000". Archived from the original on 24 August 2007.

Further reading

Read other articles:

This article includes a list of references, related reading, or external links, but its sources remain unclear because it lacks inline citations. Please help to improve this article by introducing more precise citations. (February 2016) (Learn how and when to remove this template message) Atlantic Steam Navigation Co LtdHouse flagIndustryTransportationFounded1934FounderFrank BustardDefunct1971SuccessorEuropean FerriesNumber of locationsTilbury, Preston & LowestoftArea servedNorth Sea &am...

 

U.S. presidential election in Maryland Main article: 1936 United States presidential election 1936 United States presidential election in Maryland ← 1932 November 3, 1936[1] 1940 → All 8 Maryland votes to the Electoral College   Nominee Franklin D. Roosevelt Alf Landon Party Democratic Republican Home state New York Kansas Running mate John Nance Garner Frank Knox Electoral vote 8 0 Popular vote 389,612 231,435 Percentage 62.35% 37.04% Co...

 

State senator for the 34th Senatorial District of the Missouri Senate This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages) This biography of a living person relies too much on references to primary sources. Please help by adding secondary or tertiary sources. Contentious material about living persons that is unsourced or poorly sourced must be removed immediately, especially if potentially lib...

Artikel ini membutuhkan penyuntingan lebih lanjut mengenai tata bahasa, gaya penulisan, hubungan antarparagraf, nada penulisan, atau ejaan. Anda dapat membantu untuk menyuntingnya. Badan Pengembangan Sumber Daya Manusia Energi dan Sumber Daya Mineral Gambaran umumDibentuk2001; 23 tahun lalu (2001)Nomenklatur sebelumnyaBadan Pendidikan dan PelatihanSloganJujur, Profesional, Melayani, Inovatif, BerartiSusunan organisasiKepala BadanPrahoro Yulianto NurtjahyoSekretaris BadanIr. Wakhid Hasyim...

 

Former synagogue in Voŭpa, Belarus Wołpa SynagogueThe former Wolpa Synagogue, 1920, Second Polish RepublicReligionAffiliationJudaism (former)Ecclesiastical or organisational statusSynagogue (–1940s)StatusDestroyedLocationLocationVoŭpaCountryBelarusThe former synagogue in what is now BelarusGeographic coordinates53°21′52″N 24°21′57″E / 53.3644°N 24.3657°E / 53.3644; 24.3657ArchitectureTypeSynagogue architectureStyleVernacularCompletedc. 1643De...

 

Map all coordinates using OpenStreetMap Download coordinates as: KML GPX (all coordinates) GPX (primary coordinates) GPX (secondary coordinates) The following is a list of the capitals of the provinces of South Africa. Province Capital Coordinates Eastern Cape Bhisho 32°51′12″S 27°26′10″E / 32.85333°S 27.43611°E / -32.85333; 27.43611 (Bhisho) Free State Bloemfontein 29°06′58″S 26°12′51″E / 29.11611°S 26.21417°E /...

Bupati Mamberamo TengahPetahanaManogar Sirait (Penjabat)sejak 6 Oktober 2023Masa jabatan5 tahun (definitif)Situs webSitus Resmi Kabupaten Mamberamo Tengah Kabupaten Mamberamo Tengah dari awal berdirinya pada tahun - hingga saat ini sudah pernah dipimpin oleh beberapa bupati. Daftar Bupati Berikut ini adalah Bupati Mamberamo Tengah dari masa ke masa. No Bupati Mulai menjabat Akhir menjabat Prd. Ket. Wakil Bupati — Ayub Kayame(Penjabat) 4 Maret 2011 25 Maret 2013 — [1] — 1 Ri...

 

Belgian tennis player This article includes a list of general references, but it lacks sufficient corresponding inline citations. Please help to improve this article by introducing more precise citations. (December 2013) (Learn how and when to remove this message) Sabine AppelmansCountry (sports) BelgiumResidenceAsse, BelgiumBorn (1972-04-22) 22 April 1972 (age 52)Aalst, BelgiumHeight1.68 m (5 ft 6 in)Turned pro1988Retired2001PlaysLeft-handed (two-handed bac...

 

Malaysian politician In this Malay name, there is no surname or family name. The name Dusuki is a patronymic, and the person should be referred to by their given name, Asyraf Wajdi. The word bin or binti/binte means 'son of' or 'daughter of', respectively. Yang Berbahagia Datuk Wira Dr.Asyraf Wajdi DusukiDCSM DIMPأشراف وجدي دسوقي‎Asyraf Wajdi in 2019Chairman of the Majlis Amanah RakyatIncumbentAssumed office 10 March 2023MinisterAhmad Zahid HamidiDirector-GeneralAz...

German journalist, theologian, and politician (1929–2004) You can help expand this article with text translated from the corresponding article in German. (January 2009) Click [show] for important translation instructions. View a machine-translated version of the German article. Machine translation, like DeepL or Google Translate, is a useful starting point for translations, but translators must revise errors as necessary and confirm that the translation is accurate, rather than simply ...

 

العلاقات الألبانية الكوستاريكية ألبانيا كوستاريكا   ألبانيا   كوستاريكا تعديل مصدري - تعديل   العلاقات الألبانية الكوستاريكية هي العلاقات الثنائية التي تجمع بين ألبانيا وكوستاريكا.[1][2][3][4][5] مقارنة بين البلدين هذه مقارنة عامة ومرجعية لل�...

 

Language GuramalumNative toPapua New GuineaRegionNew IrelandExtinctca. 2000 (3–4 cited 1987)[1]Language familyAustronesian Malayo-PolynesianOceanicNew IrelandPatpatar–TolaiGuramalumLanguage codesISO 639-3grzGlottologgura1254ELPGuramalumGuramalum is classified as Critically Endangered by the UNESCO Atlas of the World's Languages in Danger Guramalum is a presumed extinct[2] Oceanic language spoken on New Ireland in Papua New Guinea. References ^ Guramalum at Ethnologue ...

Part of a series on theCulture of Bangladesh History Timeline Outline Topics: Bengal Aviation Literature Military Postal Rulers Cyclones Years People Bangladeshis Names Diaspora List of Bangladeshi people Languages Script Dialects Vocabulary Grammar Bengali language movement Traditions Traditional games Muslim weddings Hindu weddings Textile arts Mythology and folklore Behula Bonbibi Oladevi Satya Pir Manasa Cuisine Entrées Bakarkhani Main dishes Beef hatkhora Haji biryani Kala bhuna Desser...

 

Agricultural technique Companion planting of carrots and onions. The onion smell puts off carrot root fly, while the smell of carrots puts off onion fly.[1] Companion planting in gardening and agriculture is the planting of different crops in proximity for any of a number of different reasons, including weed suppression, pest control, pollination, providing habitat for beneficial insects, maximizing use of space, and to otherwise increase crop productivity. Companion planting is a fo...

 

قابلية انضغاطمعلومات عامةالتعريف الرياضي ϰ = − 1 V d V d p {\displaystyle \varkappa =-{\frac {1}{V}}{\frac {\mathrm {d} V}{\mathrm {d} p}}} [1][2]التحليل البعدي L M − 1 T 2 {\displaystyle {\mathsf {L}}{\mathsf {M}}^{-1}{\mathsf {T}}^{2}} تعديل - تعديل مصدري - تعديل ويكي بيانات القابلية للانضغاط في الديناميكا الحرارية و الكيمياء و ا...

Rockefeller StreetSingel oleh Getter Jaanidari album Rockefeller StreetDirilis24 Januari 2011Formatunduh digitalGenreElectropopDurasi3:13LabelMoonwalkPenciptaSven LõhmusProduserSven Lõhmus Rockefeller StreetPerwakilan Kontes Lagu Eurovision 2011NegaraEstoniaArtisGetter JaaniBahasaInggrisKomposerSven LõhmusPenulis lirikSven LõhmusHasil FinalHasil semifinalKe-9Poin di semifinal60Hasil finalKe-24Poin di final44Kronologi partisipasi◄ Siren (2010)    Rockefeller Street (bahasa Indo...

 

جبال الألب في شمال إيطاليا. يزور إيطاليا نحو 43.[1] 7 مليون سائح سنوياً حيث أنها رابع أكبر مستفيد من السياحة في العالم وخامس البلاد زيارة بعد فرنسا (76.0 مليون) وإسبانيا (55.6 مليون) والولايات المتحدة (49.4 مليون) والصين (46.8 مليون). يزور السياح إيطاليا في المقام الأول لفنها الغني و�...

 

Church of St. Leodegar, Murbach Abbey Murbach Abbey garden Murbach Abbey (French: Abbaye de Murbach) was a famous Benedictine monastery in Murbach, southern Alsace, in a valley at the foot of the Grand Ballon in the Vosges. The monastery was founded in 727 by Eberhard, Count of Alsace, and established as a Benedictine house by Saint Pirmin. Its territory once comprised three towns and thirty villages. The buildings, including the abbey church, one of the earliest vaulted Romanesque structures...

Historic church in Connecticut, United States United States historic placeUnion Church/St. Paul's ChurchU.S. National Register of Historic PlacesU.S. Historic districtContributing property Show map of ConnecticutShow map of the United StatesLocation3 Robertsville Rd.,Riverton, ConnecticutCoordinates41°57′44″N 73°1′13″W / 41.96222°N 73.02028°W / 41.96222; -73.02028Arealess than one acreBuilt1829 (1829)Architectural styleGreek Revival, Gothic Reviva...

 

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: The Very Best of Chic & Sister Sledge – news · newspapers · books · scholar · JSTOR (June 2015) (Learn how and when to remove this message) 1999 greatest hits album by ChicThe Very Best of Chic & Sister SledgeGreatest hits album by ChicReleasedS...