This repository contains a Dockerfile and configuration for setting up a simple web server with port knocking on Ubuntu using nginx
and knockd
. Port knocking is a method used to dynamically open ports on a firewall by "knocking" on a predefined sequence of closed ports.
- Docker installed on your local machine.
git clone https://github.com/JilvinAbraham/port-knocking.git
cd port-knocking
docker build -t port-knocking .
docker run -d --name port-knocking-container -p 7000:7000 -p 8000:8000 -p 9000:9000 -p 8001:8001 port-knocking
Try accessing the web page at http://localhost:8001. It should not be accessible initially.
curl http://localhost:8001
# Should not return the web page content
Execute the following knock
commands in sequence:
knock localhost 7000:tcp 8000:tcp 9000:tcp
After performing the knock sequence, the port should open and the web page should be accessible.
Try accessing the web page again at http://localhost:8001.
curl http://localhost:8001
# Should return the web page content
Install knockd or you can even use telnet as an alternative.
To close the port, execute the following knock
command:
knock localhost 9000:tcp 8000:tcp 7000:tcp
After performing this sequence, the port should be closed again.
Try accessing the web page once more at http://localhost:8001. It should not be accessible.
curl http://localhost:8001
# Should not return the web page content
This Dockerfile sets up an Ubuntu container with nginx
and knockd
installed. It also configures nginx
to serve a simple web page on port 8001 and sets up the knockd
configuration.
The knockd.conf
file contains the port knocking configuration. It specifies the sequences for opening and closing the port 8001.