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
23 changes: 23 additions & 0 deletions app/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from flask import Flask, request


app = Flask(__name__)


@app.route('/get', methods=['GET'])
def function_get():
return "GET test\n"


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


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


if __name__ == "__main__":
app.run(host='0.0.0.0', port=5000)
9 changes: 9 additions & 0 deletions configs/vmA.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 configs/vmB.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.5.1/24]
version: 2
9 changes: 9 additions & 0 deletions configs/vmC.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.5.10/24]
gateway4: 192.168.5.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/net1.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/net2.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/net3.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/py.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/py_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.
67 changes: 67 additions & 0 deletions report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Отчёт по работе №1: Практика Linux (VirtualBox)
ФИО: Ситжанова Элина Кайдаровна<br>
День рождения: 23.05.2002

---

**Этап 1: Создание виртуальных машин и настройка пользователей.**
Создаём одну ВМ на основе скачанного образа и создаём две её копии.
Далее настраиваем сетевые адаптеры по заданию (две подсети: servernet и clientnet + сетевой мост).
После этого на каждой машине вручную задаем новый hostname и user.
```shell
1. Linux A: user=sitzhanova_1, hostname=sitzhanovaserver
2. Linux B: user=sitzhanova_2, hostname=sitzhanovagateway
3. Linux C: user=sitzhanova_3, hostname=sitzhanovaclient
```

<br><br>

**Этап 2: Netplan конфигурации.**
Необходимо переписать конфиги *netplan* согласно заданию и применить их командой *sudo netplan apply*:

![Netplan конфиг A](pics/net1.png)
![Netplan конфиг B](pics/net2.png)
![Netplan конфиг C](pics/net3.png)

<br>

На Linux А был для 'enp0s3' был выставлен автоматический айпи-адрес, а для 'enp0s8' - "192.168.23.10/24".
На Linux B был для 'enp0s3' был также выставлен автоматический айпи-адрес, для 'enp0s8' - "192.168.23.1/24", а для enp0s9 - "192.168.5.1/24".
На Linux С был для 'enp0s3' выставлен автоматический айпи-адрес, а для 'enp0s8' - "192.168.5.1/24".

<br><br>

**Этап 3: Донастройка каждой виртуальной машины.**
*Linux A*:<br>
Необходимо реализовать простое приложение на Flask (предварительно скачав его и Python) с тремя эндпоинтами (/get, /post, /put),
а также написать под него сервис, задача которого состоит в запуске приложение через автозагрузку:

![Flask app](pics/py.png)

<br>

*Linux B*:<br>
Необходимо настроить iptables для маршрутизации пакетов от машины A до машины C с фильтрацией пакетов по 5000-му порту:
Также необходимо включить ip_forward в настройках системы:

![iptables](pics/iptables.png)

<br><br>

**Этап 4: Тестирование системы.**
*Linux A*:<br>
Запускаем на Linux A приложение командой `python3 app.py` и проверяем, на каких адресах работает. <br>

*Linux B*:<br>
Запускаем `tcpdump` для просмотра логов передачи пакетов между клиентом и сервером. <br>

*Linux С*:<br>
Отправляем три запроса (/get, /post, /put) для проверки:

![Linux A_py](pics/py_check.png)
![Linux C_curl](pics/curl.png)
![tcpGET](pics/tcp_get.png)
![tcpPOST](pics/tcp_post.png)
![tcpPUT](pics/tcp_put.png)

Представленные скриншоты подтверждают работоспособность системы: все виртуальные машины успешно настроены, связь и фильтрация пакетов налажена, а Flask приложение отрабатывает все запросы.