> For the complete documentation index, see [llms.txt](https://adavyshin.gitbook.io/networks/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://adavyshin.gitbook.io/networks/tunnelirovanie.md).

# Туннелирование

Собираем схему в GNS3 по образу ниже:

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

🔧 Настройки маршрутизатора R1

```
configure terminal
!
hostname R1
!
interface Gi0/0
  ip address 172.17.1.1 255.255.255.0
  no sh
! 
interface Gi0/3
  ip address 172.17.101.1 255.255.255.0
  no sh
!
ip route 0.0.0.0 0.0.0.0 172.17.1.2
```

🔧 Настройки маршрутизатора R2

```
conf terminal
!
hostname R2
!
interface Gi0/1
  ip address 172.17.1.2 255.255.255.0
  no sh
!
interface Gi0/2
  ip address 172.17.2.2 255.255.255.0
  no sh
```

🔧 Настройки маршрутизатора R3

```
configure terminal
!
hostname R1
!
interface Gi0/0
  ip address 172.17.2.3 255.255.255.0
  no sh
! 
interface Gi0/3
  ip address 172.17.102.1 255.255.255.0
  no sh
!
ip route 0.0.0.0 0.0.0.0 172.17.2.2
```

🔧 Настройка туннеля на R1

```
interface Tunnel0
  ip address 192.168.0.1 255.255.255.252
  tunnel source Gi0/0
  tunnel destination 172.17.2.3
```

🔧 Настройка туннеля на R3

```
interface Tunnel0
  ip address 192.168.0.2 255.255.255.252
  tunnel source Gi0/0
  tunnel destination 172.17.1.1
```

Нюанс в том, что туннельный GRE-интерфейс всегда будет в UP, давайте выключим R2 и проверим состояние туннельных интерфейсов.

Чтобы пофиксить эту фичу используем отправку heartbeats

🔧 Настройка `heartbeat` на <kbd>R1</kbd>

```
interface Tu0
 keepalive 5 3
```

🔧 Настройка `heartbeat` на <kbd>R3</kbd>

```
interface Tu0
 keepalive 5 3
```

Теперь сделаем связность между площадками за R1 и R2

На маршрутизаторе  <kbd>R1</kbd> прописываем маршрут:

```
ip route 172.17.102.0 255.255.255.0 Tun0
```

На маршрутизаторе  <kbd>R2</kbd> прописываем маршрут:

```
ip route 172.17.101.0 255.255.255.0 Tun0
```

Настраиваем PC1

```
ip 172.17.101.100/24 172.17.101.1
```

Настраиваем PC2

```
ip 172.17.102.100/24 172.17.102.1
```


---

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

```
GET https://adavyshin.gitbook.io/networks/tunnelirovanie.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.
