and The "add Rule" Part:$q->default_dtd('-//W3C//DTD HTML 4.01 Transitional//EN'); print $q->header(), $q->start_html("DNAT"), $q->br(), $q->br(), $q->start_form(), $q->start_table({ -boarder => '0' }), $q->Tr($q->td($q->radio_group(-name => 'proto', -values => ['tcp','udp'], -rows => 2, -columns => 1)), $q->td('Port: ', $q->textfield(-name => 'port')), $q->td('IP-Adresse: ', $q->textfield(-name => 'ip')), $q->td($q->submit(-name => 'add', -value => 'apply'))), $q->end_table(), $q->end_form(); $q->br(), $q->br();
In short, the Problem is, everytime i call the script to add a rule, i get an error from the append_entry() methode, telling me that "protocol: Must be passed as integer or string at ..." Ok i know this fact, but i thought i'd alredy do so. So i added a debug output to check the value of $proto ... its a scalar with "tcp" (or "udp") as its value. But why IPTables::IPv4 still tells me that its "not a string"?? Next Test i did was to add "tcp" as a static element of the %addrule Hash ... and woow suddenly append_entry() seems to have no more problems with the protocol, instead now its throws me the same error for the IP-Adress :(. What is wrong with this code?? I'm a realy CGI newb so - imho - i think the problem is somewhere at:if ($q->param('add')) { # seems that user has requested a new rule my $proto = $q->param('proto'); my $port = $q->param('port'); my $ip = $q->param('ip'); # set up rule hash's for NAT and FILTER Tables my %addrule_nat = ( protocol => "$proto", "destination-port" => "$port", jump => "DNAT", "to-destination" => "$ip", ); my %addrule_for = ( protocol => $proto, "in-interface" => 'eth0', "out-interface" => 'eth1', "destination-port" => $port, jump => "ACCEPT", ); my %addrule_inp = ( protocol => $proto, "destination-port" => $port, jump => "ACCEPT", ); my $erfolg_nat = $nat->append_entry('PREROUTING', \%addrule_nat) || d +ie "NAT: $!"; my $erfolg_for = $filter->insert_entry('FORWARD', \%addrule_for, 0) | +| die "FORWARD: $!"; my $erfolg_inp = $filter->insert_entry('INPUT', \%addrule_inp, 0) || +die "INPUT: $!"; # now commit our work my $commit_nat = $nat->commit(); my $commit_filter = $filter->commit(); # tell the user it is done an refresh in 5sec _cut_ }
Can anybody help me with this issue?my $proto = $q->param('proto'); my $port = $q->param('port'); my $ip = $q->param('ip');
In reply to IPTables::IPv4 and parameters from CGI.pm by nermd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |