create iptables rule per process/service
It looks like the owner iptables module is that what you want. First, check if it's available in Your system:
iptables -m owner --help
You can read more here: http://www.frozentux.net/iptables-tutorial/iptables-tutorial.html#OWNERMATCH
Run a system command when an IPTables rule is matched
Here is how you do it:
iptables -I FORWARD -p tcp --dport 80 -d a.b.c.d -j LOG --log-prefix="TRIGGER ME NOW !!!"
tail -f some-logfile | awk '/some-pattern/ {system("run-some-command")}'
Should be straight forward enough and should be able to deal with lots of traffic, the tail command should be quick enough... Just make sure the file doesn't grow too much.
How can I use iptables to make a TCP proxy between me and a outside service?
You can try using owner module and skip the redirection for the traffic coming from the proxy. Check for --uid-owner or --pid-owner, you should be able to differentiate the traffic based on either of these.
Something like this,
iptables -t nat -I OUTPUT -m owner -p tcp -d <address> --dport <port> --uid-owner <proxy-owner> -j ACCEPT
Linux per program firewall similar to windows and mac counterparts
To answer your 3rd point.
There is such a program which provides zenity popups, it is called Leopard Flower:
http://sourceforge.net/projects/leopardflower
How to manipulate iptables rules from the web script
When you call system("iptables -L");
you may or may not be able to find iptables
, depending on your PATH
environment variable. You should prepend the path to where the binary is so that you know it will be found:
int result = system("/sbin/iptables -L");
Related Topics
Run a Shell Script in New Terminal from Current Terminal
How to Generate PDF from Docbook 5.0
How to Download a File from the Internet to My Linux Server with Bash
Check If Environment Variable Is Already Set
Given Two Directory Trees How to Find Which Files Are the Same
How to Register Fuse Filesystem Type with Mount(8) and Fstab
How to Give a Linux User Sudo Access
How to Fetch Java Version Using Single Line Command in Linux
Fata[0000] Get Http:///Var/Run/Docker.Sock/V1.17/Version: Dial Unix /Var/Run/Docker.Sock
Convert Multipage PDF to a Single Image
How to Get "Requests Per Second" for Apache in Linux
Ubuntu: Using Curl to Download an Image
Can't Install Python-Dev on Centos 6.5
Check If File Exists on Remote Host with Ssh
Install Zsh Without Root Access
Unix Command to List Files Containing String But *Not* Containing Another String