rendered paste body[root@tick ~]# cat /usr/local/bin/show-spurious-listeners
#!/usr/bin/perl -w
open(NETSTAT, "netstat -tulpen |") or do { print STDERR "couldn't run netstat -tulpen: $!\n" ; exit 2; };
# default config
our @safe_local_ips = qw/127.0.0.1 192.168.0.1 192.168.0.2 192.168.3.1 192.168.3.2/;
our @safe_local_ports = (0..1024,5900..6100);
our @safe_progs = qw/mlnet/;
do "/etc/spurious-listeners.conf";
my $exitcode=1;
while (<NETSTAT>) {
my ($prot,$lip,$lpt,$rip,$rpt,$state,$user,$inode,$pid,$pgname) =
m!^(.*?)\s+.*?\s+.*?\s+(.*?):([^:]*?)\s+(.*?):([^:]*?)\s+(.*?)\s+(.*?)\s+(.*?)\s+(.*?)/(.*)! or next;
$pgname =~ s/\s*$//;
next if grep {$_ == $lpt} @safe_local_ports
or grep {$_ eq $pgname} @safe_progs
or grep {$_ eq $lip} @safe_local_ips;
print;
$exitcode=0;
}
close(NETSTAT);
exit $exitcode;
[root@tick ~]#
[root@tick ~]#
[root@tick ~]# cat /etc/spurious-listeners.conf
@safe_local_ips = qw/127.0.0.1 192.168.142.1 192.168.142.2 192.168.3.1 192.168.3.2/;
@safe_local_ports = (0..1024,2049,7080,5900..6100,9080,9999);
@safe_progs = qw/mlnet mutella mtr python dnsmasq/;
[root@tick ~]#