Skip to contentSkip to conversation

iptables::ipv4 problems

DISCUSSION Vlad Adomnicai 1 participant 1 message Aug 23, 2006

lore
Share & tools
lore
#0 lore raw

Hi,
I tried to use the iptables::ipv4 perl module to speed up rule adding
and the other operations. Found out that my 2k lines adding time dropped from 40 seconds to just 4s which is very nice and usefull but when I wanted to update them I runned into a problem.
I can add just fine a rule from perl, but I can't delete it from
cmdline with iptables unless I write the rule number.

I have added two chains TEST and TEST2

#!/usr/bin/perl -w
use IPTables::IPv4;
$filter_table = IPTables::IPv4::init("filter");
%rule = (
source => '192.168.212.50',
jump => 'TEST2',
'out-interface' => 'eth0'
);
$filter_table->append_entry('TEST',\%rule);
$filter_table->commit();

a iptables-save shows the rule beeing added :
:TEST - [0:0]
:TEST2 - [0:0]
-A TEST -s 192.168.212.50 -o eth0 -j TEST2
COMMIT

if I try to do ' iptables -D TEST -s 192.168.212.50 -o eth0 -j TEST2' it won't delete the rule printing :
iptables: No chain/target/match by that name

if I use iptables -D TEST 1 it deletes it just fine.

i added anothe rule by hand with the same format: iptables -A TEST -s 192.168.212.50 -o eth0 -j TEST2 and got in iptables-save :TEST - [0:0]
:TEST2 - [0:0]
-A TEST -s 192.168.212.50 -o eth0 -j TEST2
-A TEST -s 192.168.212.50 -o eth0 -j TEST2
COMMIT

Now a iptables -D TEST -s 192.168.212.50 -o eth0 -j TEST2 will succeed and delete one line. If I run it again I will get the same error as before.

From the iptables-save I see no difference between the two lines, so why can't I delete it with the iptables -D and rule. ? Is the way I add the rule from perl wrong ?

Vlad Adomnicai