mcvickj
Diamond Member
I work for a library system that offers free wireless access to our patrons. The first time they make a http request we transparently proxy them to a page that has some information about the rules and policies. When the patron clicks accept we poke a hole in our firewall and they continue to the requested page.
#!/usr/bin/perl
my $rule = @ARGV[0];
my $ip = @ARGV[1];
if ($ip) {
open (RULE,"|-") or exec '/sbin/iptables', '-I', 'FORWARD', $rule, '-s', $ip, '-d', '0/0', '-j', 'ACCEPT';
close RULE;
open (RULE,"|-") or exec '/sbin/iptables', '-I', 'FORWARD', $rule, '-s', '0/0', '-d', $ip, '-j', 'ACCEPT';
close RULE;
}else{
open (RULE,"|-") or exec '/sbin/iptables', '-D', 'FORWARD', $rule;
close RULE;
}
I am working on converting our firewall rules from ipfw to iptables. What we do is grab the last octet of the IP address for $rule and the users IP address for $ip. My problem is that when I try run this I see "iptables: Index of insertion too big" in my Apache error log.
From what I have found so far iptables likes to insert the rules in order. Is it possible to get around this?
#!/usr/bin/perl
my $rule = @ARGV[0];
my $ip = @ARGV[1];
if ($ip) {
open (RULE,"|-") or exec '/sbin/iptables', '-I', 'FORWARD', $rule, '-s', $ip, '-d', '0/0', '-j', 'ACCEPT';
close RULE;
open (RULE,"|-") or exec '/sbin/iptables', '-I', 'FORWARD', $rule, '-s', '0/0', '-d', $ip, '-j', 'ACCEPT';
close RULE;
}else{
open (RULE,"|-") or exec '/sbin/iptables', '-D', 'FORWARD', $rule;
close RULE;
}
I am working on converting our firewall rules from ipfw to iptables. What we do is grab the last octet of the IP address for $rule and the users IP address for $ip. My problem is that when I try run this I see "iptables: Index of insertion too big" in my Apache error log.
From what I have found so far iptables likes to insert the rules in order. Is it possible to get around this?