summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Thormodsrud <stig@io.vyatta.com>2008-10-31 14:23:43 -0700
committerStig Thormodsrud <stig@io.vyatta.com>2008-10-31 14:23:43 -0700
commit69153fc9f6dcaa59e95847214fbab18f43992682 (patch)
treed690831b6dde0db8c99826bf281242c9d3b23630
parentb83d5949749c5bceceefcd1dbe53fb5ee596089b (diff)
downloadvyatta-nat-69153fc9f6dcaa59e95847214fbab18f43992682.tar.gz
vyatta-nat-69153fc9f6dcaa59e95847214fbab18f43992682.zip
Fix "show nat translation monitor" to work with both snat & dnat.
-rwxr-xr-xscripts/vyatta-nat-translations.pl18
-rw-r--r--templates-op/show/nat/translations/monitor/detail/node.def4
-rw-r--r--templates-op/show/nat/translations/monitor/node.def4
3 files changed, 25 insertions, 1 deletions
diff --git a/scripts/vyatta-nat-translations.pl b/scripts/vyatta-nat-translations.pl
index abd5f5c..d156df8 100755
--- a/scripts/vyatta-nat-translations.pl
+++ b/scripts/vyatta-nat-translations.pl
@@ -33,7 +33,7 @@ use strict;
my $dump = 0;
my ($xml_file, $verbose, $proto, $stats, $ipaddr, $pipe);
-my $mode='both';
+my $mode;
my $verbose_format = "%-20s %-18s %-20s %-18s\n";
my $format = "%-20s %-20s %-4s %-4s %-8s";
@@ -61,6 +61,18 @@ sub print_xml {
print Dumper($data);
}
+sub guess_snat_dnat {
+ my ($src, $dst) = @_;
+
+ if ($src->{original} eq $dst->{reply}) {
+ return "dnat";
+ }
+ if ($dst->{original} eq $src->{reply}) {
+ return "snat";
+ }
+ return "unkn";
+}
+
sub nat_print_xml {
my ($data, $mode) = @_;
@@ -116,6 +128,9 @@ sub nat_print_xml {
if (defined $verbose) {
printf($verbose_format, $in_src, $in_dst, $out_src, $out_dst);
}
+ if (! defined $mode) {
+ $mode = guess_snat_dnat(\%src, \%dst);
+ }
if (defined $mode) {
my ($from, $to);
if ($mode eq 'snat') {
@@ -222,6 +237,7 @@ if (defined $xml_file) {
} else {
$proto = "";
}
+ $mode = 'both' if ! defined $mode;
if ($mode eq 'both' or $mode eq 'snat') {
my $ipopt = "";
if (defined $ipaddr) {
diff --git a/templates-op/show/nat/translations/monitor/detail/node.def b/templates-op/show/nat/translations/monitor/detail/node.def
new file mode 100644
index 0000000..e96aa6f
--- /dev/null
+++ b/templates-op/show/nat/translations/monitor/detail/node.def
@@ -0,0 +1,4 @@
+help: Show active NAT translations events verbose
+run: LESSOPEN=cat
+ echo Type control-C to quit
+ sudo /usr/sbin/conntrack -E -n -g -o xml | ${vyatta_bindir}/sudo-users/vyatta-nat-translations.pl --pipe --verbose \ No newline at end of file
diff --git a/templates-op/show/nat/translations/monitor/node.def b/templates-op/show/nat/translations/monitor/node.def
new file mode 100644
index 0000000..ed8786f
--- /dev/null
+++ b/templates-op/show/nat/translations/monitor/node.def
@@ -0,0 +1,4 @@
+help: Show active NAT translations events
+run: LESSOPEN=cat
+ echo Type control-C to quit
+ sudo /usr/sbin/conntrack -E -n -g -o xml | ${vyatta_bindir}/sudo-users/vyatta-nat-translations.pl --pipe