Erlang OTP: Distributed & Fault-Tolerant Systems Programming · Lekcja

Zabezpieczanie cookie dystrybucji i dostępu do węzłów

Ograniczaj węzły, które mogą łączyć się z klastrem, korzystając z cookies, list dozwolonych węzłów i izolacji sieci, aby zapobiegać nieuprawnionemu dostępowi.

Lekcja 4 z 413 kroki

Zabezpieczanie cookie dystrybucji i dostępu do węzłów to bezpłatna lekcja Erlang OTP: Distributed & Fault-Tolerant Systems Programming na CoddyKit. To lekcja 4 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Erlang OTP: Distributed & Fault-Tolerant Systems Programming, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Erlang OTP: Distributed & Fault-Tolerant Systems Programming zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

How Nodes Authenticate

Erlang nodes form a cluster by sharing a secret cookie. Any node that knows the cookie and can reach the port may connect — and once connected, can run arbitrary code. This makes the cookie a critical secret.

The Magic Cookie

By default each node reads its cookie from ~/.erlang.cookie. If two nodes share it, they trust each other completely.

erlang:get_cookie().

The Danger of Defaults

A weak or default cookie on a publicly reachable distribution port is a full remote-code-execution hole. Treat the cookie like a root password.

Setting a Strong Cookie

Set a long, random cookie explicitly at startup rather than relying on the file default.

erlang:set_cookie(node(), 'a-very-long-random-secret').

Protecting the Cookie File

The cookie file must be readable only by its owner. Erlang refuses to start if permissions are too open.

chmod 400 ~/.erlang.cookie

Restricting Node Names

Use net_kernel options and firewall rules so only known hostnames can even attempt a connection. Distribution should never be exposed to the open internet.

Binding the Distribution Port

Pin the distribution to specific ports and bind EPMD to a private interface so the cluster is unreachable from outside the trusted network.

erl -kernel inet_dist_listen_min 9100 inet_dist_listen_max 9105

Monitoring Connections

nodes/0 lists currently connected nodes. Periodically auditing this list helps detect an unexpected peer.

nodes().

Reacting to New Nodes

Subscribe to node up/down events with net_kernel:monitor_nodes/1 to log or reject connections you did not expect.

net_kernel:monitor_nodes(true).

Hidden Nodes

Start tooling or monitoring nodes as hidden with -hidden so they connect without joining the full mesh, reducing the trust surface of your cluster.

erl -hidden -name tool@10.0.0.5 -setcookie SECRET

Defense in Depth

Cookies alone are not enough. Combine them with TLS distribution, a private network (VPN/VLAN), firewalled EPMD, and least-privilege node placement.

Quick Check

Test your node security knowledge.

Recap

You learned to harden node access:

  • The shared cookie is the cluster password — keep it long, random, secret
  • Protect ~/.erlang.cookie with 400 permissions
  • Bind distribution and EPMD to private interfaces; firewall them
  • Audit connected nodes with nodes/0 and monitor events
  • Layer cookies with TLS and network isolation
Bezpłatny start

Ucz się Erlang dzięki korepetycjom AI — za darmo

Pisz i uruchamiaj kod w przeglądarce, otrzymuj natychmiastową pomoc od korepetytora AI dostępnego 24/7 i kontynuuj naukę w sieci lub w aplikacji.

Kursy
12
Lekcje
48

Często zadawane pytania

Czy lekcja „Zabezpieczanie cookie dystrybucji i dostępu do węzłów” jest bezpłatna?

Tak — pełny tekst „Zabezpieczanie cookie dystrybucji i dostępu do węzłów” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Erlang OTP: Distributed & Fault-Tolerant Systems Programming, przejdź na CoddyKit PRO. Kurs Erlang OTP: Distributed & Fault-Tolerant Systems Programming zawiera 4 lekcji w sumie.

Co nauczysz się w „Zabezpieczanie cookie dystrybucji i dostępu do węzłów”?

Ograniczaj węzły, które mogą łączyć się z klastrem, korzystając z cookies, list dozwolonych węzłów i izolacji sieci, aby zapobiegać nieuprawnionemu dostępowi. Ćwiczysz Erlang OTP: Distributed & Fault-Tolerant Systems Programming z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Erlang OTP: Distributed & Fault-Tolerant Systems Programming?

Nie wymagamy żadnego doświadczenia. Erlang OTP: Distributed & Fault-Tolerant Systems Programming w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 4 z 4.

Ile czasu zajmuje lekcja „Zabezpieczanie cookie dystrybucji i dostępu do węzłów”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Erlang OTP: Distributed & Fault-Tolerant Systems Programming?

Tak. Każda lekcja Erlang OTP: Distributed & Fault-Tolerant Systems Programming zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Bezpieczna komunikacja węzłów (TLS)
  2. Uwierzytelnianie i autoryzacja
  3. Ochrona danych wrażliwych
  4. Zabezpieczanie cookie dystrybucji i dostępu do węzłów
← Powrót do Erlang OTP: Distributed & Fault-Tolerant Systems Programming