Build and load the module:
git clone https://github.com/amkgi/linux-kernel-portblocker
cd linux-kernel-portblocker
make
sudo insmod port_blocker.ko tcp_port=22
The default port is 80.
Testing:
curl ya.ru
Monitoring:
sudo dmesg -w | grep port_blocker
Unload the module:
sudo rmmod port_blocker
Tested on kernel 6.1.50-1-generic in Astra Linux 1.7.5.