Syntax highlighting of
46f5f80 ~( linux/network)
= Network =
<<TableOfContents()>>
== IP-адрес ==
Глобальный IP
[[https://www.cyberciti.biz/faq/how-to-find-my-public-ip-address-from-command-line-on-a-linux/|link|class=" moin-https"]]
{{{#!highlight bash
# --- MY Global IP
host myip.opendns.com resolver1.opendns.com
# --- or
dig +short myip.opendns.com @resolver1.opendns.com
# --- or
dig TXT +short o-o.myaddr.l.google.com @ns1.google.com
# --- or
dig +short txt ch whoami.cloudflare @1.0.0.1
# --- MY IPv6 address
dig -6 TXT +short o-o.myaddr.l.google.com @ns1.google.com
}}}
Локальный IP
{{{#!highlight bash
# Ethernet контроллеры
lspci | grep Ethernet
# сетевые интерфейсы, IP-адреса и многое другое
ifconfig
# быстрый просмотр всех доступных интерфейсов
ip a
# более подробная информация об интерфейсах
sudo lshw -class network
}}}
== Порты ==
Удаленные порты
{{{#!highlight bash
# --- nc
# проверка открытия порта 22
nc -zvw3 example.com 22
# nc: connect to example.com port 22 (tcp) failed: Connection refused
nc -zvw3 example.com 2281
# Connection to example.com 2281 port [tcp/*] succeeded!
# --- nmap
nmap example.com -p 443
# Starting Nmap 7.70 ( https://nmap.org ) at 2019-07-27 08:04 MSK
# Nmap scan report for example.com (x.x.x.x)
# Host is up (0.0041s latency).
# PORT STATE SERVICE
# 443/tcp closed https
# Nmap done: 1 IP address (1 host up) scanned in 13.04 seconds
# описание STATE см. по ссылке https://nmap.org/man/ru/man-port-scanning-basics.html
}}}
Локальные порты
{{{#!highlight bash
netstat -ant
Активные соединения с интернетом (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.1.1:53 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN
sudo netstat -tapen
Активные соединения с интернетом (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name
tcp 0 0 127.0.1.1:53 0.0.0.0:* LISTEN 0 20930 1513/dnsmasq
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 121 19019 1492/postgres
}}}
== Сетевые утилиты ==
=== curl ===
{{{#!highlight bash
#
# Basic Auth
#
curl --user name:password http://www.example.com
curl --proxy-user proxyuser:proxypassword curl.haxx.se
# GET request с user-agent и follow-redirect
curl -A "Mozilla/5" -L https://s3.example.com
#
# Post Request
#
curl --user user:secret \
-H "Content-type: application/json" \
-X POST \
-d '{"company": {"name": "xxx", "number": "00000", "country": "Russian Federation", "url": "http://yandex.ru"}}' \
http://localhost:3000/companies
#
# Pretty Output
#
curl -H "Content-type: application/json" http://localhost:3000/companies
# {"status":"ok","result":[{"id":1,"name":"! LTD","number":"08209948","country":"United Kingdom","url":"http://business.data.gov.uk/id/company/08209948"},{"id":2,"name":"!? LTD","number":"11399177","country":"United Kingdom","url":"http://business.data.gov.uk/id/company/11399177"}, ...
sudo snap install jq
curl -H "Content-type: application/json" http://localhost:3000/companies | jq
# {
# "status": "ok",
# "result": [
# {
# "id": 1,
# "name": "! LTD",
# "number": "08209948",
# "country": "United Kingdom",
# "url": "http://business.data.gov.uk/id/company/08209948"
# },
# {
# ...
}}}
=== ping ===
Команда ''ping'' - в образах ''docker'' обычно отсутствует
{{{#!highlight bash
apt-get update
apt install iputils-ping
}}}
== Конфигурация сети ==
=== Ethernet ===
[[https://help.ubuntu.com/lts/serverguide/network-configuration.html.ru|Настройки сети|class=" moin-https"]]
[[https://www.cyberciti.biz/faq/linux-setup-default-gateway-with-route-command/|Linux setup default gateway with route command|class=" moin-https"]]
{{{#!highlight bash
# настройка интерфейса
sudo ethtool eth0
# Управление NetworkManager через консоль
nmcli
# статус wifi
nmcli r wifi [on/off]
}}}
Конфигурация интерфейсов
{{{#!highlight bash
# /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto eth0
# iface eth0 inet dhcp
iface eth0 inet static
address 192.168.137.1
netmask 255.255.255.0
network 192.168.137.0
gateway 192.168.137.1
dns-nameservers 8.8.8.8
}}}
=== WiFi ===
[[https://losst.ru/nasrojka-wifi-v-ubuntu|НАСТРОЙКА WIFI В UBUNTU|class=" moin-https"]]
https://losst.ru/nasrojka-wifi-v-ubuntu
[[https://askubuntu.com/questions/55868/installing-broadcom-wireless-drivers|Installing Broadcom Wireless Drivers|class=" moin-https"]]
https://bugs.launchpad.net/ubuntu/+source/bcmwl/+bug/1757008
https://github.com/cilynx/rtl88x2bu
{{{#!highlight bash
# конфигурация беспроводных интерфейсов
iwconfig
# отображение информации о WiFi контроллере
lspci -vnn | grep Network
}}}