Product SiteDocumentation Site

Rozdział 10. Infrastruktura sieci komputerowej

10.1. Brama
10.2. X.509 certificates
10.2.1. Creating gratis trusted certificates
10.2.2. Public Key Infrastructure: easy-rsa
10.3. Virtual Private Network
10.3.1. OpenVPN
10.3.2. Virtual Private Network with SSH
10.3.3. IPsec
10.3.4. PPTP
10.4. Quality of Service
10.4.1. Principle and Mechanism
10.4.2. Configuring and Implementing
10.5. Dynamic Routing
10.6. IPv6
10.6.1. Tunneling
10.7. Domain Name Servers (DNS)
10.7.1. DNS software
10.7.2. Configuring bind
10.8. DHCP
10.8.1. Configuring
10.8.2. DHCP and DNS
10.9. Network Diagnosis Tools
10.9.1. Local Diagnosis: netstat
10.9.2. Remote Diagnosis: nmap
10.9.3. Sniffers: tcpdump and wireshark
Linux bazuje na całym dziedzictwie Uniksa w zakresie sieci komputerowych, a Debian udostępnia pełen zestaw narzędzi do tworzenia i zarządzania nimi. Ten rozdział dokonuje przeglądu tych narzędzi.

10.1. Brama

Brama to system łączący wiele sieci komputerowych. Ten termin odnosi się do lokalnej sieci komputerowej jako do „punktu wyjścia” na obowiązkowej ścieżce do wszystkich zewnętrznych adresów IP. Brama jest podłączona do każdej sieci, z którą się razem łączy, a działa jako router do przekazywania pakietów pomiędzy jego różnymi interfejsami.
Podczas, gdy sieć lokalna używa prywatnego zakresu adresów (nie rutowalnych w Internecie), to brama musi zaimplementować „maskaradę” adresów tak, aby maszyny w sieci komputerowej mogły się komunikować ze światem zewnętrznym. Maskarada (translacja adresów sieciowych) odbywa się za pomocą proxy działającego na poziomie sieci: każde wychodzące połączenie z wewnętrznej maszyny jest zastępowane przez połączenie z samej bramy (ponieważ brama ma zewnętrzny, rutowalny adres); dane przechodzące przez połączenie poddane translacji są wysyłane do nowego połaczenia, a dane powracające jako odpowiedź są wysyłane do połączenia (poddanego translacji) z wewnętrzną maszyną. Brama wykorzystuje do tego celu szereg dedykowanych portów TCP, zwykle o bardzo dużej liczbie (ponad 60000). Każde połączenie, przychodzące z wewnętrznej maszyny, pojawia się w świecie zewnętrznym jako połączenie pochodzące z jednego z tych zarezerwowanych portów.
The gateway can also perform two kinds of network address translation (or NAT for short). The first kind, Destination NAT (DNAT) is a technique to alter the destination IP address (and/or the TCP or UDP port) for a (generally) incoming connection. The connection tracking mechanism also alters the following packets in the same connection to ensure continuity in the communication. The second kind of NAT is Source NAT (SNAT), of which masquerading is a particular case; SNAT alters the source IP address (and/or the TCP or UDP port) of a (generally) outgoing connection. As for DNAT, all the packets in the connection are appropriately handled by the connection tracking mechanism. Note that NAT is only relevant for IPv4 and its limited address space; in IPv6, the wide availability of addresses greatly reduces the usefulness of NAT by allowing all “internal” addresses to be directly routable on the Internet (this does not imply that internal machines are accessible, since intermediary firewalls can filter traffic).
Enough theory, let's get practical. Turning a Debian system into a gateway is a simple matter of enabling the appropriate option in the Linux kernel, by way of the /proc/ virtual filesystem:
# echo 1 > /proc/sys/net/ipv4/conf/default/forwarding
This option can also be automatically enabled on boot if /etc/sysctl.conf or a configuration file in /etc/sysctl.d/ sets the net.ipv4.conf.default.forwarding option to 1.

Przykład 10.1. The /etc/sysctl.conf file

net.ipv4.conf.default.forwarding = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.tcp_syncookies = 1
The same effect can be obtained for IPv6 by simply replacing ipv4 with ipv6 in the manual command and using the net.ipv6.conf.all.forwarding line in /etc/sysctl.conf.
Enabling IPv4 masquerading is a slightly more complex operation that involves configuring the netfilter firewall.
Similarly, using NAT (for IPv4) requires configuring netfilter. Since the primary purpose of this component is packet filtering, the details are listed in Rozdział 14: „Bezpieczeństwo (see Sekcja 14.2, „Firewall or Packet Filtering”).