Read the CGI primer first .
You will need an HTML page with code like this:
<form method="get" action="/cgi-bin/my-fw-script.sh"> <p>Gimme an IP address: <input name="addr"></p> <input type="submit">Block IP</input> </form>
When the user clicks the "Submit Form" button, your Bash CGI program will be launched. (/path/to/cgi-bin/my-fw-script.sh in the above example.) The text input will be in the environment variable QUERY_STRING in the variable variable = value. For simple inputs, you can simply call the Bash eval function to turn it into a Bash variable:
#!/bin/sh eval $QUERY_STRING echo You asked me to block $addr.
This will only work for one input field and will break if there are spaces or other special characters. I believe that the idea of ββbash_cgi, which someone else recommended, will take care of these details for you. Do this, as in the example above, only if this program remains very simple.
By the way, you almost certainly do not want to add MAC addresses to the firewall. This only works for hosts that are on the same local network as the firewall. Packets coming from another LAN, Internet, etc., will have the MAC address of the LAN gateway. You should probably block hosts by IP address.
source share