Skip to content

Commit

Permalink
Update netflow kernel module to use the correct ip address
Browse files Browse the repository at this point in the history
  • Loading branch information
fdurand committed Feb 2, 2023
1 parent be37608 commit 76a7676
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions conf/pf.conf.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,12 @@ tracking-config_binary=/dev/null
# NetFlow Address
netflow_address=0.0.0.0

#
# services.netflow_target_host_port
#
# NetFlow Target Host Port
netflow_target_host_port=[% ENV.env_or_default("NETFLOW_TARGET_HOST_PORT", "containers-gateway.internal:2056") %]

#
# services.mysql-probe
#
Expand Down
11 changes: 10 additions & 1 deletion lib/pf/cmd/pf/confignetflow.pm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ use pf::util;
use pf::log;
use Symbol 'gensym';
use IPC::Open3;
use Socket;
use Net::IP;
our $IPT_NETFLOW_VERSION;
our $os = pf::util::os_detection();
if ($os eq 'rhel') {
Expand Down Expand Up @@ -49,7 +51,14 @@ sub _run {
system("/usr/sbin/dkms", "-q", "install", "-m", "ipt-netflow", "-v", $IPT_NETFLOW_VERSION);
system("/sbin/modprobe", "ipt_NETFLOW");
local $SIG{PIPE} = sub {};
$pid = open3('>&STDIN', '>&STDOUT', $stderr = gensym,'/sbin/sysctl',"net.netflow.destination=$Config{services}{netflow_address}:$Config{ports}{pfacct_netflow}");
my @destination = split(':',$Config{services}{netflow_target_host_port});
my $destination_ip;
if (Net::IP::ip_is_ipv4($destination[0])) {
$destination_ip = $destination[0];
} else {
$destination_ip = inet_ntoa(inet_aton($destination[0]));
}
$pid = open3('>&STDIN', '>&STDOUT', $stderr = gensym,'/sbin/sysctl',"net.netflow.destination=$destination_ip:$destination[1]");
waitpid($pid, 0);
$child_exit_status = $? >> 8;
if ($child_exit_status) {
Expand Down
2 changes: 1 addition & 1 deletion packetfence.modprobe
Original file line number Diff line number Diff line change
@@ -1 +1 @@
options ipt_NETFLOW destination=127.0.0.1:2056
options ipt_NETFLOW destination=100.64.0.1:2056

0 comments on commit 76a7676

Please sign in to comment.