From 3a102c56e7d56fa7c216d51a55dc60faf6076860 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 22 Mar 2026 21:27:13 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..ede58d6 --- /dev/null +++ b/README.md @@ -0,0 +1,180 @@ +# Домашнее задание 30 + +## OSPF + +Для выполнение задания используется vagrant box Ubuntu 22.04 + +В ДЗ указано, что нужно поднять OSPF между 3 VM, но я добавил сюда еще 2. + +### Создание Vagrantfile + +Создадим 5 VM с характеристиками + +- CPU 1 +- RAM 512Mb + +Создана сеть **router2-net** с адресацией **192.168.255.12/30** + +Будут добавлены 5 сетей с раздичной адресацией. + +Текущая карта сети: +![33_1](images/33_1.png) + + +Готовый [Vagrantfile](Vagrantfile) + + +### ansible.yml + +В сценарий для Ansible добавлены следующие действия: + +1. На всех VM установлен frr +2. В конфигурации frr будет включена поддержка **ospf** +3. На все VM будет импортирован минимальный шаблон конфигурации frr.template +4. После копирования шаблона требуется добавить в кофиг ip адреса и интерфейсы для каждой VM, мы это сделаем с помощью отдельного файла ansible_conf_frr.yml. На всех интерфейсам будем устанавливать ospf cost равный 20 +5. Включим ospf, и так как все создынные сети у нас попадают по маску 10.0.0.0/8 то в network мы укажем именно ее. + + +Готовый [ansible.yml](ansible.yml) +[ansible_conf_frr.yml](ansible_conf_frr.yml) +[frr.template](frr.template) + + + +### Проверка + +Запускаем vagrant +```bash +alex@ubuntu-pc:~/Документы/33$ vagrant up +Bringing machine 'R01' up with 'virtualbox' provider... +Bringing machine 'R02' up with 'virtualbox' provider... +Bringing machine 'R03' up with 'virtualbox' provider... +Bringing machine 'Server01' up with 'virtualbox' provider... +Bringing machine 'Server02' up with 'virtualbox' provider... +==> R01: You assigned a static IP ending in ".1" or ":1" to this machine. +==> R01: This is very often used by the router and can cause the +==> R01: network to not work properly. If the network doesn't work +==> R01: properly, try changing this IP. +==> R01: You assigned a static IP ending in ".1" or ":1" to this machine. +==> R01: This is very often used by the router and can cause the +==> R01: network to not work properly. If the network doesn't work +==> R01: properly, try changing this IP. +==> R01: You assigned a static IP ending in ".1" or ":1" to this machine. +==> R01: This is very often used by the router and can cause the +==> R01: network to not work properly. If the network doesn't work +==> R01: properly, try changing this IP. +... + + +... +TASK [get int name] ************************************************************ +changed: [R05] + +TASK [add interface ip] ******************************************************** +changed: [R05] + +TASK [add ospf frr] ************************************************************ +changed: [R05] + +RUNNING HANDLER [restart frr] ************************************************** +changed: [R05] + +PLAY RECAP ********************************************************************* +R05 : ok=10 changed=8 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 + +``` + + + + +После запуска всех машин, подключимся к VM R05 и посмотрим какие там присутствуют маршруты + + + + + +Мы видим все маршруты которые прилетели через OSPF. + + +### Изобразить ассиметричный роутинг + +Подключимся к R01, с помощью консоли оболочки vtysh увелим cost ospf до 100 на интерфейсе который подключен к R02. + + +```bash +vagrant@R01:~$ sudo vtysh + +Hello, this is FRRouting (version 8.1). +Copyright 1996-2005 Kunihiro Ishiguro, et al. + +R01# conf t +R01(config)# +R01(config)# int enp0s8 +R01(config-if)# ip ospf cost 100 +R01(config-if)# end +R01# wr +Note: this version of vtysh never writes vtysh.conf +Building Configuration... +Integrated configuration saved to /etc/frr/frr.conf +[OK] +R01# +``` + +проверим как изменились маршруты +```bash +R01(config)# do sh ip route ospf +Codes: K - kernel route, C - connected, S - static, R - RIP, + O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, + T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR, + f - OpenFabric, + > - selected route, * - FIB route, q - queued, r - rejected, b - backup + t - trapped, o - offload failure + +O 10.0.2.0/24 [110/100] is directly connected, enp0s3, weight 1, 00:10:02 +O 10.10.1.0/24 [110/60] via 10.20.1.2, enp0s9, weight 1, 00:01:21 +O 10.20.1.0/24 [110/20] is directly connected, enp0s9, weight 1, 00:10:02 +O>* 10.30.1.0/24 [110/40] via 10.20.1.2, enp0s9, weight 1, 00:01:21 +O 10.100.1.0/24 [110/20] is directly connected, enp0s10, weight 1, 00:10:02 +O>* 10.200.1.0/24 [110/60] via 10.20.1.2, enp0s9, weight 1, 00:01:21 +``` + +Мы видим, что маршрут до сети 10.200.1.0/24 идет через 10.20.1.2 (это R03) + + +Теперь у нас будет наблюдаться следующая картина, если мы будем пускать какой либо трафик (например ICPM) то пакеты будет идти по пути +от **R04** до **R05** +**R04** -> **R01** -> **R03** -> **R02** -> **R05** +а ответные пакеты будут идти минуя **R03** +**R05** -> **R02** -> **R01** -> **R04** + + +Таки образом мы достигли ассиметричного роутинга + +### сделать один из линков "дорогим", но что бы при этом роутинг был симметричным. + +Для выполнение этого задания, мы уже подключися к R02, и на интерфейся к R01 увеличим cost до 100 + +```bash +vagrant@R02:~$ sudo vtysh + +Hello, this is FRRouting (version 8.1). +Copyright 1996-2005 Kunihiro Ishiguro, et al. + +R02# conf t +R02(config)# int enp0s8 +R02(config-if)# ip ospf cost 100 +R02(config-if)# end +R02# wr +Note: this version of vtysh never writes vtysh.conf +Building Configuration... +Integrated configuration saved to /etc/frr/frr.conf +[OK] +R02# + +``` + + +Теперь трафик между R04 и R05 вновь становиться симметричным + + +Все готово! \ No newline at end of file