Code Monkey home page Code Monkey logo

firewall's Introduction

Firewall

Задачи:

  • реализовать knocking port
  • centralRouter может попасть на ssh inetrRouter через knock скрипт.
  • добавить inetRouter2, который виден(маршрутизируется (host-only тип сети для виртуалки)) с хоста или форвардится порт через локалхост.
  • запустить nginx на centralServer.
  • пробросить 80й порт на inetRouter2 8080.
  • дефолт в инет оставить через inetRouter.
  • реализовать проход на 80й порт без маскарадинга
  • Формат сдачи ДЗ - vagrant + ansible

Knocking port

  • Для запуска проекта необходимо склонировать репозиторий: git clone https://github.com/mmmex/firewall.git

  • Переходим в каталог firewall: cd firewall

  • Запускаем проект: vagrant up

  • Будет запущено 4 ВМ: inetRouter, inetRouter2, centralRouter, centralServer

  • Скрипт ansible выполнит подготовку ВМ автоматически согласно ТЗ.

  • После завершения работы скрипта, выполняем вход на ВМ centralRouter: vagrant ssh centralRouter

  • Повышаем привелегии до суперадминистратора: sudo -i

  • Выполняем вход на inetRouter по SSH через knock скрипт: knock -v -d 100 192.168.255.1 2222:udp 3333:tcp 4444:udp; ssh [email protected]

test@test-virtual-machine:~/Otus/firewall$ vagrant ssh centralRouter
Last login: Sat Jan 21 13:04:25 2023 from 10.0.2.2
[vagrant@centralRouter ~]$ sudo -i
[root@centralRouter ~]# knock -v -d 100 192.168.255.1 2222:udp 3333:tcp 4444:udp; ssh [email protected]
hitting udp 192.168.255.1:2222
hitting tcp 192.168.255.1:3333
hitting udp 192.168.255.1:4444
The authenticity of host '192.168.255.1 (192.168.255.1)' can't be established.
ECDSA key fingerprint is SHA256:0C2hhTdJ82xxKMMO5WZFvji9DdEAfYvfxXizSDoOSKo.
ECDSA key fingerprint is MD5:ff:e5:b0:1e:2b:ae:f8:5b:cb:ab:2d:5d:28:e3:60:0e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.255.1' (ECDSA) to the list of known hosts.
[email protected]'s password:
Last login: Sat Jan 21 13:08:06 2023 from 10.0.2.2
[vagrant@inetRouter ~]$
  • В логах /var/log/knockd.log на ВМ inetRouter можем наблюдать работу сервиса knock-server:
[2023-01-21 13:06] starting up, listening on eth1
[2023-01-21 13:09] 192.168.255.2: opencloseSSH: Stage 1
[2023-01-21 13:09] 192.168.255.2: opencloseSSH: Stage 2
[2023-01-21 13:09] 192.168.255.2: opencloseSSH: Stage 3
[2023-01-21 13:09] 192.168.255.2: opencloseSSH: OPEN SESAME
[2023-01-21 13:09] opencloseSSH: running command: /sbin/iptables -I INPUT -s 192.168.255.2 -p tcp --dport ssh -j ACCEPT
[2023-01-21 13:09] 192.168.255.2: opencloseSSH: command timeout
[2023-01-21 13:09] opencloseSSH: running command: /sbin/iptables -D INPUT -s 192.168.255.2 -p tcp --dport ssh -j ACCEPT
  • Демонстрация работы knocking port:

asciicast

Iptables

  • Согласно ТЗ подготовлена топология сети:

image

  • Таблица хостов:
Имя хоста Адреса Кол-во интерфейсов
inetRouter 192.168.255.1/30 1
inetRouter2 192.168.254.1/30 1
centralRouter 192.168.255.2/30, 192.168.254.2/30, 192.168.0.1/28 3
centralServer 192.168.0.2/28 1
  • Выполняем вход с хостовой машины через браузер: http://127.0.0.1:8080

  • Видим страничку nginx, которая находится на centralServer.

firewall's People

Contributors

mmmex avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.