# GRE туннель

Для развертывания GRE туннеля на сервере VPS вам нужно выполнить следующие шаги:

1. На сервере VPS установите пакеты `iproute2` и `iptables`.

   ```bash
   sudo apt-get update
   sudo apt-get install iproute2 iptables
   ```
2. Создайте GRE туннель с использованием команды `ip tunnel`.

   ```bash
   # замените IP-адреса на свои
   sudo ip tunnel add gre-tunnel mode gre remote <SERVER_IP> local <CLIENT_IP>
   sudo ip link set gre-tunnel up
   ```
3. Настройте IP-адрес для GRE интерфейса.

   ```bash
   # замените IP-адрес на свой
   sudo ip addr add <GRE_IP>/24 dev gre-tunnel
   ```
4. Настройте маршрутизацию по умолчанию через GRE интерфейс.

   ```bash
   sudo ip route add default via <GRE_IP> dev gre-tunnel
   ```
5. Настройте правила iptables для разрешения трафика GRE.

   ```bash
   sudo iptables -A INPUT -p gre -j ACCEPT
   sudo iptables -A OUTPUT -p gre -j ACCEPT
   ```

Теперь у вас должен быть настроен GRE туннель на сервере VPS. Вы можете проверить его работоспособность, отправив данные через туннельный интерфейс и убедившись, что они достигают другого конца туннеля.


---

# Agent Instructions: 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:

```
GET https://wiki.4vps.su/chastye-voprosy-linux/gre-tunnel.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
