From 83234bc6a31775c0c750e2d90176673dd8b5f3c8 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Sun, 10 Jun 2018 22:03:01 +0200 Subject: T588: remove the old DNS forwarding op mode script. --- scripts/vyatta-op-dns-forwarding.pl | 350 ------------------------------------ 1 file changed, 350 deletions(-) delete mode 100755 scripts/vyatta-op-dns-forwarding.pl diff --git a/scripts/vyatta-op-dns-forwarding.pl b/scripts/vyatta-op-dns-forwarding.pl deleted file mode 100755 index ae72b37..0000000 --- a/scripts/vyatta-op-dns-forwarding.pl +++ /dev/null @@ -1,350 +0,0 @@ -#!/usr/bin/perl -# -# Module: vyatta-op-dns-forwarding.pl -# -# **** License **** -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# This code was originally developed by Vyatta, Inc. -# Portions created by Vyatta are Copyright (C) 2008 Vyatta, Inc. -# All Rights Reserved. -# -# Author: Mohit Mehta -# Date: August 2008 -# Description: Script to execute op-mode commands for DNS forwarding -# -# **** End License **** -# - -use lib "/opt/vyatta/share/perl5/"; -use Getopt::Long; -use Vyatta::Config; -use strict; -use warnings; - -my $show_stats_output=""; -my $show_nameservers_output=""; -my $dnsmasq_log='/var/log/dnsmasq.log'; - -sub get_cache_stats { - my ($cache_size, $queries_forwarded, $queries_answered_locally, $entries_inserted, $entries_removed); - - my $grepped_line = `grep 'cache size' $dnsmasq_log`; - my @split_line = split(/\s+/, $grepped_line); - my @temp_split = split(/,/, $split_line[6]); - $cache_size = $temp_split[0]; - @temp_split = split(/\//, $split_line[7]); - $entries_removed = $temp_split[0]; - $entries_inserted = $temp_split[1]; - - $grepped_line = `grep 'queries forwarded' $dnsmasq_log`; - @split_line = split(/\s+/, $grepped_line); - @temp_split = split(/,/, $split_line[6]); - $queries_forwarded = $temp_split[0]; - $queries_answered_locally = $split_line[10]; - - $show_stats_output .= "----------------\n"; - $show_stats_output .= "Cache statistics\n"; - $show_stats_output .= "----------------\n"; - $show_stats_output .= "Cache size: $cache_size\n"; - $show_stats_output .= "Queries forwarded: $queries_forwarded\n"; - $show_stats_output .= "Queries answered locally: $queries_answered_locally\n"; - $show_stats_output .= "Total DNS entries inserted into cache: $entries_inserted\n"; - $show_stats_output .= "DNS entries removed from cache before expiry: $entries_removed\n"; - -} - -sub get_nameserver_stats { - - $show_stats_output .= "\n---------------------\n"; - $show_stats_output .= "Nameserver statistics\n"; - $show_stats_output .= "---------------------\n"; - - #To show overridden domain servers seperately, we need to compare IPs - #configured for the domain overrides in the config with the stats. - - my $vyatta_config = new Vyatta::Config; - $vyatta_config->setLevel("service dns forwarding"); - - my @domains = $vyatta_config->listOrigNodes("domain"); - my @domain_servers_list; - - #build a list of servers that are overriding global nameservers - if (@domains) { - foreach my $domain (@domains) { - push(@domain_servers_list, $vyatta_config->returnOrigValue("domain $domain server")); - } - } - my $found_overrides = 0; - my $show_stats_overrides; - my @grepped_lines = `grep ': server' $dnsmasq_log`; - foreach my $lines (@grepped_lines) { - my @each_line = split(/\s+/, $lines); - my $nameserver_word = $each_line[5]; - my @nameserver_split = split(/#/, $nameserver_word); - my $nameserver = $nameserver_split[0]; - my $queries_sent_word = $each_line[8]; - my @queries_sent_split = split(/,/, $queries_sent_word); - my $queries_sent = $queries_sent_split[0]; - my $queries_retried_failed = $each_line[12]; - - if (grep {$_ eq $nameserver}@domain_servers_list) { - if (!$found_overrides) { - $found_overrides = 1; - $show_stats_overrides .= "\nDomain Override Servers\n\n"; - } - $show_stats_overrides .= "Server: $nameserver\nQueries sent: $queries_sent\nQueries retried or failed: $queries_retried_failed\n\n"; - } else { - $show_stats_output .= "Server: $nameserver\nQueries sent: $queries_sent\nQueries retried or failed: $queries_retried_failed\n\n"; - } - } - if (defined($show_stats_overrides)) { - $show_stats_output .= $show_stats_overrides; - } -} - -sub print_stats { - print $show_stats_output; -} - -sub get_dns_nameservers { - my $vyatta_config = new Vyatta::Config; - - $vyatta_config->setLevel("service dns forwarding"); - my $use_system_nameservers = $vyatta_config->existsOrig("system"); - my @use_dhcp_nameservers = $vyatta_config->returnOrigValues("dhcp"); - my @use_nameservers = $vyatta_config->returnOrigValues("name-server"); - my @resolv_conf_nameservers = `grep "^nameserver" /etc/resolv.conf`; - my @dnsmasq_conf_nameservers = `grep "server=" /etc/dnsmasq.d/vyos.conf`; - my @dnsmasq_running = `ps ax | grep dnsmasq | grep -v grep`; - - if (!(defined $use_system_nameservers) && (@use_dhcp_nameservers == 0) && (@use_nameservers == 0)) { - - # no specific nameservers specified under DNS forwarding, so dnsmasq is getting nameservers from /etc/resolv.conf - - if (! @resolv_conf_nameservers > 0){ - $show_nameservers_output .= "No DNS servers present to forward queries to.\n"; - if (! @dnsmasq_running > 0){ - $show_nameservers_output .= "DNS forwarding has not been configured either.\n"; - } - } else { - if (! @dnsmasq_running > 0){ - $show_nameservers_output .= "\n**DNS forwarding has not been configured**\n\n"; - } - $show_nameservers_output .= "-----------------------------------------------\n"; - if ( @dnsmasq_running > 0){ - $show_nameservers_output .= " Nameservers configured for DNS forwarding\n"; - } else { - $show_nameservers_output .= " Nameservers NOT configured for DNS forwarding\n"; - } - $show_nameservers_output .= "-----------------------------------------------\n"; - foreach my $line (@resolv_conf_nameservers) { - my @split_line = split(/\s+/, $line); - my $nameserver = $split_line[1]; - my $nameserver_via = "system"; - if (@split_line > 2) { - my @dhclient_resolv_files = `ls /etc/resolv.conf.dhclient-new-* 2>/dev/null`; - foreach my $each_dhcp_resolv_conf (@dhclient_resolv_files) { - my @ns_dhclient_resolv=`grep "$nameserver\$" $each_dhcp_resolv_conf`; - if ( @ns_dhclient_resolv > 0) { - my @dhclient_file_array = split(/-/, $each_dhcp_resolv_conf); - $nameserver_via = $dhclient_file_array[2]; - chomp $nameserver_via; - $nameserver_via = 'dhcp ' . $nameserver_via; - } - } - # check here if nameserver_via is still system, if yes then search /etc/ppp/resolv-interface.conf - if ($nameserver_via eq "system") { - my @ppp_resolv_files = `ls /etc/ppp/resolv-*conf 2>/dev/null`; - foreach my $each_ppp_resolv_conf (@ppp_resolv_files) { - my @ns_ppp_resolv=`grep "$nameserver\$" $each_ppp_resolv_conf`; - if ( @ns_ppp_resolv > 0) { - my @ppp_file_array = split(/-/, $each_ppp_resolv_conf); - @ppp_file_array = split(/\./, $ppp_file_array[1]); - $nameserver_via = $ppp_file_array[0]; - chomp $nameserver_via; - $nameserver_via = 'ppp ' . $nameserver_via; - } - } - } - } - $show_nameservers_output .= "$nameserver available via '$nameserver_via'\n"; - } - } - $show_nameservers_output .= "\n"; - } else { - - # nameservers specified under DNS forwarding, so dnsmasq getting nameservers from /etc/dnsmasq.conf - - my @active_nameservers; - my $active_nameserver_count = 0; - $show_nameservers_output .= "-----------------------------------------------\n"; - $show_nameservers_output .= " Nameservers configured for DNS forwarding\n"; - $show_nameservers_output .= "-----------------------------------------------\n"; - my $show_nameservers_output_dhcp; - my $show_nameservers_output_domain; - my $show_nameservers_output_nameserver; - - my $line_flag; - ## server=/test.com/1.1.1.1 - foreach my $line (@dnsmasq_conf_nameservers) { - my @split_line = split(/=/, $line); - my @nameserver_array = split(/\s+/, $split_line[1]); - my $nameserver = $nameserver_array[0]; - my $domain; - my @domain_tokens; - - if ($nameserver_array[2] eq "domain-override") - { - #$nameserver has /test.com/1.1.1.1, seperate it. - @domain_tokens = split(/\//, $nameserver); - if (!defined($line_flag)) { - $line_flag = 1; - $show_nameservers_output_domain .= "\n"; - $show_nameservers_output_domain .= "Domain Overrides:\n"; - $show_nameservers_output_domain .= "\n"; - } - } - $active_nameservers[$active_nameserver_count] = $nameserver; - $active_nameserver_count++; - my $nameserver_via = $nameserver_array[2]; - if (@nameserver_array > 3){ - my $dhcp_interface = $nameserver_array[3]; - $show_nameservers_output_dhcp .= "$nameserver available via '$nameserver_via $dhcp_interface'\n"; - } elsif (@domain_tokens) { - $show_nameservers_output_domain .= "$domain_tokens[1] uses $domain_tokens[2]\n"; - } else { - $show_nameservers_output_nameserver .= "$nameserver available via '$nameserver_via'\n"; - } - } - if (defined ($show_nameservers_output_nameserver)) { - $show_nameservers_output .= $show_nameservers_output_nameserver; - } - if (defined ($show_nameservers_output_dhcp)) { - $show_nameservers_output .= $show_nameservers_output_dhcp; - } - if (defined ($show_nameservers_output_domain)) { - $show_nameservers_output .= $show_nameservers_output_domain ; - } - - # then you need to get nameservers from /etc/resolv.conf that are not in dnsmasq.conf to show them as inactive - - my $active_dnsmasq_nameserver; - my $output_inactive_nameservers = 0; - foreach my $resolv_conf_line (@resolv_conf_nameservers) { - my @resolv_conf_split_line = split(/\s+/, $resolv_conf_line); - my $resolv_conf_nameserver = $resolv_conf_split_line[1]; - $active_dnsmasq_nameserver = 0; - my $resolv_nameserver_via = "system"; - foreach my $dnsmasq_nameserver (@active_nameservers) { - if ($dnsmasq_nameserver eq $resolv_conf_nameserver) { - $active_dnsmasq_nameserver = 1; - } - } - if ($active_dnsmasq_nameserver == 0) { - if ($output_inactive_nameservers == 0){ - $output_inactive_nameservers = 1; - $show_nameservers_output .= "\n-----------------------------------------------\n"; - $show_nameservers_output .= " Nameservers NOT configured for DNS forwarding\n"; - $show_nameservers_output .= "-----------------------------------------------\n"; - } - if (@resolv_conf_split_line > 2) { - my @dhclient_resolv_files = `ls /etc/resolv.conf.dhclient-new-* 2>/dev/null`; - foreach my $each_dhcp_resolv_conf (@dhclient_resolv_files) { - chomp $each_dhcp_resolv_conf; - my @ns_dhclient_resolv=`grep "$resolv_conf_nameserver\$" $each_dhcp_resolv_conf`; - if ( @ns_dhclient_resolv > 0) { - my @dhclient_file_array = split(/-/, $each_dhcp_resolv_conf); - $resolv_nameserver_via = $dhclient_file_array[2]; - chomp $resolv_nameserver_via; - $resolv_nameserver_via = 'dhcp ' . $resolv_nameserver_via; - } - } - # check here if resolv_nameserver_via is still system, if yes then search /etc/ppp/resolv-interface.conf - if ($resolv_nameserver_via eq "system") { - my @ppp_resolv_files = `ls /etc/ppp/resolv-*conf 2>/dev/null`; - foreach my $each_ppp_resolv_conf (@ppp_resolv_files) { - my @ns_ppp_resolv=`grep "$resolv_conf_nameserver\$" $each_ppp_resolv_conf`; - if ( @ns_ppp_resolv > 0) { - my @ppp_file_array = split(/-/, $each_ppp_resolv_conf); - @ppp_file_array = split(/\./, $ppp_file_array[1]); - $resolv_nameserver_via = $ppp_file_array[0]; - chomp $resolv_nameserver_via; - $resolv_nameserver_via = 'ppp ' . $resolv_nameserver_via; - } - } - } - } - - $show_nameservers_output .= "$resolv_conf_nameserver available via '$resolv_nameserver_via'\n"; - } - } - $show_nameservers_output .= "\n"; - } -} - -sub print_nameservers { - print $show_nameservers_output; -} - -sub wait_for_write { - - my $last_size = (stat($dnsmasq_log))[7]; - my $cnt=0; - while(1) { - system("usleep 10000"); # sleep for 0.01 second - my $curr_size = (stat($dnsmasq_log))[7]; - if( $curr_size == $last_size ) { - # Not modified - $cnt++; - last if($cnt > 1); - } else { - # Modified\n - $cnt=0; - } - $last_size = $curr_size; - } - -} - -# -# main -# -my ($clear_cache, $clear_all, $show_statistics, $show_nameservers); - -GetOptions("clear-cache!" => \$clear_cache, - "clear-all!" => \$clear_all, - "show-statistics!" => \$show_statistics, - "show-nameservers!" => \$show_nameservers); - -if (defined $clear_cache) { - system("kill -1 `pidof dnsmasq`"); -} - -if (defined $clear_all) { - system("/etc/init.d/dnsmasq restart >&/dev/null"); -} - -if (defined $show_statistics) { - system("echo > $dnsmasq_log; kill -10 `pidof dnsmasq`"); - wait_for_write; - get_cache_stats; - get_nameserver_stats; - print_stats; -} - -if (defined $show_nameservers) { - get_dns_nameservers; - print_nameservers; -} - -exit 0; - -# end of file -- cgit v1.2.3 From 98c47096b1b008066963b8e99ce792f0f5127345 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Sun, 10 Jun 2018 22:14:06 +0200 Subject: Related to T689: update the show tech-support scripts. Remove references to Vyatta. Remove all references to serial WAN interfaces: not supported since forever. Remove references to IPS, also not supported since forever. Update configuration path for NAT. Do not try to check if VRRP is configured since it can be inside VIFs, the old check was incomplete. --- functions/tech-support | 111 ++++--------------------------------------- functions/tech-support-brief | 2 +- 2 files changed, 11 insertions(+), 102 deletions(-) diff --git a/functions/tech-support b/functions/tech-support index e4602d2..5c619d6 100755 --- a/functions/tech-support +++ b/functions/tech-support @@ -75,7 +75,7 @@ header Entitlement show entitlement fi -header Vyatta Version and Package Changes +header VyOS Version and Package Changes show version all header Configuration File @@ -104,12 +104,12 @@ header Ethernet header Interface statistics ip -s link show -for eth in $(/opt/vyatta/sbin/vyatta-interfaces.pl --show=ethernet) +for eth in $(${vyos_completion_dir}/list_interfaces.py --type=ethernet) do header "Physical Interface statistics for $eth" sudo ethtool -S $eth done -for eth in $(/opt/vyatta/sbin/vyatta-interfaces.pl --show=ethernet) +for eth in $(${vyos_completion_dir}/list_interfaces.py --type=ethernet) do header "Physical Interface Details for $eth" show interfaces ethernet $eth physical /sbin/ethtool -k $eth @@ -123,83 +123,12 @@ show arp | grep incomplete | wc -l header Bridge /sbin/brctl show -for br in $(/opt/vyatta/sbin/vyatta-interfaces.pl --show=bridge) +for br in $(${vyos_completion_dir}/list_interfaces.py --type=bridge) do header "Bridge Information for $br" /sbin/brctl showstp $br /sbin/brctl showmacs $br done -header Serial - -header "WAN Interface Hardware Information (wanrouter hwprobe)" -is_sangoma='lspci -n -d '1923:*'' -is_adsl='lspci -n -d '14bc:*'' -if [ -z "$is_sangoma" -a -z "$is_adsl" ]; then - - sudo wanrouter hwprobe - -header "WAN Interface Software Version (wanrouter version)" -wanrouter version - -header "WAN Interface Debugging Information (wanrouter debug)" -wanrouter debug - -header "WAN Interface Connection Status Information (wanrouter summary)" -wanrouter summary - -header "WAN Interface Information Summary (wanrouter status)" -wanrouter status - -header "WAN Interface Driver Information (wanrouter modules)" -wanrouter modules - -if [ -e /etc/wanpipe/wanrouter.rc ]; then - header "WAN Interface Startup Script (/etc/wanpipe/wanrouter.rc)" - cat /etc/wanpipe/wanrouter.rc -fi - -header WAN Interfaces -wanifs=( /sys/class/net/wan* ) -wanifs=`echo -n ${wanifs[@]##*/}` - -echo "wanifs are $wanifs" - -for ifname in $wanifs ; do - header "wanpipemon -i $ifname -c sc" - sudo wanpipemon -i $ifname -c sc - - header "wanpipemon -i $ifname -c so" - sudo wanpipemon -i $ifname -c so - - header "wanpipemon -i $ifname -c xcv" - sudo wanpipemon -i $ifname -c xcv - - header "wanpipemon -i $ifname -c xru" - sudo wanpipemon -i $ifname -c xru - - header "wanpipemon -i $ifname -c xm" - sudo wanpipemon -i $ifname -c xm - - header "wanpipemon -i $ifname -c xl" - sudo wanpipemon -i $ifname -c xl - - header "wanpipemon -i $ifname -c Ta" - sudo wanpipemon -i $ifname -c Ta -done - -for i in /etc/wanpipe/wanpipe*.conf ; do - if [ -e $i ]; then - header $i - cat $i - fi -done - -header "WAN Interface Configuration Log (wanrouter conflog)" -wanrouter conflog - -else -echo "Wanpipe not configured" -fi header ROUTING @@ -465,16 +394,6 @@ else echo "Firewall is not configured" fi -header IPS -if cli-shell-api existsActive content-inspection; then - header IPS log - show ips log - header IPS Update-Log - show ips update-log -else - echo "IPS is not configured" -fi - header IPSec if cli-shell-api existsActive vpn ipsec; then header IPSec Status @@ -498,7 +417,7 @@ else fi header NAT -if cli-shell-api existsActive service nat; then +if cli-shell-api existsActive nat; then header NAT Rules show nat rules header NAT Statistics @@ -510,12 +429,11 @@ else fi -header NETFLOW -if cli-shell-api existsActive system flow-accounting netflow; then - header NetFlow Accounting +header FlowAccounting +if cli-shell-api existsActive system flow-accounting; then show flow-accounting else - echo "Netflow is not configured" + echo "Flow accounting is not configured" fi header OPENVPN @@ -618,17 +536,8 @@ else fi header VRRP -found=0 -for eth in $(cd /sys/class/net; echo eth*); do - if cli-shell-api existsActive interfaces ethernet $eth vrrp; then - header \''show vrrp'\' - show vrrp - found=1 - fi -done -if [ $found -eq 0 ]; then - echo "VRRP is not configured" -fi +# XXX: not checking if configured, we'd have to walk all VIFs +show vrrp detail header WAN LOAD BALANCING if cli-shell-api existsActive load-balancing wan; then diff --git a/functions/tech-support-brief b/functions/tech-support-brief index 998adaf..6035d4a 100755 --- a/functions/tech-support-brief +++ b/functions/tech-support-brief @@ -71,7 +71,7 @@ header Show Tech-Support Brief header CONFIGURATION -header Vyatta Version and Package Changes +header VyOS Version and Package Changes show version all header Running configuration -- cgit v1.2.3