Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there any api for linux iptables , so that my program can add firewall rules [duplicate]

I am writing an application using libc, for that am in search of an api for iptables so that i can add firewall rules using my program .is there any available set of api to do this.

like image 739
cc4re Avatar asked Apr 12 '13 17:04

cc4re


People also ask

Does firewalld work with iptables?

The firewalld service implements its firewall policies using normal iptables rules.It accomplishes this by building a management framework using iptables chains. Most of the rules you are likely to see will be used to create these management chains and direct the flow of traffic in and out of these structures.

How do I create a new iptables rule?

To insert a new rule above a specific existing rule, simply use the index number of that existing rule. For example to insert a new rule to the top of the chain, use the following command with index number 1. It's also possible to flush all rules of a specific chain or even the whole iptables using the -F -parameter.


1 Answers

You can use libiptc

Quote from the howto page:

libiptc is the library that is used to communicate with netfilter, the internal kernel code in charge of firewalling and packet filtering. This code and iptables were written by Paul "Rusty" Russell. iptables was developed using libiptc calls to get the job done.

http://tldp.org/HOWTO/Querying-libiptc-HOWTO/whatis.html

like image 109
Eloims Avatar answered Oct 02 '22 07:10

Eloims