- if (($rule->{nbdport} && $rule->{nbdport} > 1) ||
- ($rule->{nbsport} && $rule->{nbsport} > 1)) {
- $cmd .= " --match multiport"
- }
+ my $multiport = 0;
+ $multiport++ if $rule->{nbdport} && ($rule->{nbdport} > 1);
+ $multiport++ if $rule->{nbsport} && ($rule->{nbsport} > 1);
+
+ $cmd .= " --match multiport" if $multiport;
+
+ die "multiport: option '--sports' cannot be used together with '--dports'\n"
+ if ($multiport == 2) && ($rule->{dport} ne $rule->{sport});