‐ Shell - ins1x/OLT GitHub Wiki

Shell команды для диагностики сети

Большинство примеров ниже приведены для PowerShell

Проверить открыт ли порт на локалхосте:

telnet localhost 4000

Проверить процесс использующий определенный порт (Для Linux и macOS)

sudo lsof -i :4000

Проверить какие порты слушает система (Для Linux и macOS)

sudo lsof -i -P -n | grep LISTEN

После проверки вы увидите список портов со статусами:

  • LISTENING — порт открыт и ожидает соединений
  • ESTABLISHED — активное соединение
  • CLOSE_WAIT — соединение закрывается
  • TIME_WAIT — соединение завершено, но порт временно занят

Проверить коннект на определенный порт:

Test-NetConnection google.com -port 80

ComputerName     : google.com
RemoteAddress    : 142.250.130.101
RemotePort       : 80
InterfaceAlias   : Ethernet 2
SourceAddress    : 100.111.112.2
TcpTestSucceeded : True

Проверить коннект с определенным MTU и TTL:

Test-Connection -ComputerName server1 -MtuSize 1400 -Ttl 128

Команда netstat показывает статистику соединений:

netstat -an

Активные подключения

  Имя    Локальный адрес        Внешний адрес          Состояние
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:445            0.0.0.0:0              ESTABLISHED
  TCP    0.0.0.0:5040           0.0.0.0:0              TIME_WAIT
  TCP    0.0.0.0:5357           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:7680           0.0.0.0:0              LISTENING

Проверка доступности ресурса:

Test-NetConnection google.com

ComputerName           : google.com
RemoteAddress          : 142.250.130.101
InterfaceAlias         : Ethernet 3
SourceAddress          : 100.111.112.1
PingSucceeded          : True
PingReplyDetails (RTT) : 27 ms

Проверить LINK поднимается на скорости:

Get-NetAdapter

Name                      InterfaceDescription                    ifIndex Status       MacAddress             LinkSpeed
----                      --------------------                    ------- ------       ----------             ---------
Ethernet 3                Intel(R) Ethernet Connection (17) I2...      17 Up           A8-A1-59-BB-93-16         1 Gbps
Ethernet 2                Intel(R) Ethernet Connection (17) I2...      14 Up           A8-A1-59-BB-93-16       100 Mbps

Проверить настройки сетевой:

Get-NetIPConfiguration

InterfaceAlias       : Ethernet 4
InterfaceIndex       : 10
InterfaceDescription : Intel(R) Ethernet Connection (17) I219-V
NetProfile.Name      : Неопознанная сеть
IPv4Address          : 192.168.100.2
IPv4DefaultGateway   :
DNSServer            : 8.8.8.8

InterfaceAlias       : Ethernet 3
InterfaceIndex       : 17
InterfaceDescription : Intel(R) Ethernet Connection (17) I219-V
NetProfile.Name      : Сеть 2
IPv4Address          : 192.168.1.3
IPv6DefaultGateway   :
IPv4DefaultGateway   : 192.168.1.1
DNSServer            : 194.158.196.245
                       86.57.255.149
                       

Проверить настройки DNS:

Get-DnsClientServerAddress

InterfaceAlias               Interface Address ServerAddresses
                             Index     Family
--------------               --------- ------- ---------------
Ethernet 3                          17 IPv4    {8.8.8.8}
Ethernet 3                          17 IPv6    {}
Ethernet 4                          10 IPv4    {194.158.196.245, 86.57.255.149}
Ethernet 4                          10 IPv6    {}
Loopback Pseudo-Interface 1          1 IPv4    {}

Resolve DNS:


Resolve-DnsName onliner.by

Name                                           Type   TTL   Section    IPAddress
----                                           ----   ---   -------    ---------
onliner.by                                     A      400   Answer     178.124.129.12
onliner.by                                     A      400   Answer     178.124.129.14
nslookup www.google.com

Sever:    192.168.1.1
Address:  192.168.1.105

Не заслуживающий доверия ответ:
Name:     wikipedia.org
Addresses:  2a02:ec80:300:ed1a::1
          185.15.59.224

Для теста через определенный DNS сервер его нужно дописать после домена (например DNS Google): nslookup www.google.com 8.8.8.8

Маршруты IP из таблицы маршрутизации:

 Get-NetRoute

ifIndex DestinationPrefix                              NextHop                                  RouteMetric ifMetric PolicyStore
------- -----------------                              -------                                  ----------- -------- -----------
10      192.168.1.0/24                                 192.168.1.2                                        1 25       ActiveStore
17      0.0.0.0/0                                      192.168.1.1                                      256 25       ActiveStore
17      ff00::/8                                       ::                                               256 25       ActiveStore
1       ff00::/8                                       ::                                               256 75       ActiveStore
17      fe80::1ef7:b047:7bfd:9ddf/128                  ::                                               256 25       ActiveStore
17      fe80::/64                                      ::                                               256 25       ActiveStore
1       ::1/128                                        ::                                               256 75       ActiveStore

Кэш Neigboor:

 Get-NetNeighbor

ifIndex IPAddress                                          LinkLayerAddress      State       PolicyStore
------- ---------                                          ----------------      -----       -----------
17      ff02::1:fffd:9ddf                                  33-33-FF-FD-9D-DF     Permanent   ActiveStore
17      fe80::221:b7ff:fe15:71bc                           00-21-B7-15-71-BC     Stale       ActiveStore
1       ff02::1:2                                                                Permanent   ActiveStore
1       ff02::16                                                                 Permanent   ActiveStore
1       ff02::c                                                                  Permanent   ActiveStore
10      192.168.1.23                                       FF-FF-FF-FF-FF-FF     Permanent   ActiveStore
17      192.168.1.112                                      A8-A1-59-22-0B-E9     Stale       ActiveStore
17      192.168.1.97                                       00-00-00-00-00-00     Unreachable ActiveStore