Questions tagged [python-iptables]

Iptables is the tool that is used to manage netfilter, the standard packet filtering and manipulation framework under Linux. It is used to setup, inspect and maintain tables of IPv4 packet filter rules in the Linux kernel. Questions pertaining to maintaining tables of packet filters in Linux must be tagged under this tag.

The package can be installed from THIS PAGE

More details about this package is available on THIS DOCUMENTATION LINK

17 questions
2
votes
2 answers

python-iptables how to specify multi argument matches

How do I specify multi-argument matches with python-iptables? For example, the following iptables command: -A INPUT -s 1.1.1.1 -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j DROP If I create the following: import iptc rule = iptc.Rule() rule.src…
pepoluan
  • 6,132
  • 4
  • 46
  • 76
1
vote
0 answers

Why python-iptables has problem when working with syslog module

I met a strange bug. I have worked on it for 2 days, but failed to solve it. So I want to post it here to see if someone can help on this. I found python-iptables(iptc) cannot work with syslog module. Please see the following code. test1() will only…
Wei Yao
  • 11
  • 2
1
vote
2 answers

Regex code to parse full Iptables log Python

I have this string bellow on iptables logs, i want parse full content. My actual regex parse 90% but i need the all content logs. My python regex: regex = re.compile('([^ ]+)=([^ ]+)') I need this parameters too: Aug 13 17:16:33 app-srv01 kernel:…
dmrpy
  • 59
  • 1
  • 8
1
vote
0 answers

Python-iptables, rule with interface does not match ipv6 packets

We are using python-iptables v0.12.0 in production within a dockerized environment orchestrated by kubernetes. The container application that uses python-iptables library consists of the following networking: Two internal interfaces exist eth0 and…
1
vote
1 answer

Can't add rules to iptables, nothing gets committed

According to the documentation:rules, doing the following should add a simple rule to the iptables list of rules: rule = iptc.Rule() rule.src = "127.0.0.1" rule.protocol = "udp" rule.target = rule.create_target("ACCEPT") match =…
Torxed
  • 22,866
  • 14
  • 82
  • 131
1
vote
1 answer

Python iptables matches (uid-owner) error

I am trying to create the following rule using the python-iptables library. # iptables -t nat -A OUTPUT -p tcp -m owner --uid-owner username -j DROP Here is my code chain = iptc.Chain(iptc.Table(iptc.Table.NAT), "OUTPUT") rule =…
user4671628
1
vote
1 answer

bash script excutes multiple iptables chain

I am using the script below to apply iptables by filtering IP from the whitelist.txt file. if I have more than one IP in the list, my iptables is showing multiple chains: #!/bin/bash # allowed ip file…
striker
  • 21
  • 3
0
votes
0 answers

Why is Pacemaker failing to update iptables and showing an error in crm status?

We are trying to create a clone set of 2 nodes for load sharing , by using pacemaker commands as below: crm configure primitive p_vip ocf:heartbeat:IPaddr2 params ip="10.214.132.107" cidr_netmask="21" nic="eth0" clusterip_hash="sourceip-sourceport"…
0
votes
0 answers

4 Bash line 1 : command not found error for python app

I made an app on linux with python to install iptable rules but it gives a run time error when i click the install button 4 Bash line 1 :(command name) command not found I tried running with sudo, logging as root to execute the code ,shebang header…
0
votes
1 answer

How to eliminate duplicate IP Table entries through python program

iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT tcp -- 10.10.10.10 anywhere tcp dpt:6379 ACCEPT tcp -- 10.10.10.10 anywhere tcp dpt:6379 I know…
0
votes
1 answer

How to see traffic on a certain ip (there are multiple ips on the server)

I am trying to see how to see the amount of traffic for each IP in Python in mbs so I can remove the IP address route in Linux and save my network from an attack when it occurs. but only ban the IP which is sending over 550 mbs. And also whitelist…
Sheep
  • 3
  • 2
0
votes
2 answers

Run python-iptables (iptc) as non-root user

I am trying to run the python-iptables as a non-root user. My script is test.py: import iptc import os uid = os.getuid() print("Real user ID of the current process:", uid) table = iptc.Table(iptc.Table.FILTER) print("Table is:".format(table)) I…
belabrinel
  • 851
  • 8
  • 15
0
votes
1 answer

Is there a way to change local port bound using iptables?

Sorry, I'm a noob in iptables. I have a VPN app which binds on local port 1080, while it goes to destination port 1194 (openvpn). The app does not support privileged port binding (which needs root, of which I have). I want the app to bind on local…
Silent
  • 31
  • 6
0
votes
1 answer

python-iptables installation error

I am trying to install python-iptables for Python27 but I get the following error after using pip install python-iptables and easy_install python-iptables libxtwrapper/wrapper.c(5) : fatal error C1083: Cannot open include file: 'sys/utsname.h': No…
0
votes
1 answer

Looking for a way to correcly generate an iptables-restore file

I'm building a firewall rule generator and i need to apply all the iptables rule atomically. The only guaranteed way to do that is to use an iptables restore file, which has it's own syntax. The only guaranteed way to generate such a file is to run…
user37203
  • 676
  • 5
  • 21
1
2