Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [[Category:Network configuration]]
- [[cs:Network configuration]]
- [[el:Network configuration]]
- [[es:Network configuration]]
- [[fr:Connexions reseau]]
- [[it:Network configuration]]
- [[ja:ネットワーク設定]]
- [[nl:Network configuration]]
- [[pt:Network configuration]]
- [[ru:Network configuration]]
- [[sk:Network configuration]]
- [[zh-hans:Network configuration]]
- [[zh-hant:Network configuration]]
- {{Related articles start}}
- {{Related|Network Debugging}}
- {{Related|Firewalls}}
- {{Related|Jumbo frames}}
- {{Related|Internet sharing}}
- {{Related|Router}}
- {{Related articles end}}
- W tym artykule opisano, jak skonfigurować połączenia sieciowe w warstwie sieciowej i wyższych. Na przykładzie [[/Ethernet]] i [[#Wireless | Wi-fi]].
- == Sprawdzanie połączania ==
- Aby rozwiązać problemy z połączeniem z połączaniem, sprawdź następujące warunki i upewnij się, że je spełniasz:
- # Twój [[#Network interfaces|interfejs sieciowy]] jest widoczny i włączony. W przeciwnym razie sprawdź sterownik urządzenia - patrz [[/Ethernet#Device driver]] i [[/Wireless#Device driver]].
- # Masz połączanie z siecią. Przewód jest podłączony lub jesteś [[/Wireless|podłączony do sieci bezprzewodowej]].
- # Twój interfejs sieciowy ma [[#IP addresses|adres IP]].
- # Twoja [[#Routing table|tabela trasowania]] jest poprawnie skonfigurowana.
- # Możesz [[#Ping|wysłać ping]] na lokalny adres IP (np. bramę domyślną).
- # Możesz [[#Ping|wysłać ping]] na publiczny adres (np. {{ic|8.8.8.8}}, który jest serwerem Google DNS i jest wygodnym adresem do testowania).
- # [[Check if you can resolve domain names]] (np. {{ic|archlinux.org}}).
- === Ping ===
- {{Expansion|Dodaj lub połącz wyjaśnienia typowych błędów ping, takich jak Nieznany host / sieć, jest nieosiągalny.}}
- [[Wikipedia:pl:Ping|ping]] służy do sprawdzenia, czy możesz dotrzeć do hosta i mierzenia opóźnienia z połączania z danym hostem.
- {{hc|$ ping www.example.com|2=
- PING www.example.com (93.184.216.34): 56(84) data bytes
- 64 bytes from 93.184.216.34: icmp_seq=0 ttl=56 time=11.632 ms
- 64 bytes from 93.184.216.34: icmp_seq=1 ttl=56 time=11.726 ms
- 64 bytes from 93.184.216.34: icmp_seq=2 ttl=56 time=10.683 ms
- ...
- }}
- Przy każdej otrzymanej odpowiedzi narzędzie ping wydrukuje wiersz podobny do powyższego. Aby uzyskać więcej informacji zobacz {{man|8|ping}} manual. Pamiętaj, że komputery można skonfigurować tak, aby nie odpowiadały na żądania echa ICMP. [https://unix.stackexchange.com/questions/412446/how-to-disable-ping-response-icmp-echo-in-linux-all-the-time]
- Jeśli nie otrzymasz odpowiedzi, może to być związane z domyślną bramą lub dostawcą usług internetowych (ISP). Możesz uruchomić [[traceroute]] w celu dalszej diagnozy trasy do hosta.
- {{Note|If you receive an error like {{ic|ping: icmp open socket: Operation not permitted}} when executing ''ping'', try to re-install the {{Pkg|iputils}} package.}}
- == Zarządzanie siecią ==
- Aby skonfigurować połączenie sieciowe, wykonaj następujące kroki:
- # Upewnij się, że [[#Network interfaces|interfejs sieciowy]] jest widoczny i włączony.
- # Połącz się z siecią. Podłącz przewód Ethernet lub [[/Wireless|połącz się z siecią bezprzewodową]].
- # Configure your network connection:
- #* [[#Static IP address|Statyczny adres IP]]
- #* Dynamiczny adres IP: Użyj [[#DHCP|DHCP]]
- {{Note|Obraz instalacyjny ma włączony [[dhcpcd]] ({{ic|dhcpcd@''interface''.service}}) dla [https://git.archlinux.org/archiso.git/tree/configs/releng/airootfs/etc/udev/rules.d/81-dhcpcd.rules przewodowych urządzeń sieciowych] przy rozruchu.}}
- === net-tools ===
- Arch Linux wycofał {{Pkg|net-tools}} na rzecz {{Pkg|iproute2}}.[https://www.archlinux.org/news/deprecation-of-net-tools/]
- {| class="wikitable"
- ! Przestarzałe polecenie !! Polecenie alternatywne
- |-
- | arp || ip neighbor
- |-
- | [[Wikipedia:pl:ifconfig|ifconfig]] || ip address, ip link
- |-
- | netstat || [[#Investigate sockets|ss]]
- |-
- | route || ip route
- |}
- Aby uzyskać więcej informacji zobacz [https://dougvitale.wordpress.com/2011/12/21/deprecated-linux-networking-commands-and-their-replacements/ ten artykuł (po angielsku)].
- === iproute2 ===
- [[Wikipedia:iproute2|iproute2]] należy do {{Pkg|base}} [[meta package]] i zapewnia interfejs wiersza polecenia {{man|8|ip}} używany do zarządzania [[#Network interfaces|interfejsami sieciowymi]], [[#IP addresses|adresami IP]] [[#Routing table|tablicami trasowania]]. Należy pamiętać, że konfiguracja wykonana przy użyciu {{ic|ip}} zostanie utracona po restarcie. W celu trwałej konfiguracji można użyć [[network manager]] lub zautomatyzować polecenia ''ip'' za pomocą skryptów i [[systemd#Writing unit files|systemd units]]. Zauważ też, że {{ic|ip}} polecenia ogólnie mogą być skrócone, dla jasności zostały one jednak określone w tym artykule.
- === Interfejsy sieciowe ===
- Domyślnie [[udev]] przypisuje nazwy do interfejsów sieciowych za pomocą [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames Przewidywalnych nazw interfejsów sieciowych], z których przedrostkami łączyą się nazwy {{ic|en}} (wired/[[Wikipedia:Ethernet|Ethernet]]), {{ic|wl}} (wireless/WLAN), i {{ic|ww}} ([[Wikipedia:Wireless WAN|WWAN]]).
- {{Tip|Aby zmienić nazwy interfejsu, patrz [[#Change interface name]] i [[#Revert to traditional interface names]].}}
- ==== Lista interfejsów sieciowych ====
- Nazwy interfejsów przewodowych i bezprzewodowych można znaleźć za pośrednictwem {{ic|ls /sys/class/net}} lub {{ic|ip link}}. Zauważ, że {{ic|lo}} jest [[Wikipedia:loop device|urządzenie pętli]] i nie jest używane do nawiązywania połączeń sieciowych.
- Nazwy urządzeń bezprzewodowych można również pobrać za pomocą {{ic|iw dev}}. Zobacz też [[/Wireless#Get the name of the interface]].
- Jeśli Twojego interfejsu sieciowego nie ma na liście, upewnij się, że sterownik urządzenia został pomyślnie załadowany. Zobacz [[/Ethernet#Device driver]] lub [[/Wireless#Device driver]].
- ==== Włączanie i wyłączanie interfejsów sieciowych ====
- Interfejsy sieciowe można włączać / wyłączać za pomocą {{ic|ip link set ''interface'' up{{!}}down}}, zobacz {{man|8|ip-link}}.
- Aby sprawdzić status interfejsu {{ic|eth0}}:
- {{hc|$ ip link show dev eth0|
- 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state DOWN mode DEFAULT qlen 1000
- ...
- }}
- The {{ic|UP}} in {{ic|<BROADCAST,MULTICAST,UP,LOWER_UP>}} is what indicates the interface is up, not the later {{ic|state DOWN}}.
- {{Note|Jeśli twoją domyślną trasą jest interfejs {{ic|eth0}}, usunięcie go spowoduje również usunięcie trasy, a przywrócenie go z powrotem nie spowoduje automatycznego przywrócenia domyślnej trasy. Zobacz [[#Routing table]] aby ją przywrócić.}}
- === Statyczny adres IP ===
- Statyczny adres IP można skonfigurować za pomocą większości standardowych [[#Network managers|menedżerów sieci]] zobacz też [[dhcpcd]].
- Aby ręcznie skonfigurować statyczny adres IP, dodaj adres IP zgodnie z opisem w [[#Adres IP]], skonfiguruj [[#Routing table|tablice trasowania]] i [[Domain name resolution|skonfiguruj serwery DNS]].
- === Adres IP ===
- [[Wikipedia:pl:Adres IP|Adresami IP]] zarządza się za pomocą {{man|8|ip-address}}.
- Wypisz adresy IP:
- $ ip address show
- Dodaj adres IP do interfejsu:
- # ip address add ''address/prefix_len'' broadcast + dev ''interface''
- :Uwaga:
- :* adres jest podany w [[Wikipedia:pl:Classless Inter-Domain Routing notation|notacji CIDR]] aby również podać [[Wikipedia:Subnetwork|maskę podsieci]]
- :* {{ic|+}} to specjalny symbol, który powoduje, że [[Wikipedia:pl:Broadcast|adres rozgłoszeniowy]] jest wyliczany z adresu IP i maski podsieci
- :{{Note|Upewnij się, że ręcznie przypisane adresy IP nie powodują konfliktu z adresami przydzielonymi przez DHCP.}}
- Usuń adres IP z interfejsu:
- $ ip address del ''address/prefix_len'' dev ''interface''
- Usuń wszystkie adresy spełniające kryteria, np. Określonego interfejsu:
- $ ip address flush dev ''interface''
- {{Tip|Adresy IP można obliczyć za pomocą [http://jodies.de/ipcalc ipcalc] ({{Pkg|ipcalc}}).}}
- === Tablica trasowania ===
- :{{Note|Używam polskiej nazwy trasownik zamiast angielskiej router.}}
- [[Wikipedia:pl:Tablica trasowania|Tabela trasowania]] jest używana do określenia, czy można dotrzeć do adresu IP, bezpośrednio lub przez bramę (trasownik), jeśli dany adres nie należy do naszej sieci i nie jest ustawiana brama dla sieci do której należy dany adres, używana jest [[Wikipedia:Default gateway|brama domyślna]].
- The routing table is managed using {{man|8|ip-route}}.
- ''PREFIX'' is either a CIDR notation or {{ic|default}} for the default gateway.
- Wyświetl trasy IPv4:
- $ ip route show
- Wyświetl trasy IPv6:
- $ ip -6 route
- Dodaj trasę:
- # ip route add ''PREFIX'' via ''address'' dev ''interface''
- Usuń trasę:
- # ip route del ''PREFIX'' via ''address'' dev ''interface''
- PREFIX - adres sieci docelowej z maską podsieci w postaci CIDR na przykład 192.168.4.0/24
- address - adres bramy przez którą mają być przesyłane pakiety
- interface - nasz interfejs sieciowy (karta sieciowa) dla którego ustawiamy trasę
- === DHCP ===
- Serwer [[Wikipedia:pl:Dynamic Host Configuration Protocol|DHCP]] przydziela przydziela adres IP, maskę podsieci, adres bramy domyślnej i ewentualnie adresy serwerów DNS i paru innych usług.
- Aby korzystać z DHCP, potrzebujesz serwera w sieci i klienta na komputerze:
- {| class="wikitable"
- ! Klient !! pakiet !! [[Archiso]] !! Uwagi !! Systemd units
- |-
- | [[dhcpcd]] || {{Pkg|dhcpcd}} || {{Yes}} || DHCP, DHCPv6, ZeroConf, static IP || {{ic|dhcpcd.service}}, {{ic|dhcpcd@''interface''.service}}
- |-
- | [https://www.isc.org/downloads/dhcp/ ISC dhclient] || {{Pkg|dhclient}} || {{Yes}} || DHCP, DHCPv6, BOOTP, static IP || {{ic|dhclient@''interface''.service}}
- |}
- {{Note|
- * Nie należy uruchamiać dwóch klientów DHCP jednocześnie.
- * Zamiast bezpośredniego korzystania z klienta DHCP można również użyć [[#Network managers|network manager]].
- }}
- {{Tip|Możesz sprawdzić, czy serwer DHCP działa z {{Pkg|dhcping}}.}}
- ==== Servers ====
- {{Expansion|[[systemd-networkd]] has DHCP server support.}}
- {| class="wikitable"
- ! Server !! Package !! IPv4 !! IPv6 !! GUI !! Interfaces !! Storage backend(s) !! Note
- |-
- | [[dhcpd]] || {{Pkg|dhcp}} || {{Yes}} || {{Yes}} || [https://github.com/Akkadius/glass-isc-dhcp Glass-ISC-DHCP] || ? || File ||
- |-
- | [[dnsmasq]] || {{Pkg|dnsmasq}} || {{Yes}} || {{Yes}} || {{No}} || ? || File || Also DNS, PXE and TFTP
- |-
- | [[Kea]] || {{Pkg|kea}} || {{Yes}} || {{Yes}} || [https://github.com/isc-projects/kea-anterius Kea-Anterius (Experimental)] || REST, RADIUS and NETCONF || File, MySQL, PostgreSQL and Cassandra || Also DNS
- |}
- === Menadżerzy sieci ===
- Menedżer sieci pozwala zarządzać ustawieniami połączeń sieciowych przy użyciu tak zwany profili sieciowych, aby ułatwić między sieciami.
- {{Note|Istnieje wiele rozwiązań do wyboru, ale pamiętaj, że wszystkie wzajemnie się wykluczają; nie powinieneś uruchamiać dwóch demonów jednocześnie.}}
- {| class="wikitable"
- ! Network manager || GUI || [[Archiso]] [https://git.archlinux.org/archiso.git/tree/configs/releng/packages.x86_64] || CLI tools || [[Wikipedia:Point-to-Point Protocol|PPP]] support <br>(e.g. 3G modem) || [[#DHCP|DHCP client]] || Systemd units
- |-
- ! [[ConnMan]]
- | {{Y|8 unofficial}} || {{No}} || {{man|1|connmanctl}} || {{Yes}} (with {{aur|ofono}}) || internal || {{ic|connman.service}}
- |-
- ! [[netctl]]
- | {{Y|2 unofficial}} || {{Yes}} || {{man|1|netctl}}, wifi-menu || {{Yes}} || [[dhcpcd]] or {{Pkg|dhclient}} || {{ic|netctl-ifplugd@''interface''.service}}, {{ic|netctl-auto@''interface''.service}}
- |-
- ! [[NetworkManager]]
- | {{Yes}} || {{No}} || {{man|1|nmcli}}, {{man|1|nmtui}} || {{Yes}} || internal, [[dhcpcd]] or {{Pkg|dhclient}} || {{ic|NetworkManager.service}}
- |-
- ! [[systemd-networkd]]
- | {{No}} || {{Yes}} ({{Pkg|base}}) || {{man|1|networkctl}} || {{No|https://github.com/systemd/systemd/issues/481}} || internal || {{ic|systemd-networkd.service}}, {{ic|systemd-resolved.service}}
- |-
- ! [[Wicd]]
- | {{Yes}} || {{No}} || {{man|8|wicd-cli}}{{Dead link|2020|02|22}}, {{man|8|wicd-curses}}{{Dead link|2020|02|22}} || {{No}} || [[dhcpcd]] || {{ic|wicd.service}}
- |}
- Istnieje również [[Wifi Radar]], aplikacja GUI do zarządzania sieciami Wi-Fi za pomocą narzędzi {{Pkg|wireless_tools}}, aplikacja GUI do zarządzania sieciami Wi-Fi za pomocą narzędzi.
- Zobacz też [[List of applications#Network managers]].
- == Ustaw nazwę hosta ==
- [[Wikipedia:Hostname|Nazwa hosta]] to unikatowa nazwa utworzona w celu identyfikacji komputera w sieci ustawiony w {{ic|/etc/hostname}}—patrz {{man|5|hostname}} i {{man|7|hostname}} po więcej informacji. Plik może zawierać nazwę domeny. Aby ustawić nazwę hosta, [[textedit|edytuj]] {{ic|/etc/hostname}}:
- {{hc|/etc/hostname|
- ''nazwaMojegoHosta''
- }}
- {{Tip|Aby uzyskać porady dotyczące wybierania nazwy hosta, zobacz [https://tools.ietf.org/html/rfc1178 RFC 1178].}}
- Możesz też użyć {{man|1|hostnamectl}}:
- # hostnamectl set-hostname ''nazwaMojegoHosta''
- Aby tymczasowo ustawić nazwę hosta (do ponownego uruchomienia), użyj {{man|1|hostname}} z {{Pkg|inetutils}}:
- # hostname ''nazwaMojegoHosta''
- Aby ustawić „ładną” nazwę hosta i inne metadane komputera, zobacz {{man|5|machine-info}}.
- === Local hostname resolution ===
- {{Expansion|Explain why you want a resolvable hostname, why {{ic|127.0.1.1}} is used (and why a static IP address should be preferred over it).}}
- The {{ic|myhostname}} [[Name Service Switch]] (NSS) module of [[systemd]] provides local hostname resolution without having to edit {{ic|/etc/hosts}} ({{man|5|hosts}}). It is enabled by default.
- Some clients may however still rely on {{ic|/etc/hosts}}, see [https://lists.debian.org/debian-devel/2013/07/msg00809.html] [https://bugzilla.mozilla.org/show_bug.cgi?id=87717#c55] for examples.
- To configure the hosts file, add the following lines to {{ic|/etc/hosts}}:
- 127.0.0.1 localhost
- ::1 localhost
- 127.0.1.1 ''myhostname''.localdomain ''myhostname''
- {{Note|The order of hostnames/aliases that follow the IP address in {{ic|/etc/hosts}} is significant. The first string is considered the canonical hostname and may be appended with parent domains, where domain components are separated by a dot (ie. {{ic|.localdomain}} above). All following strings on the same line are considered aliases. See {{man|5|hosts}} for more info.}}
- As a result the system resolves to both entries:
- {{hc|$ getent hosts|
- 127.0.0.1 localhost
- 127.0.0.1 localhost
- 127.0.1.1 ''myhostname''.localdomain ''myhostname''
- }}
- For a system with a permanent IP address, that permanent IP address should be used instead of {{ic|127.0.1.1}}.
- === Local network hostname resolution ===
- To make your machine accessible in your LAN via its hostname you can:
- * edytuj plik {{ic|/etc/hosts}} dla każdego hosta, patrz {{man|5|hosts}}
- * ustaw nazwy hostów na [[DNS server]] i zmuś urządzenia w twojej sieci LAN jego użycia (np. przez [[#DHCP]])
- * lub prostszy sposób: użyj usługi[[Wikipedia:pl:Zeroconf|Zeroconf]]:
- ** Rozpoznawanie nazw hostów [[Wikipedia:NetBIOS#Name service|NetBIOS]] Microsoftu. Dostarczone przez [[Samba]] w systemie Linux. Wymaga tylko [[Systemd#Using_units|uruchomienia]] {{ic|nmb.service}}. Komputery z uruchomionym systemem Windows, macOS lub Linux z {{ic|nmb}} będą mogły znaleźć Twój komputer.
- ** Rozpoznawanie nazw hostów za pomocą [[Wikipedia:Multicast DNS|mDNS]]. Dostarczoną przez {{ic|nss_mdns}} z [[Avahi]] (patrz [[Avahi#Hostname resolution]] po więcej informacji) lub [[systemd-resolved]]. Komputery z macOS lub Linux z uruchomionym Avahi lub systemd-resolved, będą widzieć twoją nazwę hosta. Starsze trzydziestodwubitowe systemy z rodziny Windows nie obsługują mDNS.
- == Tips and tricks ==
- === Change interface name ===
- {{Note|When changing the naming scheme, do not forget to update all network-related configuration files and custom systemd unit files to reflect the change.}}
- You can change the device name by defining the name manually with an udev-rule. For example:
- {{hc|/etc/udev/rules.d/10-network.rules|2=
- SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"
- SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"
- }}
- These rules will be applied automatically at boot.
- A couple of things to note:
- * To get the MAC address of each card, use this command: {{ic|cat /sys/class/net/''device_name''/address}}
- * Make sure to use the lower-case hex values in your udev rules. It does not like upper-case.
- If the network card has a dynamic MAC, you can use {{ic|DEVPATH}}, for example:
- {{hc|/etc/udev/rules.d/10-network.rules|2=
- SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"
- SUBSYSTEM=="net", DEVPATH=="/devices/pci*/*1c.0/*/net/*", NAME="en"
- }}
- To get the {{ic|DEVPATH}} of all currently-connected devices, see where the symlinks in {{ic|/sys/class/net/}} lead. For example:
- {{hc|file /sys/class/net/*|
- /sys/class/net/enp0s20f0u4u1: symbolic link to ../../devices/pci0000:00/0000:00:14.0/usb2/2-4/2-4.1/2-4.1:1.0/net/enp0s20f0u4u1
- /sys/class/net/enp0s31f6: symbolic link to ../../devices/pci0000:00/0000:00:1f.6/net/enp0s31f6
- /sys/class/net/lo: symbolic link to ../../devices/virtual/net/lo
- /sys/class/net/wlp4s0: symbolic link to ../../devices/pci0000:00/0000:00:1c.6/0000:04:00.0/net/wlp4s0
- }}
- The device path should match both the new and old device name, since the rule may be executed more than once on bootup. For example, in the second rule, {{ic|"/devices/pci*/*1c.0/*/net/enp*"}} would be wrong since it will stop matching once the name is changed to {{ic|en}}. Only the system-default rule will fire the second time around, causing the name to be changed back to e.g. {{ic|enp1s0}}.
- If you are using a USB network device (e.g. Android phone tethering) that has a dynamic MAC address and you want to be able to use different USB ports, you could use a rule that matched depending on vendor and product ID instead:
- {{hc|/etc/udev/rules.d/10-network.rules|2=
- SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="12ab", ATTRS{idProduct}=="3cd4", NAME="net2"
- }}
- To [[udev#Testing rules before loading|test]] your rules, they can be triggered directly from userspace, e.g. with {{ic|udevadm --debug test /sys/class/net/*}}. Remember to first take down the interface you are trying to rename (e.g. {{ic|ip link set enp1s0 down}}).
- {{Note|When choosing the static names '''it should be avoided to use names in the format of "eth''X''" and "wlan''X''"''', because this may lead to race conditions between the kernel and udev during boot. Instead, it is better to use interface names that are not used by the kernel as default, e.g.: {{ic|net0}}, {{ic|net1}}, {{ic|wifi0}}, {{ic|wifi1}}. For further details please see the [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] documentation.}}
- === Revert to traditional interface names ===
- If you would prefer to retain traditional interface names such as eth0, [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames Predictable Network Interface Names] can be disabled by masking the udev rule:
- # ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules
- Alternatively, add {{ic|1=net.ifnames=0}} to the [[kernel parameters]].
- === Set device MTU and queue length ===
- You can change the device [[wikipedia:Maximum transmission unit|MTU]] and queue length by defining manually with an udev-rule. For example:
- {{hc|/etc/udev/rules.d/10-network.rules|2=
- ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1500", ATTR{tx_queue_len}="2000"
- }}
- {{Note|
- * {{ic|mtu}}: For PPPoE, the MTU should be no larger than 1492. You can also set MTU via {{man|5|systemd.netdev}}.
- * {{ic|tx_queue_len}}: Small value for slower devices with a high latency like modem links and ISDN. High value is recommend for server connected over the high-speed Internet connections that perform large data transfers.
- }}
- === Bonding or LAG ===
- See [[netctl#Bonding]] or [[Wireless bonding]].
- === IP address aliasing ===
- IP aliasing is the process of adding more than one IP address to a network interface. With this, one node on a network can have multiple connections to a network, each serving a different purpose. Typical uses are virtual hosting of Web and FTP servers, or reorganizing servers without having to update any other machines (this is especially useful for nameservers).
- ==== Example ====
- To manually set an alias, for some NIC, use {{Pkg|iproute2}} to execute
- # ip addr add 192.168.2.101/24 dev eth0 label eth0:1
- To remove a given alias execute
- # ip addr del 192.168.2.101/24 dev eth0:1
- Packets destined for a subnet will use the primary alias by default. If the destination IP is within a subnet of a secondary alias, then the source IP is set respectively. Consider the case where there is more than one NIC, the default routes can be listed with {{ic|ip route}}.
- === Promiscuous mode ===
- Toggling [[wikipedia:Promiscuous mode|promiscuous mode]] will make a (wireless) NIC forward all traffic it receives to the OS for further processing. This is opposite to "normal mode" where a NIC will drop frames it is not intended to receive. It is most often used for advanced network troubleshooting and [[wikipedia:Packet sniffing|packet sniffing]].
- {{hc|/etc/systemd/system/[email protected]|<nowiki>
- [Unit]
- Description=Set %i interface in promiscuous mode
- After=network.target
- [Service]
- Type=oneshot
- ExecStart=/usr/bin/ip link set dev %i promisc on
- RemainAfterExit=yes
- [Install]
- WantedBy=multi-user.target
- </nowiki>}}
- If you want to enable promiscuous mode on interface {{ic|eth0}} run [[enable]] {{ic|[email protected]}}.
- === Investigate sockets ===
- ''ss'' is a utility to investigate network ports and is part of the {{Pkg|iproute2}} package. It has a similar functionality to the [https://www.archlinux.org/news/deprecation-of-net-tools/ deprecated] netstat utility.
- Common usage includes:
- Display all TCP Sockets with service names:
- $ ss -at
- Display all TCP Sockets with port numbers:
- $ ss -atn
- Display all UDP Sockets:
- $ ss -au
- For more information see {{man|8|ss}}.
- == Troubleshooting ==
- === The TCP window scaling problem ===
- TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.
- Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection. That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.
- It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts. The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.
- The resulting connection is at best very slow or broken.
- ==== How to diagnose the problem ====
- First of all, let us make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).
- When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.
- If you cannot browse any website, but you can ping some random hosts, chances are great that you are experiencing this problem: ping uses ICMP and is not affected by TCP problems.
- You can try to use [[Wireshark]]. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).
- ==== Ways of fixing it ====
- ===== Bad =====
- To fix it the bad way, you can change the {{ic|tcp_rmem}} value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.
- # echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem
- ===== Good =====
- Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]]):
- net.ipv4.tcp_window_scaling = 0
- ===== Best =====
- This problem is caused by broken routers/firewalls, so let us change them. Some users have reported that the broken router was their very own DSL router.
- ==== More about it ====
- This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and an archived Kernel Trap article: [https://web.archive.org/web/20120426135627/http://kerneltrap.org:80/node/6723 Window Scaling on the Internet].
- There are also several relevant threads on the LKML.
- == See also ==
- * [https://www.tldp.org/LDP/nag2/index.html Linux Network Administrators Guide]
- * [https://www.debian.org/doc/manuals/debian-reference/ch05.en.html Debian Reference: Network setup]
- * [https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Networking_Guide/ RHEL7: Networking Guide]
- * [http://www.linuxhomenetworking.com/wiki/ Linux Home Networking]
- * [https://blog.packagecloud.io/eng/2016/06/22/monitoring-tuning-linux-networking-stack-receiving-data/ Monitoring and tuning the Linux Networking Stack: Receiving data]
- * [https://blog.packagecloud.io/eng/2017/02/06/monitoring-tuning-linux-networking-stack-sending-data/ Monitoring and tuning the Linux Networking Stack: Sending data]
- * [http://blog.yadutaf.fr/2017/07/28/tracing-a-packet-journey-using-linux-tracepoints-perf-ebpf/ Tracing a packet journey using tracepoints, perf and eBPF]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement