diff --git a/app/app.py b/app/app.py new file mode 100644 index 0000000..8a327b0 --- /dev/null +++ b/app/app.py @@ -0,0 +1,20 @@ +from flask import Flask, request + +app = Flask(__name__) + +@app.route('/get', methods=['GET']) +def func_GET(): + return "here comes GET response\n" + +@app.route('/post', methods= ['POST']) +def func_POST(): + data = request.json + return f"here comes POST response: {data}\n" + +@app.route(/put', methods= ['PUT']) +def func_PUT() : + data = request.json + return f"here comes PUT response: {data}\n" + +if __name__ == '__main__': + app.run(host='0.0.0.0', port=5000) diff --git a/configs/client.txt b/configs/client.txt new file mode 100644 index 0000000..330af9a --- /dev/null +++ b/configs/client.txt @@ -0,0 +1,9 @@ +network: + ethernets: + enp0s3: + dhcp4: true + enp0s8: + dhcp4: no + addresses: [192.168.3.10/24] + gateway4: 192.168.3.1 + version: 2 diff --git a/configs/gateway.txt b/configs/gateway.txt new file mode 100644 index 0000000..b2a6a15 --- /dev/null +++ b/configs/gateway.txt @@ -0,0 +1,11 @@ +network: + ethernets: + enp0s3: + dhcp4: true + enp0s8: + dhcp4: no + addresses: [192.168.31.1/24] + enp0s9: + dhcp4: no + addresses: [192.168.3.1/24] + version: 2 diff --git a/configs/server.txt b/configs/server.txt new file mode 100644 index 0000000..9165416 --- /dev/null +++ b/configs/server.txt @@ -0,0 +1,9 @@ +network: + ethernets: + enp0s3: + dhcp4: true + enp0s8: + dhcp4: no + addresses: [192.168.31.10/24] + gateway4: 192.168.31.1 + version: 2 diff --git a/configs/webserver.txt b/configs/webserver.txt new file mode 100644 index 0000000..8e7269f --- /dev/null +++ b/configs/webserver.txt @@ -0,0 +1,8 @@ +[Unit] +Description=Web-Server +[Service] +Type=idle +WorkingDirectory=/home/user/server +ExecStart=python3 app.py +[Install] +WantedBy=multi-user.target diff --git a/photos/VM A/1 VM A.png b/photos/VM A/1 VM A.png new file mode 100644 index 0000000..cbcdfc6 Binary files /dev/null and b/photos/VM A/1 VM A.png differ diff --git a/photos/VM A/1 app and webserver.png b/photos/VM A/1 app and webserver.png new file mode 100644 index 0000000..afc1f9d Binary files /dev/null and b/photos/VM A/1 app and webserver.png differ diff --git a/photos/VM A/1 configuration.png b/photos/VM A/1 configuration.png new file mode 100644 index 0000000..a8be089 Binary files /dev/null and b/photos/VM A/1 configuration.png differ diff --git a/photos/VM A/1 hostname and add user.png b/photos/VM A/1 hostname and add user.png new file mode 100644 index 0000000..37b1bf6 Binary files /dev/null and b/photos/VM A/1 hostname and add user.png differ diff --git a/photos/VM A/1 responses.png b/photos/VM A/1 responses.png new file mode 100644 index 0000000..7aea663 Binary files /dev/null and b/photos/VM A/1 responses.png differ diff --git a/photos/VM A/readme.txt b/photos/VM A/readme.txt new file mode 100644 index 0000000..3898305 --- /dev/null +++ b/photos/VM A/readme.txt @@ -0,0 +1 @@ +скриншоты с ВМ А (сервер) diff --git a/photos/VM B/2 VM B.png b/photos/VM B/2 VM B.png new file mode 100644 index 0000000..e8c7164 Binary files /dev/null and b/photos/VM B/2 VM B.png differ diff --git a/photos/VM B/2 configuration.png b/photos/VM B/2 configuration.png new file mode 100644 index 0000000..c06dbe4 Binary files /dev/null and b/photos/VM B/2 configuration.png differ diff --git a/photos/VM B/2 hostname and add user.png b/photos/VM B/2 hostname and add user.png new file mode 100644 index 0000000..cf73533 Binary files /dev/null and b/photos/VM B/2 hostname and add user.png differ diff --git a/photos/VM B/2 iptables and routes.png b/photos/VM B/2 iptables and routes.png new file mode 100644 index 0000000..a1ce6b2 Binary files /dev/null and b/photos/VM B/2 iptables and routes.png differ diff --git a/photos/VM B/2 tcpdump GET.png b/photos/VM B/2 tcpdump GET.png new file mode 100644 index 0000000..e76e5f2 Binary files /dev/null and b/photos/VM B/2 tcpdump GET.png differ diff --git a/photos/VM B/2 tcpdump POST.png b/photos/VM B/2 tcpdump POST.png new file mode 100644 index 0000000..0b8d252 Binary files /dev/null and b/photos/VM B/2 tcpdump POST.png differ diff --git a/photos/VM B/2 tcpdump PUT.png b/photos/VM B/2 tcpdump PUT.png new file mode 100644 index 0000000..65555fe Binary files /dev/null and b/photos/VM B/2 tcpdump PUT.png differ diff --git a/photos/VM B/readme.txt b/photos/VM B/readme.txt new file mode 100644 index 0000000..1d2d1ef --- /dev/null +++ b/photos/VM B/readme.txt @@ -0,0 +1 @@ +скриншоты с ВМ Б (шлюз) diff --git a/photos/VM C/3 VM C.png b/photos/VM C/3 VM C.png new file mode 100644 index 0000000..9fbb2ef Binary files /dev/null and b/photos/VM C/3 VM C.png differ diff --git a/photos/VM C/3 configuration.png b/photos/VM C/3 configuration.png new file mode 100644 index 0000000..7072af2 Binary files /dev/null and b/photos/VM C/3 configuration.png differ diff --git a/photos/VM C/3 hostname and add user.png b/photos/VM C/3 hostname and add user.png new file mode 100644 index 0000000..a121b47 Binary files /dev/null and b/photos/VM C/3 hostname and add user.png differ diff --git a/photos/VM C/3 requests.png b/photos/VM C/3 requests.png new file mode 100644 index 0000000..deb58fc Binary files /dev/null and b/photos/VM C/3 requests.png differ diff --git a/photos/VM C/readme.txt b/photos/VM C/readme.txt new file mode 100644 index 0000000..7998914 --- /dev/null +++ b/photos/VM C/readme.txt @@ -0,0 +1 @@ +скриншоты с ВМ С (клиент) diff --git a/photos/readme.txt b/photos/readme.txt new file mode 100644 index 0000000..bc08fcd --- /dev/null +++ b/photos/readme.txt @@ -0,0 +1 @@ +скриншоты diff --git a/report.md b/report.md new file mode 100644 index 0000000..25227cd --- /dev/null +++ b/report.md @@ -0,0 +1,85 @@ +Отчет по практической работе с виртуальными машинами на ОС Linux Ubuntu 24.04.2 + +Работа начинается с создания и настройки виртуальных машин А, Б и С - сервера, шлюза и клиента соответственно. +Ниже предствлены скрины настройки виртуальных машин и их состояние: +![3 VM C](https://github.com/user-attachments/assets/aea185b9-502e-4e87-8646-738c90d8d457) +![2 VM B](https://github.com/user-attachments/assets/da9744cf-cc18-4d5b-8a47-9d854e0ad308) +![1 VM A](https://github.com/user-attachments/assets/e800ffc2-1e71-4821-8a16-a0d3fe862c1b) + +--- + +На всех трех виртуальных машинах был изменён 'hostname' в соответствии с заданием: +![1 hostname and add user](https://github.com/user-attachments/assets/b6477e76-06de-4855-bf62-1acdab0898a2) +![2 hostname and add user](https://github.com/user-attachments/assets/342684de-5ae1-4ea0-a460-dcbc3a8738ae) +![3 hostname and add user](https://github.com/user-attachments/assets/70036e6b-164f-47d0-b8a6-ed1d698f2d61) + +В итоге получилось присвоить виртуальным машинам новые 'hostname':
+ВМ А - asowslaserver
ВМ Б - asowslagateway
ВМ С - asowslaclient + +А так же на всех трех виртуальных машинах успешно были добавлены новые пользователи 'not_asowsla' и присвоены пароли для авторизации + +--- + +Далее была произведена конфигурация виртуальных интерфейсов на всех трех виртуальных машинах: +![1 configuration](https://github.com/user-attachments/assets/2185bfec-72ec-4fa8-87de-5b413970cd0f) +![2 configuration](https://github.com/user-attachments/assets/dd83cf2e-5b1b-45fd-a64d-f67c447ec4c0) +![3 configuration](https://github.com/user-attachments/assets/f7e060b5-3731-4e7a-80a8-c7a007a3dd23) + +На ВМ А был для 'enp0s3' был выставлен автоматический айпи-адрес, а для 'enp0s8' - "192.168.31.10/24" в соответствии с заданием;
+На ВМ Б был для 'enp0s3' был также выставлен автоматический айпи-адрес, для 'enp0s8' - "192.168.31.1/24", а для enp0s9 - "192.168.3.1/24" в соответствии с заданием;
+На ВМ С был для 'enp0s3' выставлен автоматический айпи-адрес, а для 'enp0s8' - "192.168.3.1/24" в соответствии с заданием; + +Все конфигурационные файлы также представлены отдельно в соответствующей папке 'configs' в репозиторие. + +--- + +Перейдем к рассмотрению процесса настраивания виртуальных машин по отдельности. + +Начнем с ВМ А. + +Был http-сервер на порту 5000. Также были реализованы три эндпоинта (запрос /get, /post, /put). Ниже представлен результат настройки (скрин был сделал раньше, чем я поменял 'hostname' на тот, что в задании): +![1 app and webserver](https://github.com/user-attachments/assets/a4ab76d8-2cfb-4b20-907f-10d7a4ef2690) + +Скрипты, описанные в 'app.py' и '/lib/systemd/system/web.server.service', представлены отдельно - в папках 'app' и 'configs' соответственно. + +--- + +Рассмотрит ВМ Б. + +С помощью утилит ip route и iptables были настроены маршрут пакетов от ВМ A до ВМ C и была настроена фильтрация по порту 5000. + +Настройка маршрутов представлена ниже: +![2 iptables and routes](https://github.com/user-attachments/assets/3148be73-89ea-498b-8dd5-69410d437077) + +--- + +Перейдем к ВМ С. + +Ранее была представлена конфигурация ВМ С. А ниже представлены запросы, передаваемые через ВМ Б на ВМ А: +![3 requests](https://github.com/user-attachments/assets/1fd7407b-1e12-4e78-9ec3-2cdd15f43ebe) + +Как можно заметить, ВМ С успешно получает фидбек от ВМ А. + +--- + +Теперь рассмотрит фидбек, получаемый с ВМ А, и мониторинг с помощью 'tcpdump' по порту 5000, установленный на ВМ Б. + +На скринах ниже представлено состояние ВМ А во время получения запросов с ВМ С: +![1 responses](https://github.com/user-attachments/assets/76eb76bd-7aff-42c6-9707-b41139d26c4d) + +Так же с помощью команды 'tcpdump' были получены логи передачи пакетов с ВМ С на ВМ А. Ниже представлены скрины. + +Мониторинг запросов GET с ВМ С на ВМ А: +![2 tcpdump GET](https://github.com/user-attachments/assets/ac0935ff-3e67-401e-9c00-0affb7b21197) + +Мониторинг запросов POST с ВМ С на ВМ А: +![2 tcpdump POST](https://github.com/user-attachments/assets/ba3f4544-b076-4fda-8faf-062331758438) + +Мониторинг запросов PUT с ВМ С на ВМ А: +![2 tcpdump PUT](https://github.com/user-attachments/assets/9beca983-1933-43f9-b6ef-4238be1f7885) + +--- + +По вышепредставленным скринам и описаниям происходящего можно сделать вывод, что все виртуальные машины были успешно настроены. Все три вида запросов с ВМ С на ВМ А через ВМ Б проходят успешно. + +---