====== Трюки в консоли: Сеть ====== ===== Посмотреть информацию о сертификате через консоль ===== Проверенные oneliner'ы 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 ===== Отключить ipv6 кроме lo ===== Отключить ipv6 на всех интерфейсах кроме lo # 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 ===== Время ответа сервера через curl ===== via http://www.dtulyakov.ru/curl.html 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 ===== Коды ошибок wget ===== 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 Если wget выдаёт **Exited with return code = 5**, то используем ключ **--no-check-certificate** ===== Как запустить wget/curl/ping с сабинтерфейса? ===== **ping** можно запустить с другого IP, но не с алиаса (eth0:1) $ ping -I 192.168.13.254 **curl** --interface --interface 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. $ curl --interface eth0:1 $ curl --interface 192.168.13.254 $ curl --interface foobar **wget** --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. Пример $ wget -qO- http://checkip.dyndns.com/ --bind-address Current IP CheckCurrent IP Address: ===== Как узнать адрес хоста из консоли? ===== 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 http://unix.stackexchange.com/a/194136 ===== Список активных исходящих соединений на порты 25,80,443. ===== # lsof -nP -i :25,80,443 +c 15 ===== Как увеличить ip_local_port_range ===== Как увеличить диапазон локальных портов (ip_local_port_range) доступных для установки исходящих подключений Смотрим текущий диапазон # cat /proc/sys/net/ipv4/ip_local_port_range 32768 61000 Либо так # sysctl net.ipv4.ip_local_port_range net.ipv4.ip_local_port_range = 32768 61000 Увеличиваем значение # sysctl -w net.ipv4.ip_local_port_range="16000 64000" net.ipv4.ip_local_port_range = 16000 64000 Или так # echo 16000 64000 > /proc/sys/net/ipv4/ip_local_port_range Чтобы изменения сохранились после перезгрузки системы добавьте новое значение в файл ''/etc/sysctl.conf'' или в отдельный файл, который будет подгружаться # cat /etc/sysctl.d/net.ipv4.ip_local_port_range.conf net.ipv4.ip_local_port_range = 16000 64000 И последнее. Смотрим сколько активных соединений у нас сейчас # 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 0 0 0 UDP 11 6 5 TCP 18 13 5 INET 29 19 10 FRAG 0 0 0 ===== REMOTE HOST IDENTIFICATION HAS CHANGED ===== @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ 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] $ ssh-keygen -R foo.bar.com {{tag>linux terminal tnt network curl wget}}