Linux Netfilter discussions
 help / color / mirror / Atom feed
From: alvin <alvin.sm@Mail.Linux-Consulting.com>
To: Thomas Delrue <thomas.delrue@fundamental-software.net>
Cc: netfilter@vger.kernel.org, alvin <alvin.sm@Mail.Linux-Consulting.com>
Subject: Re: Creating, editing, removing rules from C(++)
Date: Tue, 21 Jul 2015 15:30:26 -0700 (PDT)	[thread overview]
Message-ID: <201507212230.t6LMURFX024196@Mail.Linux-Consulting.com> (raw)
In-Reply-To: <55AEBC86.5010604@fundamental-software.net>


hi thomas

> Is there a way to interact with the firewall rules from a C(++) program?
> What I'm really trying to do is have a program that only allows a
> certain set of CIDRs through the firewall through a particular port.
> However these CIDRs change from time to time and so my application is
> there to update the firewall rules to make sure that the firewall rules
> contain the latest and greatest information that says: "drop everything
> trying to connect to port P EXCEPT for stuff originating from these CIDRs=
> ".

yes, i update iptables rules randomly and on the fly

iptables recent module did not do what i wanted so i wrote the 
add or delete iptables rules in C

it has a command line interface or web pages with cgi-bin 

modifying iptables rules from apache requires visudo to 
allow apache to modify iptable rules which is kinda dangerous :-)

# eg. add incoming ddos attackers to iptables blacklist
# iptables-gui -autoadd ... 'a.b.c.d|w.x.y.z'

# the corresponding actual iptable rule:
  iptables -I BlackList -p tcp -s a.b.c.d -d myLAN/24 -j TARPIT

# eg. remove inactive ddos attacks from the blacklist
# iptables-gui -autodelete ... w.x.y.z

# the corresponding actual iptable rule:
  iptables -D BlackList -p tcp -s a.b.c.d -d myLAN/24 -j TARPIT

- online demo:  http://DDoS-Mitigator.net/cgi-bin/IPtables-GUI.pl

have fun
alvin

> The information I've found so far seems to indicate I should look at
> libnftnl and nftables but I'm not sure this is right.
> Can you point me to the documentation for this? I've been looking online
> for information on how to do this but haven't found anything really.
> 
> Thanks,
> Thomas

  reply	other threads:[~2015-07-21 22:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-21 21:41 Creating, editing, removing rules from C(++) Thomas Delrue
2015-07-21 22:30 ` alvin [this message]
     [not found]   ` <55AECB5B.9090302@fundamental-software.net>
2015-07-22 17:01     ` alvin
2015-07-21 23:15 ` Neal P. Murphy
2015-07-22  0:08   ` Sven-Haegar Koch
2015-07-22  0:31     ` Neal P. Murphy
2015-07-22 13:39   ` Thomas Delrue
2015-07-27 10:25 ` Bastian Bittorf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201507212230.t6LMURFX024196@Mail.Linux-Consulting.com \
    --to=alvin.sm@mail.linux-consulting.com \
    --cc=netfilter@vger.kernel.org \
    --cc=thomas.delrue@fundamental-software.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox