> For the complete documentation index, see [llms.txt](https://spacecore.gitbook.io/wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://spacecore.gitbook.io/wiki/ua/network-and-security-configuration/prohibiting-interaction-with-private-networks.md).

# Без взаємодії з приватними мережами

Можуть виникнути проблеми, коли раптом надходять скарги від дата-центру про сканування приватних мереж, хоча ви не робили це навмисно. Ми можемо заблокувати всі приватні мережі, щоб вирішити цю проблему.

## Установка ufw

Спочатку перевірте наявність ufw на вашому сервері:

```
sudo apt install ufw
```

<figure><img src="/files/fgtfnlz0wO9rxGCO8Yn7" alt=""><figcaption></figcaption></figure>

Далі, перед увімкненням, слід вказати важливі налаштування, щоб не втратити доступ до сервісів. Дозвольте порти SSH, HTTP, HTTPS:

```
sudo ufw allow 22
sudo ufw allow 80
sudo ufw allow 443
```

Увімкнемо наш фаєрвол:

```
sudo ufw enable
```

<figure><img src="/files/PbcA9G3VQcPJyyEmrDgZ" alt=""><figcaption></figcaption></figure>

Далі ми можемо перевірити стан фаєрволу:

```
sudo ufw status
```

<figure><img src="/files/WJ2iwts9IonYeO4T6Kle" alt=""><figcaption></figcaption></figure>

## Блокування приватних мереж&#x20;

Все добре! Тепер перейдемо до блокування приватних мереж. До них належать:

{% hint style="info" %}
These include:

* 10.0.0.0/8&#x20;
* 172.16.0.0/12&#x20;
* 192.168.0.0/16&#x20;
* 100.64.0.0/10
  {% endhint %}

Блокуємо їх за допомогою команд:

```
sudo ufw deny out from any to 10.0.0.0/8
sudo ufw deny out from any to 172.16.0.0/12
sudo ufw deny out from any to 192.168.0.0/16
sudo ufw deny out from any to 100.64.0.0/10
sudo ufw deny out from any to 198.18.0.0/15
sudo ufw deny out from any to 169.254.0.0/16
```

Після додавання можемо знову перевірити стан правил:

```
sudo ufw status

# Або за допомогою iptables:
iptables-save
```

<figure><img src="/files/ZtwyehvFNf6L1XJLylb7" alt=""><figcaption></figcaption></figure>

Тепер, якщо ми спробуємо отримати доступ до адреси приватної мережі, отримаємо помилку. Наприклад, за допомогою команди ping:

```
ping 198.18.22.62
```

<figure><img src="/files/FnnIIpkvk3wnJOgmD0oG" alt=""><figcaption></figcaption></figure>

Готово!

## Розблокування мереж (за необхідності)&#x20;

Перевірте список поточних правил ufw разом з їх нумерацією:

```
sudo ufw status numbered
```

<figure><img src="/files/KvrBUcIjUeeC4DI3JLRE" alt=""><figcaption></figcaption></figure>

Тепер можемо видалити необхідне правило за допомогою команди:

```
sudo ufw delete <номер правила>
```

Наприклад, видалимо правило 7:

```
sudo ufw delete 7
```

<figure><img src="/files/dnGpT34U0t1fIs3Kdij5" alt=""><figcaption></figcaption></figure>

Тепер немає обмежень при спробі повторного доступу до 198.18.22.62.

Дякуємо за ознайомлення! Тепер ви знаєте, як закрити (і відкрити) доступ до вашого сервера для приватних мереж за допомогою ufw.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://spacecore.gitbook.io/wiki/ua/network-and-security-configuration/prohibiting-interaction-with-private-networks.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
