Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions app/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from flask import Flask, request

app = Flask(__name__)

@app.route('/get', methods=['GET'])
def get_route():
return "route get is working!\n"

@app.route('/post', methods=['POST'])
def post_route():
return f"route post is working!: {request.json}\n"

@app.route('/put', methods=['PUT'])
def put_route():
return f"route put is working!: {request.json}\n"

if __name__ == "__main__":
app.run(host='0.0.0.0', port=5000)
9 changes: 9 additions & 0 deletions config/A.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
network:
ethernets:
enp0s3:
dhcp4: true
enp0s8:
dhcp4: no
addresses: [192.168.23.10/24]
gateway4: 192.168.23.1
version: 2
11 changes: 11 additions & 0 deletions config/B.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
network:
ethernets:
enp0s3:
dhcp4: true
enp0s8:
dhcp4: no
addresses: [192.168.23.1/24]
enp0s9:
dhcp4: no
addresses: [192.168.10.1/24]
version: 2
9 changes: 9 additions & 0 deletions config/C.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
network:
ethernets:
enp0s3:
dhcp4: true
enp0s8:
dhcp4: no
addresses: [192.168.23.10/24]
gateway4: 192.168.10.1
version: 2
Binary file added pics/curl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/iptables.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/netA.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/netB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/netC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/python.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/python_check.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/tcp_get.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/tcp_post.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/tcp_put.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Отчёт по работе №1: Практика Linux (VirtualBox)

**Литвин Георгий Дмитриевич**

<br>

**Дата рождения: 23.10.2002**


---

**Начинаем работу с создания одной ВМ на основе скачанного образа.** Дважды клонируем её. <br>
Далее настраиваем сетевые адаптеры по заданию:
- Вместо NAT - Сетевой мост
- Добавляем две внутренние подсети - `clientnet` и `servernet` <br> <br>

После настройки запускаем все три ВМ и конфигурируем hostname и user:
- `user=litvin_1, hostname=litvin_server (server)`
- `user=litvin_2, hostname=litvin_gateway (gateway)`
- `user=litvin_3, hostname=litvin_client (client)`

---

**Перейдем к настройке netplan конфигов.** <br>
Меняем конфигурационные файлы командой:
```shell
sudo nano /etc/netplan/00-installer-config.yaml
```
А также применяем новые сетевые настройки:
```shell
sudo netplan apply
```
Проверим полученный результат: <br>

![Netplan A](pics/netA.png)
![Netplan B](pics/netB.png)
![Netplan C](pics/netC.png)

---
**Linux A (server)**

<br>

В корневой папке создадим файл `app.py` с простым Flask приложением на три эндпоинта. <br>
Также напишем сервис для автозапуска приложения:

![Flask приложение и сервис для его запуска](pics/python.png)

---
**Linux B (gateway)**

<br>

Настроим `iptables` на ВМ-шлюзе для фильтрации пакетов по 5000 порту. <br>
Делаем это также через терминал командами по заданию. <br>
После изменения сохраняем конфигурацию через `iptables-persistent`. <br>
Проверим полученный результат: <br>

![ip_rules](pics/iptables.png)

---

**Тестирование**

<br>

Для проверки всей системы необходимо:
- Запустить `python3 app.py` на машине **А**
- Запустить `tcpdump` на машине **B**
- Начать отправлять `curl` запросы на машине **C**
Проверим полученный результат: <br>

![ВМ С](pics/python_check.png)

Также проверим логи `tcpdump` на машине **B**:

![get](pics/tcp_get.png)
![post](pics/tcp_post.png)
![put](pics/tcp_put.png)