aboutsummaryrefslogtreecommitdiffstats
path: root/examples/historical/dlink-ng/dlink-ng-config.pm.dist
blob: 82abbf60c3b2945ed7b11818fd6063c07ad2f251 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/usr/bin/perl
use strict;
use warnings;
no warnings 'closure'; # remove "Variable $foo will not stay shared" :-D
package dlinkng::config;

# Common config
our $domain_name = ".net.party.bylan.net";	# DNS-name to append to hostnames (overriden later on for TG-mode)
our $dlink_def_user = "admin";			# Default user for a factory-default D-Link
our $dlink_def_ip = "10.90.90.90";		# IP for a factory-default D-Link
our $dlink_def_mask = "255.255.255.0";		# Mask for a factory-default D-Link
our $dlink_router_ip = "10.90.90.91";		# IP to use on the router/core
our $dlink_prefix = "30";			# Prefix to use when setting D-Link IP
our $dhcp4_proxyprofile = "DHCPv4Proxy";	# DHCPv4 proxy profile to use on IOS-XR
our $dhcp6_proxyprofile = "DHCPv6Proxy";	# DHCPv6 proxy profile to use on IOS-XR
our $vrf_prefix = "dlink";			# What to prefix the VRF-number (Thread ID) with
our $max_threads = 1;				# Max threads to use
our $dlink_host_suffix = "_DGS-3100";		# Suffix for hostname on the D-Link switches (needed by NMS)
our $default_coreswos = "ios";			# Default OS on coresw
our $dlink_lacp_start = '45';			# First port for LACP-group on D-Links
our $dlink_lacp_end = '48';			# Last port for LACP-group on D-Links
our $configure_last_port = 0;			# Configure last port differently than the rest
our $last_port_regex = '^e([1-8][1-9]|[2-8][0-9])-';	# Regex to use in combination with $configure_last_port
our $use_ssh_cisco = 0;				# Use SSH towards Cisco-boxes
our $use_ssh_dlink = 0;				# Use SSH towards D-Link switches
our $cdp_enable = 0;				# Enable or disable CDP on each port
our $save_config = 1;				# Save configuration to Cisco switch			
our $access_vlan = '3602';			# VLAN to use for last port

# Specific config -- just declare empty
our $cisco_user = "";				# Username used when logging into the swithces
our $cisco_pass = "";				# Password used when logging into the switches
our $dhcprelay4_pri = "";			# Primary ip helper-address / ip dhcp relay address
our $dhcprelay4_sec = "";			# Secondary ip helper-address / ip dhcp relay address
our $dhcprelay6_pri = "";			# Primary ipv6 dhcp relay
our $dhcprelay6_sec = "";			# Secondary ipv6 dhcp relay
our $log_dir = "";				# Path to logfiles

# Placeholders, setting them after all config loaded
our ($po_config, $last_port_config, $os_regex, $os_info);

# Set variables that relies on all config being loaded
sub set_variables{
	# Custom Portchannel-config
	$po_config = {
		ios => [
			"ip directed-broadcast 2699",
			"ip pim sparse-mode",
			"ip pim bsr-border",
			"logging event link-status",
			"ipv6 nd other-config-flag",
			"ipv6 dhcp server sexdhcp",
		],
		nx => [
			"",
		],
		xr => [
			"logging events link-status",
			"ipv4 directed-broadcast",
			"ipv6 nd prefix default 300 300 no-autoconfig",
			"ipv6 nd other-config-flag",
			"ipv6 nd managed-config-flag",
		],
	};

	# Custom last port config
	$last_port_config = {
		ios => [
			"logging event link-status",
			"switchport mode access",
			"switchport access vlan $access_vlan",
			"spanning-tree bpduguard enable",
		],
		nx => [
			"",
		],
		xr => [
			"",
		],
	};

	# Define what OS-version a coresw runs
	# NX, XR, XE, etc
	# The regex is matched against $coreswip
	$os_regex = {
		ios => 'iosbox',
		nx => 'flexusnexus',
		xr => 'c01',
	};

	# Configure settings for each OS
	$os_info = {
		ios => {
			max_sessions => 10,
		},
		nx => {
			# define 64 sessions on nxos
			# nx-os# conf t
			# nx-os(config)# feature dhcp
			# nx-os(config)# line vty
			# nx-os(config-line)# session-limit 64
			max_sessions => 50,
		},
		xr => {
			# telnet vrf default ipv4 server max-servers 100 access-list MGNTv4
			# telnet vrf default ipv6 server max-servers 100 access-list MGNTv6
			max_sessions => 50,
		},
	};
}

# Load ByLAN related configuration
sub load_bylan_config{
	# Define bylan-dir, and add it to %INC
	my $bylan_dir;
	BEGIN {
		use FindBin;
		$bylan_dir = "$FindBin::Bin"; # Assume working-folder is the path where this script resides
	}
	use lib $bylan_dir;
	eval "use bylan";
	use Getopt::Long;
	
	# Load config
	my $config_file = "$bylan_dir/bylan.conf";
	my $conf = Config::General->new(
		-ConfigFile => $config_file,
		-InterPolateVars => 1);
	my %config = $conf->getall;
	
	# Options
	$cisco_user = "$config{switches}->{user}";		# Username used when logging into the swithces
	$cisco_pass = "$config{switches}->{pw}";		# Password used when logging into the switches
	$dhcprelay4_pri = "$config{servers}->{dhcp1_ipv4}";	# Primary ip helper-address / ip dhcp relay address
	$dhcprelay4_sec = "$config{servers}->{dhcp2_ipv4}";	# Secondary ip helper-address / ip dhcp relay address
	$dhcprelay6_pri = "$config{servers}->{dhcp1_ipv6}";	# Primary ipv6 dhcp relay
	$dhcprelay6_sec = "$config{servers}->{dhcp2_ipv6}";	# Secondary ipv6 dhcp relay
	$log_dir = "$bylan_dir/logs/telnet";			# Path to logfiles
}

# Load TG related configuration
sub load_tg_config{
	my $tg_dir;
	BEGIN {
		$tg_dir = '/root/tgmanage';
		require "$tg_dir/include/config.pm";
	        eval {
	                require "$tg_dir/include/config.local.pm";
	        };
	}

	# Options
	$cisco_user = "$nms::config::ios_user";		# Username used when logging into the swithces
	$cisco_pass = "$nms::config::ios_pass";		# Password used when logging into the switches
	$domain_name = ".infra.$nms::config::tgname.gathering.org";	# DNS-name to append to hostnames
	$dhcprelay4_pri = "$nms::config::dhcp_server1";	# Primary ip helper-address / ip dhcp relay address
	$dhcprelay4_sec = "$nms::config::dhcp_server2";	# Secondary ip helper-address / ip dhcp relay address
	$log_dir = "$tg_dir/dlink-ng/log";		# Path to logfiles	
}

# Uncomment the one you want
#load_bylan_config();
#load_tg_config();

# Set last variables that depend on the config above being set
set_variables();


1;