RTFM.WIKI

Ordnung muß sein. Ordnung über alles (18+)

Инструменты пользователя

Инструменты сайта


Stylesheet conf/userstyle.css not found, please contact the developer of "dokuwiki_2024" template.
linux:terminal:terminal_tnt_network

Различия

Показаны различия между двумя версиями страницы.

Ссылка на это сравнение

linux:terminal:terminal_tnt_network [2020/12/25 03:51] – внешнее изменение 127.0.0.1linux:terminal:terminal_tnt_network [2021/11/27 03:38] (текущий) dx
Строка 1: Строка 1:
 +====== Трюки в консоли: Сеть ======
  
 +===== Посмотреть информацию о сертификате через консоль =====
 +
 +Проверенные oneliner'ы 
 +
 +<code bash>
 +curl -vvI https://gnupg.org
 +curl --insecure -vvI https://gnupg.org 2>&1 | awk 'BEGIN { cert=0 } /^\* SSL connection/ { cert=1 } /^\*/ { if (cert) print }'
 +nmap -p 443 --script ssl-cert gnupg.org
 +nmap -sV -sC gnupg.org -p 443
 +echo | gnutls-cli gnupg.org
 +</code>
 +
 +===== Отключить ipv6 кроме lo =====
 +
 +Отключить ipv6 на всех интерфейсах кроме lo
 +
 +<code bash>
 +# sysctl -w net.ipv6.conf.default.disable_ipv6=1
 +# sysctl -w net.ipv6.conf.all.disable_ipv6=1
 +# sysctl -w net.ipv6.conf.lo.disable_ipv6=0
 +</code>
 +
 +===== Время ответа сервера через curl =====
 +
 +via http://www.dtulyakov.ru/curl.html
 +
 +<code bash>
 +curl -s -w '\nLookup time:\t%{time_namelookup}\nConnect time:\t%{time_connect}\nAppCon time:\t%{time_appconnect}\nRedirect time:\t%{time_redirect}\nPreXfer time:\t%{time_pretransfer}\nStartXfer time:\t%{time_starttransfer}\n\nTotal time:\t%{time_total}\n' -o /dev/null http://ya.ru
 +</code>
 +
 +===== Коды ошибок wget =====
 +
 +<code>
 +0    No problems occurred
 +1    Generic error code
 +2    Parse error — for instance, when parsing command-line options, the .wgetrc or .netrc…
 +3    File I/O error
 +4    Network failure
 +5    SSL verification failure
 +6    Username/password authentication failure
 +7    Protocol errors
 +8    Server issued an error response
 +</code>
 +
 +Если wget выдаёт **Exited with return code = 5**, то используем ключ **--no-check-certificate**
 +
 +===== Как запустить wget/curl/ping с сабинтерфейса? =====
 +
 +**ping** можно запустить с другого IP, но не с алиаса (eth0:1)
 +
 +<code bash>$ ping -I 192.168.13.254 <dest_host></code>
 +
 +**curl** --interface <name>
 +
 +<code>
 +--interface <name>
 +
 +Perform an operation using a specified interface. You can enter interface name, IP address or host name. An example could look like:
 +
 + curl --interface eth0:1 https://www.example.com/
 +
 +If this option is used several times, the last one will be used. 
 +</code>
 +
 +<code bash>
 +$ curl --interface eth0:1 <dest_host>
 +$ curl --interface 192.168.13.254 <dest_host>
 +$ curl --interface foobar <dest_host>
 +</code>
 +
 +**wget**
 +
 +<code bash>
 +--bind-address=ADDRESS
 +
 +    When making client TCP/IP connections, bind to ADDRESS on the local machine. ADDRESS may be specified as a hostname or IP address. This option can be useful if your machine is bound to multiple IPs. 
 +</code>
 +
 +Пример
 +
 +<code bash>
 +$ wget -qO- http://checkip.dyndns.com/ --bind-address <public_ip>
 +<html><head><title>Current IP Check</title></head><body>Current IP Address: <public_ip></body></html>
 +</code>
 +
 +===== Как узнать адрес хоста из консоли? =====
 +
 +<code bash>
 +lynx --dump http://ipecho.net/plain
 +dig +short myip.opendns.com @resolver1.opendns.com
 +curl -s http://whatismijnip.nl |cut -d " " -f 5
 +curl -s icanhazip.com
 +curl -s http://ifconfig.me
 +curl curlmyip.com
 +</code>
 +
 +http://unix.stackexchange.com/a/194136
 +
 +===== Список активных исходящих соединений на порты 25,80,443. =====
 +
 +<code bash># lsof -nP -i :25,80,443 +c 15</code>
 +
 +===== Как увеличить ip_local_port_range =====
 +
 +Как увеличить диапазон локальных портов (ip_local_port_range) доступных для установки исходящих подключений
 +
 +Смотрим текущий диапазон
 +
 +<code>
 +# cat /proc/sys/net/ipv4/ip_local_port_range
 +32768   61000
 +</code>
 +
 +Либо так
 +
 +<code>
 +# sysctl net.ipv4.ip_local_port_range
 +net.ipv4.ip_local_port_range = 32768    61000
 +</code>
 +
 +Увеличиваем значение
 +
 +<code>
 +# sysctl -w net.ipv4.ip_local_port_range="16000 64000"
 +net.ipv4.ip_local_port_range = 16000 64000
 +</code>
 +
 +Или так
 +
 +<code># echo 16000 64000 > /proc/sys/net/ipv4/ip_local_port_range</code>
 +
 +Чтобы изменения сохранились после перезгрузки системы добавьте новое значение в файл ''/etc/sysctl.conf'' или в отдельный файл, который будет подгружаться
 +
 +<code>
 +# cat /etc/sysctl.d/net.ipv4.ip_local_port_range.conf
 +net.ipv4.ip_local_port_range = 16000 64000
 +</code>
 +
 +И последнее. Смотрим сколько активных соединений у нас сейчас
 +
 +<code>
 +# ss -s
 +Total: 198 (kernel 750)
 +TCP:   23 (estab 4, closed 5, orphaned 0, synrecv 0, timewait 4/0), ports 0
 +
 +Transport Total     IP        IPv6
 +*         750                      
 +RAW                              
 +UDP       11        6                
 +TCP       18        13        5        
 +INET      29        19        10       
 +FRAG      0                   
 +</code>
 +
 +===== REMOTE HOST IDENTIFICATION HAS CHANGED =====
 +
 +<code bash>
 +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 +@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
 +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 +IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
 +Someone could be eavesdropping on you right now (man-in-the-middle attack)!
 +It is also possible that a host key has just been changed.
 +The fingerprint for the RSA key sent by the remote host is
 +fc:f9:10:fe:5e:8e:02:3b:5b:4a:65:55:b3:6a:d8:f2.
 +Please contact your system administrator.
 +Add correct host key in /Users/macbook/.ssh/known_hosts to get rid of this message.
 +Offending RSA key in /Users/macbook/.ssh/known_hosts:1
 +RSA host key for ukserverhd.zapto.org has changed and you have requested strict checking.
 +Host key verification failed.
 +
 +[Process completed]
 +</code>
 +
 +<code bash>$ ssh-keygen -R foo.bar.com</code>
 +
 +{{tag>linux terminal tnt network curl wget}}