Linux china open port

Как посмотреть открытые порты в Linux

Сетевые порты — это механизм, с помощью которого операционная система определяет какой именно программе необходимо передать сетевой пакет. Здесь можно привести пример с домом. Например, почтальону необходимо доставить посылку. Он доставляет посылку к дому, это IP адрес компьютера. А дальше в самом доме уже должны разобраться в какую квартиру направить эту посылку. Номер квартиры — это уже порт.

Если порт открыт это означает, что какая либо программа, обычно сервис, использует его для связи с другой программой через интернет или в локальной системе. Чтобы посмотреть какие порты открыты в вашей системе Linux можно использовать множество различных утилит. В этой статье мы рассмотрим самые популярные способы посмотреть открытые порты Linux.

Как посмотреть открытые порты linux

1. netstat

Утилита netstat позволяет увидеть открытые в системе порты, а также открытые на данный момент сетевые соединения. Для отображения максимально подробной информации надо использовать опции:

  • -l или —listening — посмотреть только прослушиваемые порты;
  • -p или —program — показать имя программы и ее PID;
  • -t или —tcp — показать tcp порты;
  • -u или —udp показать udp порты;
  • -n или —numeric показывать ip адреса в числовом виде.

Открытые порты Linux, которые ожидают соединений имеют тип LISTEN, а перед портом отображается IP адрес на котором сервис ожидает подключений. Это может быть определенный IP адрес или */0.0.0.0 что означают любой доступный адрес:

sudo netstat -tulpn

Утилита ss — это современная альтернатива для команды netstat. В отличие от netstat, которая берет информацию из каталога /proc, утилита ss напрямую связывается со специальной подсистемой ядра Linux, поэтому работает быстрее и её данные более точные, если вы хотите выполнить просмотр открытых портов это не имеет большого значения. Опции у неё такие же:

Можно вывести только процессы, работающие на 80-том порту:

sudo ss -tulpn | grep :80

3. lsof

Утилита lsof позволяет посмотреть все открытые в системе соединения, в том числе и сетевые, для этого нужно использовать опцию -i, а чтобы отображались именно порты, а не названия сетевых служб следует использовать опцию -P:

Ещё один пример, смотрим какие процессы работают с портом 80:

sudo lsof -i -P | grep :80

4. Nmap

Программа Nmap — мощный сетевой сканер, разработанный для сканирования и тестирования на проникновение удаленных узлов, но ничего не мешает направить его на локальный компьютер. Утилита позволяет не только посмотреть открытые порты, но и примерно определить какие сервисы их слушают и какие уязвимости у них есть. Программу надо установить:

sudo apt install nmap

Затем можно использовать:

Для простого сканирования можно запускать утилиту без опций. Детальнее о её опциях можно узнать в статье про сканирование сети в Nmap. Эта утилита ещё будет полезна если вы хотите посмотреть какие порты на компьютере доступны из интернета.

Если это публичный сервер, то результат скорее всего не будет отличатся от локального сканирования, но на домашнем компьютере все немного по другому. Первый вариант — используется роутер и в сеть будут видны только порты роутера, еще одним порогом защиты может стать NAT-сервер провайдера. Технология NAT позволяет нескольким пользователям использовать один внешний IP адрес. И так для просмотра открытых внешних портов сначала узнаем внешний ip адрес, для надежности воспользуемся онлайн сервисом:

wget -O — -q eth0.me

Дальше запускаем сканирование:

В результате мы видим, что открыт порт 80 веб-сервера и 22 — порт службы ssh, я их не открывал, эти порты открыты роутером, 80 — для веб-интерфейса, а 22 для может использоваться для обновления прошивки. А еще можно вообще не получить результатов, это будет означать что все порты закрыты, или на сервере установлена система защиты от вторжений IDS. Такая проверка портов может оказаться полезной для того, чтобы понять находится ли ваш компьютер в безопасности и нет ли там лишних открытых портов, доступных всем.

Читайте также:  Сжатие системного диска windows 10 для чего

5. Zenmap

Программа Zenmap — это графический интерфейс для nmap. Она не делает ничего нового кроме того, что может делать nmap, просто предоставляет ко всему этому удобный интерфейс. Для её установки выполните:

sudo apt install zenmap

Запустить программу можно из главного меню или командой:

Затем введите адрес localhost в поле Цель и нажмите кнопку Сканирование:

После завершения сканирования утилита вывела список открытых портов Linux.

Выводы

В этой статье мы рассмотрели инструменты, которые вы можете использовать для того чтобы узнать узнать открытые порты linux. Инструментов не так много как для просмотра информации об оперативной памяти или процессоре, но их вполне хватает. А какими программами пользуетесь вы? Напишите в комментариях!

Источник

Linux china open port

Recently, we wrote two articles on the same topic. These articles help you to check whether the given port in the remote server is open.

if you want Check if the port on the remote Linux system is open [1] Please click the link to browse. if you want Check if ports on multiple remote Linux systems are open [2] Please click the link to browse. if you want Check the status of multiple ports on multiple remote Linux systems [2] Please click the link to browse.

But this article helps you check the list of open ports on the local system.

There are very few utilities for this purpose in Linux. However, I provide the four most important Linux commands to check this.

You can use the following four commands to complete this work. These commands are very famous and widely used by Linux administrators.

◈ netstat: Netstat («network statistics») is a command-line tool that displays information about network connections (in and out), such as routing tables, disguised connections, multicast members and network ports. ◈nmap: Nmap («Network Mapper») is an open source tool for network exploration and security auditing. It is designed to quickly scan large networks. ◈ss: Used to dump socket statistics. It can also be used similar to netstat. It can display more TCP status information than other tools. ◈lsof:Lsof is short for List Open. It is used to output all files opened by a certain process.

How to use the Linux command netstat to check the list of open ports in the system

netstatIt is an abbreviation of Network Statistics, which is a command-line tool that displays information about network connections (in and out), such as routing tables, disguised connections, multicast members, and network ports.

It can list all tcp, udp connections and all unix socket connections.

It is used to discover network problems and determine the number of network connections.

  1. # netstat — tplugn
  2. Active Internet connections ( only servers )
  3. Proto Recv — Q Send — Q Local Address Foreign Address State PID / Program name
  4. tcp 0 0 0.0 . 0.0 : 25 0.0 . 0.0 :* LISTEN 2038 / master
  5. tcp 0 0 127.0 . 0.1 : 199 0.0 . 0.0 :* LISTEN 1396 / snmpd
  6. tcp 0 0 0.0 . 0.0 : 80 0.0 . 0.0 :* LISTEN 1398 / httpd
  7. tcp 0 0 0.0 . 0.0 : 22 0.0 . 0.0 :* LISTEN 1388 / sshd
  8. tcp6 0 0 . 25 . * LISTEN 2038 / master
  9. tcp6 0 0 . 22 . * LISTEN 1388 / sshd
  10. udp 0 0 0.0 . 0.0 : 39136 0.0 . 0.0 :* 1396 / snmpd
  11. udp 0 0 0.0 . 0.0 : 56130 0.0 . 0.0 :* 1396 / snmpd
  12. udp 0 0 0.0 . 0.0 : 40105 0.0 . 0.0 :* 1396 / snmpd
  13. udp 0 0 0.0 . 0.0 : 11584 0.0 . 0.0 :* 1396 / snmpd
  14. udp 0 0 0.0 . 0.0 : 30105 0.0 . 0.0 :* 1396 / snmpd
  15. udp 0 0 0.0 . 0.0 : 50656 0.0 . 0.0 :* 1396 / snmpd
  16. udp 0 0 0.0 . 0.0 : 1632 0.0 . 0.0 :* 1396 / snmpd
  17. udp 0 0 0.0 . 0.0 : 28265 0.0 . 0.0 :* 1396 / snmpd
  18. udp 0 0 0.0 . 0.0 : 40764 0.0 . 0.0 :* 1396 / snmpd
  19. udp 0 0 10.90 . 56.21 : 123 0.0 . 0.0 :* 895 / ntpd
  20. udp 0 0 127.0 . 0.1 : 123 0.0 . 0.0 :* 895 / ntpd
  21. udp 0 0 0.0 . 0.0 : 123 0.0 . 0.0 :* 895 / ntpd
  22. udp 0 0 0.0 . 0.0 : 53390 0.0 . 0.0 :* 1396 / snmpd
  23. udp 0 0 0.0 . 0.0 : 161 0.0 . 0.0 :* 1396 / snmpd
  24. udp6 0 0 . 123 . * 895 / ntpd
  25. IPv6 / IPv4 Group Memberships
  26. Interface RefCnt Group
  27. ————— —— ———————
  28. lo 1 224.0 . 0.1
  29. eth0 1 224.0 . 0.1
  30. lo 1 ff02 :: 1
  31. lo 1 ff01 :: 1
  32. eth0 1 ff02 :: 1
  33. eth0 1 ff01 :: 1
Читайте также:  Копирование с помощью проводника windows

You can also use the following command to check a specific port.

  1. # # netstat — tplugn | grep : 22
  2. tcp 0 0 0.0 . 0.0 : 22 0.0 . 0.0 :* LISTEN 1388 / sshd
  3. tcp6 0 0 . 22 . * LISTEN 1388 / sshd

How to use the Linux command to check the list of open ports in the system?

ssUsed to dump socket statistics. It can also display something likenetstat Information. It can display more TCP status information than other tools.

  1. # ss — lntu
  2. Netid State Recv — Q Send — Q Local Address : Port Peer Address : Port
  3. udp UNCONN 0 0 *: 39136 *:*
  4. udp UNCONN 0 0 *: 56130 *:*
  5. udp UNCONN 0 0 *: 40105 *:*
  6. udp UNCONN 0 0 *: 11584 *:*
  7. udp UNCONN 0 0 *: 30105 *:*
  8. udp UNCONN 0 0 *: 50656 *:*
  9. udp UNCONN 0 0 *: 1632 *:*
  10. udp UNCONN 0 0 *: 28265 *:*
  11. udp UNCONN 0 0 *: 40764 *:*
  12. udp UNCONN 0 0 10.90 . 56.21 : 123 *:*
  13. udp UNCONN 0 0 127.0 . 0.1 : 123 *:*
  14. udp UNCONN 0 0 *: 123 *:*
  15. udp UNCONN 0 0 *: 53390 *:*
  16. udp UNCONN 0 0 *: 161 *:*
  17. udp UNCONN 0 0 . 123 . *
  18. tcp LISTEN 0 100 *: 25 *:*
  19. tcp LISTEN 0 128 127.0 . 0.1 : 199 *:*
  20. tcp LISTEN 0 128 *: 80 *:*
  21. tcp LISTEN 0 128 *: 22 *:*
  22. tcp LISTEN 0 100 . 25 . *
  23. tcp LISTEN 0 128 . 22 . *

You can also use the following command to check a specific port.

  1. # # ss — lntu | grep ‘:25’
  2. tcp LISTEN 0 100 *: 25 *:*
  3. tcp LISTEN 0 100 . 25 . *

How to use the Linux command nmap to check the list of open ports in the system?

Nmap («Network Mapper») is an open source tool for network exploration and security auditing. It is designed to quickly scan large networks, but of course it can also work on a standalone host.

Nmap uses bare IP packets in a novel way to determine which hosts are available on the network, what services (application name and version) these hosts provide, what operating system (version) they run, and what type of packet filtering is used / Firewall, and many other features.

Although Nmap is commonly used for security audits, many system and network administrators find it also useful for daily work, such as inventorying network assets, managing service upgrade plans, and monitoring host or service uptime.

  1. # nmap — sTU — O localhost
  2. Starting Nmap 6.40 ( http : //nmap.org ) at 2019-03-20 09:57 CDT
  3. Nmap scan report for localhost ( 127.0 . 0.1 )
  4. Host is up ( 0.00028s latency ).
  5. Other addresses for localhost ( not scanned ): 127.0 . 0.1
  6. Not shown : 1994 closed ports
  7. PORT STATE SERVICE
  8. 22 / tcp open ssh
  9. 25 / tcp open smtp
  10. 80 / tcp open http
  11. 199 / tcp open smux
  12. 123 / udp open ntp
  13. 161 / udp open snmp
  14. Device type : general purpose
  15. Running : Linux 3.X
  16. OS CPE : cpe :/ o : linux : linux_kernel : 3
  17. OS details : Linux 3.7 — 3.9
  18. Network Distance : 0 hops
  19. OS detection performed . Please report any incorrect results at http : //nmap.org/submit/ .
  20. Nmap done : 1 IP address ( 1 host up ) scanned in 1.93 seconds
Читайте также:  Anno 1701 для windows

You can also use the following command to check a specific port.

  1. # nmap — sTU — O localhost | grep 123
  2. 123 / udp open ntp

How to use Linux command to check the list of open ports in the system?

It shows you the list of open files on the system and the process of opening them. It will also show you other information related to the file.

  1. # lsof — i
  2. COMMAND PID USER FD TYPE DEVICE SIZE / OFF NODE NAME
  3. ntpd 895 ntp 16u IPv4 18481 0t0 UDP *: ntp
  4. ntpd 895 ntp 17u IPv6 18482 0t0 UDP *: ntp
  5. ntpd 895 ntp 18u IPv4 18487 0t0 UDP localhost : ntp
  6. ntpd 895 ntp 20u IPv4 23020 0t0 UDP CentOS7 . 2daygeek . com : ntp
  7. sshd 1388 root 3u IPv4 20065 0t0 TCP *: ssh ( LISTEN )
  8. sshd 1388 root 4u IPv6 20067 0t0 TCP *: ssh ( LISTEN )
  9. snmpd 1396 root 6u IPv4 22739 0t0 UDP *: snmp
  10. snmpd 1396 root 7u IPv4 22729 0t0 UDP *: 40105
  11. snmpd 1396 root 8u IPv4 22730 0t0 UDP *: 50656
  12. snmpd 1396 root 9u IPv4 22731 0t0 UDP *: pammratc
  13. snmpd 1396 root 10u IPv4 22732 0t0 UDP *: 30105
  14. snmpd 1396 root 11u IPv4 22733 0t0 UDP *: 40764
  15. snmpd 1396 root 12u IPv4 22734 0t0 UDP *: 53390
  16. snmpd 1396 root 13u IPv4 22735 0t0 UDP *: 28265
  17. snmpd 1396 root 14u IPv4 22736 0t0 UDP *: 11584
  18. snmpd 1396 root 15u IPv4 22737 0t0 UDP *: 39136
  19. snmpd 1396 root 16u IPv4 22738 0t0 UDP *: 56130
  20. snmpd 1396 root 17u IPv4 22740 0t0 TCP localhost : smux ( LISTEN )
  21. httpd 1398 root 3u IPv4 20337 0t0 TCP *: http ( LISTEN )
  22. master 2038 root 13u IPv4 21638 0t0 TCP *: smtp ( LISTEN )
  23. master 2038 root 14u IPv6 21639 0t0 TCP *: smtp ( LISTEN )
  24. sshd 9052 root 3u IPv4 1419955 0t0 TCP CentOS7 . 2daygeek . com : ssh -> Ubuntu18 — 04.2daygeek . com : 11408 ( ESTABLISHED )
  25. httpd 13371 apache 3u IPv4 20337 0t0 TCP *: http ( LISTEN )
  26. httpd 13372 apache 3u IPv4 20337 0t0 TCP *: http ( LISTEN )
  27. httpd 13373 apache 3u IPv4 20337 0t0 TCP *: http ( LISTEN )
  28. httpd 13374 apache 3u IPv4 20337 0t0 TCP *: http ( LISTEN )
  29. httpd 13375 apache 3u IPv4 20337 0t0 TCP *: http ( LISTEN )

You can also use the following command to check a specific port.

  1. # lsof — i : 80
  2. COMMAND PID USER FD TYPE DEVICE SIZE / OFF NODE NAME
  3. httpd 1398 root 3u IPv4 20337 0t0 TCP *: http ( LISTEN )
  4. httpd 13371 apache 3u IPv4 20337 0t0 TCP *: http ( LISTEN )
  5. httpd 13372 apache 3u IPv4 20337 0t0 TCP *: http ( LISTEN )
  6. httpd 13373 apache 3u IPv4 20337 0t0 TCP *: http ( LISTEN )
  7. httpd 13374 apache 3u IPv4 20337 0t0 TCP *: http ( LISTEN )
  8. httpd 13375 apache 3u IPv4 20337 0t0 TCP *: http ( LISTEN )

Author: Magesh Maruthamuthu [4] Topics: lujun9972 Translator: heguangzhi Proofreading: wxy

This article consists of LCTT Original compilation, Linux China Honor launch

Источник

Оцените статью