For the project that I am currently working on, the task is to read a file from disk that is of following format:
port number [in/out/both]
So, if a port number is followed by in, only inbound connections are allowed. If it is followed by out, only outbound connections are allowed and bidirectional if it is followed by both. Block all other ports.
One way to do this, is to read the file at boot time and store port and type in a data structure and keep that in memory, and when a process tries to use a port, grant the access based in the data structure that is in memory. The problem is, I dont know how to actually implement this, just need a push in the right directions. I know this can be done using iptables, but that is not allowed.