| 1 |  | 
|---|
| 2 | # | 
|---|
| 3 | # | 
|---|
| 4 | #  aug 2002, jasper\@WirelessLeiden.NL | 
|---|
| 5 | # | 
|---|
| 6 |  | 
|---|
| 7 |  | 
|---|
| 8 | $now=localtime($unow=time()); | 
|---|
| 9 |  | 
|---|
| 10 | $config='/etc/wl/wleiden.conf'; | 
|---|
| 11 | $domain='wLeiden.NET'; | 
|---|
| 12 |  | 
|---|
| 13 | $ifconfig='/sbin/ifconfig'; | 
|---|
| 14 | $iwconfig='/sbin/iwconfig'; | 
|---|
| 15 | $ipchains='/sbin/ipchains'; | 
|---|
| 16 | $indexmaker='/usr/bin/indexmaker'; | 
|---|
| 17 | $sroute='/sbin/route'; | 
|---|
| 18 | $OSPFPWD='huppel'; | 
|---|
| 19 | $separator=';'; | 
|---|
| 20 | $author='feb 2003 jasper@WirelessLeiden.NL'; | 
|---|
| 21 | $wicontrol='/usr/sbin/wicontrol'; | 
|---|
| 22 |  | 
|---|
| 23 | if ($functions_only) {goto functions;} | 
|---|
| 24 | $source='/etc/wl/wleiden.pl'; | 
|---|
| 25 |  | 
|---|
| 26 | do($config) || die; | 
|---|
| 27 | parse_config(); | 
|---|
| 28 |  | 
|---|
| 29 |  | 
|---|
| 30 | $hostname=`/bin/hostname |cut -d . -f 1`;chomp($hostname); | 
|---|
| 31 | $maxmask= pack("CCCC", 255, 255, 255, 255); | 
|---|
| 32 |  | 
|---|
| 33 |  | 
|---|
| 34 | if (! $ARGV[0]) {die "use start/stop/startall";} | 
|---|
| 35 |  | 
|---|
| 36 | if ($ARGV[1]=~/debug/i) {$DEBUG=1;} | 
|---|
| 37 | if ($ARGV[0]=~/start/i) | 
|---|
| 38 | { | 
|---|
| 39 |  | 
|---|
| 40 | ###################################################################### | 
|---|
| 41 | do_it(); | 
|---|
| 42 |  | 
|---|
| 43 | open_files(); | 
|---|
| 44 | $nwcfg.="$indexmaker /etc/mrtg/mrtg.cfg> /var/www/html/mrtg/index.html 2> /dev/null\n"; | 
|---|
| 45 |  | 
|---|
| 46 | print_files();close_files(); | 
|---|
| 47 |  | 
|---|
| 48 | system("chmod 755 /etc/wl/nwcfg.sh;/etc/wl/nwcfg.sh"); | 
|---|
| 49 |  | 
|---|
| 50 | if ($DEBUG) {die "DEBUGGING!";} | 
|---|
| 51 |  | 
|---|
| 52 | if ($DEBUG) {print "\nDEBUG: making mrtg index.\n";} | 
|---|
| 53 |  | 
|---|
| 54 | changeline("/etc/sysconfig/dhcpd","DHCPDARGS","DHCPDARGS=\"$dhcpints\""); | 
|---|
| 55 |  | 
|---|
| 56 | #if ($DEBUG) {print "\nDEBUG: reloading firewall.\n";} | 
|---|
| 57 | #$nwcfg.="/usr/local/sbin/firewall\n"; | 
|---|
| 58 |  | 
|---|
| 59 | if ($DEBUG) {print "\nDEBUG: restarting daemons.\n";} | 
|---|
| 60 |  | 
|---|
| 61 | if ($ARGV[0]=~/startall/) {$restart='restart';} | 
|---|
| 62 | else  {$restart='condrestart';} | 
|---|
| 63 | $nwcfg.="/etc/init.d/dhcpd $restart\n"; | 
|---|
| 64 | $nwcfg.="/etc/init.d/zebra $restart\n"; | 
|---|
| 65 | $nwcfg.="/etc/init.d/ospfd $restart\n"; | 
|---|
| 66 | $nwcfg.="/etc/init.d/httpd $restart\n"; | 
|---|
| 67 | $nwcfg.="/etc/init.d/named $restart\n"; | 
|---|
| 68 |  | 
|---|
| 69 |  | 
|---|
| 70 | ######################################################################## | 
|---|
| 71 | } else  # geen start -> stop | 
|---|
| 72 | { | 
|---|
| 73 | $nwcfg.="$ifconfig lo:1 down\n"; | 
|---|
| 74 |  | 
|---|
| 75 | foreach $if (keys %config) | 
|---|
| 76 | { | 
|---|
| 77 | $nwcfg.="$ifconfig $if down\n"; | 
|---|
| 78 | } | 
|---|
| 79 | } | 
|---|
| 80 |  | 
|---|
| 81 |  | 
|---|
| 82 | exit; | 
|---|
| 83 |  | 
|---|
| 84 | ######################################################################## | 
|---|
| 85 |  | 
|---|
| 86 | functions: | 
|---|
| 87 |  | 
|---|
| 88 | $ahum=1; | 
|---|
| 89 |  | 
|---|
| 90 | sub do_it | 
|---|
| 91 | { | 
|---|
| 92 | if ($OS=~/FreeBSD/i) {$FreeBSD=1;} | 
|---|
| 93 | elsif ($OS=~/Linux/i) {$Linux=1;} | 
|---|
| 94 |  | 
|---|
| 95 | init_files(); | 
|---|
| 96 |  | 
|---|
| 97 | #system("/sbin/modprobe ipv6"); | 
|---|
| 98 | #system("/sbin/modprobe ipchains"); | 
|---|
| 99 |  | 
|---|
| 100 | $nwcfg.="$ifconfig lo:1 down\n"; | 
|---|
| 101 | #print "ifconfig lo:1 $master_ip\n"; | 
|---|
| 102 | #$nwcfg.="$ifconfig lo:1 $master_ip netmask 255.255.255.255\n"; # altijd up! | 
|---|
| 103 |  | 
|---|
| 104 | $last=''; | 
|---|
| 105 | foreach $if (sort {$b <=> $a} keys %config) | 
|---|
| 106 | { | 
|---|
| 107 | if ($TYPE{$if}=~/wireless/) {$last=$if} | 
|---|
| 108 | } if ($last) {iwconfig("$last &> /dev/null");} # Laatste het eerste... | 
|---|
| 109 |  | 
|---|
| 110 | $keys=1; | 
|---|
| 111 | foreach $if (sort keys %config) | 
|---|
| 112 | { | 
|---|
| 113 | if ($if=~/^([^:]+):(\d+)/) {$mymain=$1;$mysub=$2;} else {$mymain='';} | 
|---|
| 114 |  | 
|---|
| 115 | if ($functions_only<1) {print "Doing interface: $if IP: $IP{$if}\n";} | 
|---|
| 116 |  | 
|---|
| 117 | if ($if!~/:\d+/) {$main=1;} else {$main=0;} | 
|---|
| 118 |  | 
|---|
| 119 | ##################### DOWN | 
|---|
| 120 | if ($DOWN{$if}=~/yes/) | 
|---|
| 121 | {   print "$if configured DOWN.\n"; | 
|---|
| 122 | $nwcfg.="$ifconfig $if 127.0.0.1 down\n"; | 
|---|
| 123 |  | 
|---|
| 124 | if ($main) | 
|---|
| 125 | { | 
|---|
| 126 | $zebra1.=sprintf <<EOZ3; | 
|---|
| 127 |  | 
|---|
| 128 | interface $if | 
|---|
| 129 | description $DESC{$if} | 
|---|
| 130 | ip address 127.0.0.1/0 | 
|---|
| 131 | shutdown | 
|---|
| 132 |  | 
|---|
| 133 | EOZ3 | 
|---|
| 134 | $ospfd2{$if}.=" interface $if\n\n"; | 
|---|
| 135 | } | 
|---|
| 136 | next;   # Interface down. | 
|---|
| 137 | } | 
|---|
| 138 | ##################### DOWN | 
|---|
| 139 | if ($main) | 
|---|
| 140 | { | 
|---|
| 141 | $if=~/(\d+)/;$ifnum=$1; | 
|---|
| 142 | $nick="${nodename}$ifnum.$domain"; | 
|---|
| 143 |  | 
|---|
| 144 | if ($TYPE{$if}=~/wireless/) | 
|---|
| 145 | { | 
|---|
| 146 |  | 
|---|
| 147 | if ($SDESC{$if}) {$nick="$SDESC{$if}.$nick";} | 
|---|
| 148 | #print "$nick\n"; | 
|---|
| 149 | if (iwconfig("$if mode $MODE{$if}")) | 
|---|
| 150 | { | 
|---|
| 151 | if ($DEBUG) {print "\nDEBUG: iwconfig $if mode $MODE{$if} essid $ESSID{$if} nick $nick ap $AP{$if} channel $CHANNEL{$if} sens $SENS{$if} txpower $TXPOWER{$if} rate $RATE{$if}\n";} | 
|---|
| 152 | iwconfig("$if essid $ESSID{$if}"); | 
|---|
| 153 | iwconfig("$if nick $nick"); | 
|---|
| 154 |  | 
|---|
| 155 | $freebsd.=sprintf<<EOFB33; | 
|---|
| 156 | $wicontrol -i $if -s $nick       # Nickname | 
|---|
| 157 | #$wicontrol -i $if -t 7          # TXrate | 
|---|
| 158 | $wicontrol -i $if -P 0           # PowerSave | 
|---|
| 159 | $wicontrol -i $if -Z             # Zero SNR cache | 
|---|
| 160 | EOFB33 | 
|---|
| 161 | if ($MODE{$if}=~/master/i) | 
|---|
| 162 | { | 
|---|
| 163 | $freebsd.=sprintf<<EOFB3; | 
|---|
| 164 | $wicontrol -i $if -p 6           # hostap mode | 
|---|
| 165 | $wicontrol -i $if -n $ESSID{$if} # network name | 
|---|
| 166 | $wicontrol -i $if -q $ESSID{$if} # ESSID | 
|---|
| 167 | $wicontrol -i $if -c 1           # broadcasting essid on | 
|---|
| 168 | EOFB3 | 
|---|
| 169 | } else { | 
|---|
| 170 | $freebsd.=sprintf<<EOFB4; | 
|---|
| 171 | $wicontrol -i $if -p 1           # Client mode (managed) | 
|---|
| 172 | $wicontrol -i $if -n $ESSID{$if} # ESSID | 
|---|
| 173 | EOFB4 | 
|---|
| 174 | } | 
|---|
| 175 | if ($AP{$if})             {iwconfig("$if ap $AP{$if}");} | 
|---|
| 176 |  | 
|---|
| 177 | if ($MODE{$if}=~/master/) { | 
|---|
| 178 | if ($CHANNEL{$if})  { | 
|---|
| 179 | $freebsd.="$wicontrol -i $if -f $CHANNEL{$if}           # Channel\n"; | 
|---|
| 180 | } else { | 
|---|
| 181 | $freebsd .= "# WARNING  - master but no channel defined.\n"; | 
|---|
| 182 | }; | 
|---|
| 183 | } else { | 
|---|
| 184 | $freebsd.="# No channel - client follows\n# $wicontrol -i $if -f 0              # Channel\n"; | 
|---|
| 185 | } | 
|---|
| 186 |  | 
|---|
| 187 | if ($SENS{$if})           {iwconfig("$if sens $SENS{$if}");} | 
|---|
| 188 | if ($TXPOWER{$if})        {iwconfig("$if txpower $TXPOWER{$if}");} | 
|---|
| 189 | if ($RATE{$if})           {iwconfig("$if rate $RATE{$if}");} | 
|---|
| 190 | } #else { print "ERROR: Could not configure interface $if\n";next;} | 
|---|
| 191 |  | 
|---|
| 192 | $rcconf.="\nifconfig_$if=\"inet $IP{$if} -promisc\"\n"; | 
|---|
| 193 | #$rcconf.="ifconfig_$if=\"inet $IP{$if} -promisc \"\n  ssid $ESSID{$if} \\"\n"; | 
|---|
| 194 | #if ($CHANNEL{$if})        {$rcconf.="  channel $CHANNEL{$if}";} | 
|---|
| 195 | #$rcconf.="\\\n  stationname $nick\"\n"; | 
|---|
| 196 | #if ($MODE{$if}=~/master/)                 {$rcconf.="#mediaopt hostap\n";} | 
|---|
| 197 | #$rcconf.="\n"; | 
|---|
| 198 |  | 
|---|
| 199 | $freebsd.="\n"; | 
|---|
| 200 | } # if wireless | 
|---|
| 201 | mrtg1(); | 
|---|
| 202 | if ($OS=~/FreeBSD/) | 
|---|
| 203 | { | 
|---|
| 204 | $ospfd2{$if}.=sprintf <<EOO2; | 
|---|
| 205 |  | 
|---|
| 206 | interface $if | 
|---|
| 207 | ip ospf message-digest-key 1 md5 $OSPFPWD | 
|---|
| 208 | ip ospf authentication message-digest | 
|---|
| 209 | ip ospf dead-interval 180 | 
|---|
| 210 | EOO2 | 
|---|
| 211 |  | 
|---|
| 212 | $keys++; | 
|---|
| 213 |  | 
|---|
| 214 | $zebra.=sprintf  <<EOZ2; | 
|---|
| 215 |  | 
|---|
| 216 | interface $if | 
|---|
| 217 | description $DESC{$if} | 
|---|
| 218 | no shutdown | 
|---|
| 219 | EOZ2 | 
|---|
| 220 | } | 
|---|
| 221 |  | 
|---|
| 222 | }                     ######################   MAIN | 
|---|
| 223 |  | 
|---|
| 224 | if ($OS=~/Linux/) | 
|---|
| 225 | { | 
|---|
| 226 | $ospfd2{$if}.=sprintf <<EOO21; | 
|---|
| 227 |  | 
|---|
| 228 | interface $if | 
|---|
| 229 | ip ospf message-digest-key 1 md5 $OSPFPWD | 
|---|
| 230 | ip ospf authentication message-digest | 
|---|
| 231 | EOO21 | 
|---|
| 232 | $keys++; | 
|---|
| 233 |  | 
|---|
| 234 | $zebra.=sprintf  <<EOZ21; | 
|---|
| 235 |  | 
|---|
| 236 | interface $if | 
|---|
| 237 | description $DESC{$if} | 
|---|
| 238 | no shutdown | 
|---|
| 239 | EOZ21 | 
|---|
| 240 | } | 
|---|
| 241 |  | 
|---|
| 242 | if ($IP{$if}) | 
|---|
| 243 | { | 
|---|
| 244 | $zebra.=sprintf " ip address $IP{$if}\n"; | 
|---|
| 245 | ($ip,$netmask,$broadcast,$network,$width)=calc_ip($IP{$if}); | 
|---|
| 246 | if ($netmask == '0.0.0.0') | 
|---|
| 247 | {print "Forgot netmask in config $hostname $if: $IP{$if}!\n"; | 
|---|
| 248 | die "Forgot netmask in config $hostname $if: $IP{$if}!\n"; | 
|---|
| 249 | } | 
|---|
| 250 |  | 
|---|
| 251 | #    if ($DEBUG) {print("\nDEBUG: $ifconfig $if $ip netmask $netmask broadcast $broadcast up\n");} | 
|---|
| 252 | if ($DEBUG) {print("\nDEBUG: $if $ip $netmask $network $broadcast\n");} | 
|---|
| 253 |  | 
|---|
| 254 | if (! $main) {$nwcfg.="$ifconfig $mymain up\n";} | 
|---|
| 255 | $nwcfg.="$ifconfig $if $ip down\n"; | 
|---|
| 256 | $nwcfg.="$ifconfig $if $ip netmask $netmask broadcast $broadcast up\n"; | 
|---|
| 257 | if ($main) | 
|---|
| 258 | { | 
|---|
| 259 | if ($TYPE{$if}!~/wireless/) {$rcconf.="\nifconfig_$if=\"inet $IP{$if}\"\n";} | 
|---|
| 260 | } else {$rcconf.="ifconfig_${mymain}_alias${mysub}=\"inet $IP{$if}\"\n";} | 
|---|
| 261 | } | 
|---|
| 262 | if (($OS=~/Linux/) || ($main)) {$zebra.= "\n";} | 
|---|
| 263 |  | 
|---|
| 264 | if ($ROUTE{$if}) | 
|---|
| 265 | { | 
|---|
| 266 | if ($DEBUG) {print "\nDEBUG: ROUTE: $ROUTE{$if}\n";} | 
|---|
| 267 |  | 
|---|
| 268 | foreach $r (split(/$separator/,$ROUTE{$if})) | 
|---|
| 269 | { | 
|---|
| 270 | if ($DEBUG) {print "\nDEBUG: ROUTE2: $r\n";} | 
|---|
| 271 |  | 
|---|
| 272 | $r=~/([^\/ ]+)\/?(\S+)\s+(\S+)/; | 
|---|
| 273 | $R="$1/$2";$gw=$3;$nm=$2; | 
|---|
| 274 | ($route,$r_netmask,$r_broadcast,$r_network,$r_width)=calc_ip($R); | 
|---|
| 275 | if ($R eq '0.0.0.0/0') | 
|---|
| 276 | {   $doit="$sroute add default gw $gw dev $mymain"; | 
|---|
| 277 | $rcconf.="\ndefaultrouter=\"$gw\"\n\n"; | 
|---|
| 278 | } | 
|---|
| 279 | elsif ($nm eq 32)      {$doit="$sroute add $route gw $gw dev $mymain";} | 
|---|
| 280 | else {$doit="$sroute add -net $route netmask $r_netmask gw $gw dev $mymain";} | 
|---|
| 281 |  | 
|---|
| 282 | if ($DEBUG) {print "\nROUTE3: $doit\n";} | 
|---|
| 283 | $nwcfg.="$doit\n"; | 
|---|
| 284 | if ($R eq '0.0.0.0/0') {$ospfd3.=" default-information originate\n"} | 
|---|
| 285 | else | 
|---|
| 286 | { | 
|---|
| 287 | $area=get_area($R); | 
|---|
| 288 | $ospfd4.="! static route $R\nnetwork $R area $area\n\n"; | 
|---|
| 289 | $NW{$area}.="$network/$width "; | 
|---|
| 290 | } | 
|---|
| 291 | $zebra.="ip route $r\n"; | 
|---|
| 292 | } | 
|---|
| 293 | } | 
|---|
| 294 |  | 
|---|
| 295 | ($ip,$netmask,$broadcast,$network,$width)=calc_ip($IP{$if}); | 
|---|
| 296 | if (($DHCP{$if}) && ($DHCP{$if}!~/off|no/i)) | 
|---|
| 297 | { | 
|---|
| 298 | ($from,$upto)=split(/-/,$DHCP{$if}); | 
|---|
| 299 | $ip=~/(^\d+\.\d+\.\d+)\.\d+$/; | 
|---|
| 300 | $dip=$1; | 
|---|
| 301 | $dhcp.=sprintf <<EOD2; | 
|---|
| 302 |  | 
|---|
| 303 | # | 
|---|
| 304 | #  $if $DESC{$if} | 
|---|
| 305 | # | 
|---|
| 306 | subnet $network netmask $netmask { | 
|---|
| 307 | range  $dip.$from $dip.$upto; | 
|---|
| 308 | option broadcast-address $broadcast; | 
|---|
| 309 | option subnet-mask $netmask; | 
|---|
| 310 | option routers $ip; | 
|---|
| 311 | $DHCP_STATIC{$if} | 
|---|
| 312 | } | 
|---|
| 313 |  | 
|---|
| 314 | EOD2 | 
|---|
| 315 | if ($dhcpints!~/$mymain/) {$dhcpints.=" $mymain";} | 
|---|
| 316 | }  # DHCP | 
|---|
| 317 | else | 
|---|
| 318 | { | 
|---|
| 319 | if ( ($main) ) #|| ($DHCP{$mymain}=~/off|no/i)) | 
|---|
| 320 | {  # niet als main wel dhcp heeft. | 
|---|
| 321 | $dhcp.="subnet $network netmask $netmask {not authoritative; } # $if\n\n"; | 
|---|
| 322 | } | 
|---|
| 323 | } | 
|---|
| 324 | if ($OSPF_NEIGHBORS{$if}=~/no/i) | 
|---|
| 325 | { | 
|---|
| 326 | if ($main) {$OSPF_PASSIVE{$if}=1;} | 
|---|
| 327 | } | 
|---|
| 328 |  | 
|---|
| 329 | if ($OSPF_AREA{$if}!~/no/i) | 
|---|
| 330 | { | 
|---|
| 331 | ($ip,$netmask,$broadcast,$network,$width)=calc_ip($IP{$if}); | 
|---|
| 332 |  | 
|---|
| 333 | if ($IP{$if}) | 
|---|
| 334 | { | 
|---|
| 335 | #               if (($OSPF_NEIGHBORS{$if}!~/no/) || | 
|---|
| 336 | if ($OSPF_AREA{$if} eq '') {$area=get_area($network);} | 
|---|
| 337 | else {$area=int($OSPF_AREA{$if});} | 
|---|
| 338 |  | 
|---|
| 339 | $ospfd4.="! $if ($DESC{$if})\nnetwork $network/$width area $area\n\n"; | 
|---|
| 340 | $NW{$area}.="$network/$width "; | 
|---|
| 341 | } | 
|---|
| 342 |  | 
|---|
| 343 | if ($OSPF_BROADCAST{$if}=~/no/i) | 
|---|
| 344 | { | 
|---|
| 345 | if ($main) | 
|---|
| 346 | { | 
|---|
| 347 | #if ($DEBUG) {print "DEBUG: OSPF_NEIGHBORS{$if}: ($OSPF1_NEIGHBORS{$if})\n";} | 
|---|
| 348 | $OSPFD_NONBROADCAST{$if}=1; | 
|---|
| 349 | } | 
|---|
| 350 | if ($OSPF_NEIGHBORS{$if}!~/no/i) | 
|---|
| 351 | { | 
|---|
| 352 | foreach $n (split(/[\s$separator]+/,$OSPF_NEIGHBORS{$if})) | 
|---|
| 353 | { | 
|---|
| 354 | if ($DEBUG) {print "DEBUG: OSPF2_NEIGHBOR{$if}: [$n]\n";} | 
|---|
| 355 | $ospfd5.="! $if link: $SDESC{$if}\n neighbor $n\n\n"; | 
|---|
| 356 | } | 
|---|
| 357 | if ($main) {$OSPF_PASSIVE{$if}=0;} | 
|---|
| 358 | else {$OSPF_PASSIVE{$mymain}=0;} | 
|---|
| 359 | } #ospf_neighbors | 
|---|
| 360 | } | 
|---|
| 361 |  | 
|---|
| 362 | } # ospf_area | 
|---|
| 363 |  | 
|---|
| 364 | if ($POINT_TO_POINT{$if}) | 
|---|
| 365 | { | 
|---|
| 366 | foreach $p (split(/$separator/,$POINT_TO_POINT{$if})) | 
|---|
| 367 | { | 
|---|
| 368 | mrtg2(); | 
|---|
| 369 | } #foreach $pointtopoint | 
|---|
| 370 | } # pointopoint | 
|---|
| 371 | } # foreach if | 
|---|
| 372 |  | 
|---|
| 373 | foreach $if (sort keys %config) | 
|---|
| 374 | { | 
|---|
| 375 | if ($if!~/:\d+/) {$main=1;} else {$main=0;} | 
|---|
| 376 | if ($main) | 
|---|
| 377 | { | 
|---|
| 378 | $ospfd2.=$ospfd2{$if}; | 
|---|
| 379 | if ($OSPF_PASSIVE{$if}) | 
|---|
| 380 | { | 
|---|
| 381 | $ospfd22.=" passive-interface $if\n"; | 
|---|
| 382 | } | 
|---|
| 383 | if ($OSPFD_NONBROADCAST{$if}) | 
|---|
| 384 | { | 
|---|
| 385 | $ospfd2.= " ip ospf network non-broadcast\n"; | 
|---|
| 386 | } | 
|---|
| 387 | if ($OSPF_COST{$if}) | 
|---|
| 388 | { | 
|---|
| 389 | $ospfd2.=" ip ospf cost $OSPF_COST{$if}\n"; | 
|---|
| 390 | } | 
|---|
| 391 |  | 
|---|
| 392 | } | 
|---|
| 393 | } | 
|---|
| 394 |  | 
|---|
| 395 | $zebra.= "\n\nlog file /var/log/zebra.log\n\n"; | 
|---|
| 396 |  | 
|---|
| 397 | foreach $area (keys %NW) | 
|---|
| 398 | { | 
|---|
| 399 | if ($area eq 0) {next;} | 
|---|
| 400 | $nwa=0xffffffff; | 
|---|
| 401 | foreach $nw (split(/\s+/,$NW{$area})) | 
|---|
| 402 | { | 
|---|
| 403 | ($ip,$width)=split(/\//,$nw); | 
|---|
| 404 | ($a,$b,$c,$d)=split(/\./,$ip); | 
|---|
| 405 | ($II)=($a<<24)+($b<<16)+($c<<8)+$d; | 
|---|
| 406 | if ($width eq 32) {$nm=0xffffffff;} | 
|---|
| 407 | else {$nm=0xffffffff-1<<(31-$width);} | 
|---|
| 408 |  | 
|---|
| 409 | $II=$II & $nm; | 
|---|
| 410 | $nwa=$nwa & $II; | 
|---|
| 411 | #     $ospfd.=sprintf ("NW-$area: $nw ==> %08x enne %08x\n",$II,$nwa); | 
|---|
| 412 | } | 
|---|
| 413 | $nwa=itoadr($nwa); | 
|---|
| 414 |  | 
|---|
| 415 | if ($AGGREGATE) {$agg=$AGGREGATE;} | 
|---|
| 416 | else {$agg=21;} | 
|---|
| 417 |  | 
|---|
| 418 | if (($nwa!~/^172\.16\./) && ($area > 0)) | 
|---|
| 419 | { $ospfarea.="area $area range $nwa/$agg substitute $nwa/$agg\n"; } | 
|---|
| 420 |  | 
|---|
| 421 | $ospf21.="! area $area authentication message-digest\n"; | 
|---|
| 422 | } | 
|---|
| 423 |  | 
|---|
| 424 |  | 
|---|
| 425 | $ospfd.=sprintf <<EOOL; | 
|---|
| 426 |  | 
|---|
| 427 | !  ================>   interfaces  <================ | 
|---|
| 428 |  | 
|---|
| 429 | $ospfd2 | 
|---|
| 430 |  | 
|---|
| 431 | !  ================>   OSPF router  <================ | 
|---|
| 432 | router ospf | 
|---|
| 433 | ospf router-id $master_ip | 
|---|
| 434 | $ospfd21 | 
|---|
| 435 |  | 
|---|
| 436 | passive-interface lo0 | 
|---|
| 437 | $ospfd22 | 
|---|
| 438 |  | 
|---|
| 439 | !default | 
|---|
| 440 | $ospfd3 | 
|---|
| 441 |  | 
|---|
| 442 | $ospfarea | 
|---|
| 443 |  | 
|---|
| 444 | !  ================>   networks  <================ | 
|---|
| 445 | $ospfd4 | 
|---|
| 446 |  | 
|---|
| 447 | !  ================>  neighbors  <================ | 
|---|
| 448 | $ospfd5 | 
|---|
| 449 |  | 
|---|
| 450 | log file /var/log/ospf.log | 
|---|
| 451 |  | 
|---|
| 452 | EOOL | 
|---|
| 453 | # $rcconf.="\n\n" . $freebsd; | 
|---|
| 454 | } | 
|---|
| 455 |  | 
|---|
| 456 | sub get_area | 
|---|
| 457 | { | 
|---|
| 458 | local($IP)=@_; | 
|---|
| 459 | local($range); | 
|---|
| 460 | local($ip,$netmask,$broadcast,$network,$width); | 
|---|
| 461 | local($a,$b,$c,$d)=split(/\./,$IP); | 
|---|
| 462 | local($II)=($a<<24)+($b<<16)+($c<<8)+$d; | 
|---|
| 463 | local($ii,$ip,$nm,$I2); | 
|---|
| 464 |  | 
|---|
| 465 | #  for ($i=0;$i<=$maxareas;$i++) | 
|---|
| 466 | #  { | 
|---|
| 467 | #    $ii=$II[$i]; | 
|---|
| 468 | #    $nm=$NM[$i]; | 
|---|
| 469 | #    $I2=$II & $nm; | 
|---|
| 470 | ##$ospfd.=sprintf "i=$i\t $RANGE[$i]\t ii=$ii\t nm=$nm\t I2=$I2 $II $IP $a,$b,$c,$d\n"; | 
|---|
| 471 | #    if ($I2 == $ii) {return($AREA[$i]);} | 
|---|
| 472 | #  } | 
|---|
| 473 | #  return(12345); | 
|---|
| 474 |  | 
|---|
| 475 | $area=1; | 
|---|
| 476 | if ($b eq 16) {$area=0;} | 
|---|
| 477 | elsif ($c < 128) {$area=($b * 10)} | 
|---|
| 478 | else {$area=(1+($b*10));} | 
|---|
| 479 | if ($area > 255) {$area/=10;} | 
|---|
| 480 | return($area); | 
|---|
| 481 | } | 
|---|
| 482 |  | 
|---|
| 483 |  | 
|---|
| 484 | sub read_areas | 
|---|
| 485 | { | 
|---|
| 486 | $maxareas=0; | 
|---|
| 487 | open(AC,"$home/areas.conf") || die; | 
|---|
| 488 | while (<AC>) | 
|---|
| 489 | { | 
|---|
| 490 | chomp(); | 
|---|
| 491 | s/#.*$//; | 
|---|
| 492 | if (! $_) {next;} | 
|---|
| 493 | ($area,$range,$desc,$counter,$junk)=split(/\s+/); | 
|---|
| 494 | $AREA[$maxareas]=$area; | 
|---|
| 495 | $RANGE[$maxareas]=$range; | 
|---|
| 496 | $DESC[$maxareas]=$desc; | 
|---|
| 497 |  | 
|---|
| 498 | ($ip,$width)=split(/\//,$range); | 
|---|
| 499 | ($a,$b,$c,$d)=split(/\./,$ip); | 
|---|
| 500 | $ii=($a<<24)+($b<<16)+($c<<8)+$d; | 
|---|
| 501 |  | 
|---|
| 502 | if ($width eq 32) {$nm=0xffffffff;} | 
|---|
| 503 | else {$nm=0xffffffff-1<<(31-$width);} | 
|---|
| 504 | $II[$maxareas]=$ii; | 
|---|
| 505 | $NM[$maxareas]=$nm; | 
|---|
| 506 |  | 
|---|
| 507 | $maxareas++; | 
|---|
| 508 | } | 
|---|
| 509 | close(AC); | 
|---|
| 510 | } | 
|---|
| 511 |  | 
|---|
| 512 | sub parse_config | 
|---|
| 513 | { | 
|---|
| 514 | foreach $if (keys %config) | 
|---|
| 515 | { | 
|---|
| 516 | $cfg=$config{$if}; | 
|---|
| 517 | if (! $html) {print "Parsing interface: $if\n";} | 
|---|
| 518 | while ($cfg) | 
|---|
| 519 | { | 
|---|
| 520 | $cfg=~s/^([^\n\r]+)[\r\n]*//m; | 
|---|
| 521 | $line=$1; | 
|---|
| 522 | $line=~s/\s*#.*//; | 
|---|
| 523 | if ((($name,$value)=split(/=/,$line)) eq 2) | 
|---|
| 524 | { | 
|---|
| 525 | if ($name eq 'ESSID') {$value=lc($value);} | 
|---|
| 526 | #print "VAL($name)=$value\n"; | 
|---|
| 527 | $doit="if (exists(\$$name\{\"$if\"\})) {\$$name\{\"$if\"\}.=\"$separator$value\";} else {\$$name\{\"$if\"\}.=\"$value\";}"; | 
|---|
| 528 | #print "DOIT: [$doit]\n"; | 
|---|
| 529 | eval($doit); | 
|---|
| 530 | } | 
|---|
| 531 | #print "CFG:[$cfg]\n"; | 
|---|
| 532 | $cfg=~s/[\r\n]*$//m; | 
|---|
| 533 | } | 
|---|
| 534 | } | 
|---|
| 535 | if ($functions_only<1) {print "Done parsing config.\n";} | 
|---|
| 536 | } | 
|---|
| 537 |  | 
|---|
| 538 | sub iwconfig | 
|---|
| 539 | { | 
|---|
| 540 | local($line)=@_; | 
|---|
| 541 | $nwcfg.="$iwconfig $line\n"; | 
|---|
| 542 |  | 
|---|
| 543 | } | 
|---|
| 544 |  | 
|---|
| 545 | sub ipchains | 
|---|
| 546 | { | 
|---|
| 547 | local($line)=@_; | 
|---|
| 548 | return(system("$ipchains $line")); | 
|---|
| 549 | } | 
|---|
| 550 |  | 
|---|
| 551 | #($a,$b,$c,$d) = unpack('C4',$addr[0]); | 
|---|
| 552 |  | 
|---|
| 553 | #$IP = pack("CCCC", 152, 2, 128, 184);  # create IP address | 
|---|
| 554 | #($var1, $var2, $var3, $var4) = unpack("CCCC", $IP);  #inverse of the above | 
|---|
| 555 |  | 
|---|
| 556 |  | 
|---|
| 557 |  | 
|---|
| 558 | sub calc_ip | 
|---|
| 559 | {  local($i)=@_; | 
|---|
| 560 | local($a,$b,$c,$d); | 
|---|
| 561 | local($ip,$width)=split(/\//,$i); | 
|---|
| 562 | local($a,$b,$c,$d)=split(/\./,$ip); | 
|---|
| 563 | local($ii)=($a<<24)+($b<<16)+($c<<8)+$d; | 
|---|
| 564 |  | 
|---|
| 565 | if ($width eq 32) {$nm=0xffffffff;} | 
|---|
| 566 | else {$nm=0xffffffff-1<<(31-$width);} | 
|---|
| 567 | $nw=($ii & $nm); | 
|---|
| 568 | $br=$nw | (0xffffffff & ~$nm); | 
|---|
| 569 | $netmask=itoadr($nm);; | 
|---|
| 570 | $broadcast=itoadr($br);; | 
|---|
| 571 | $network=itoadr($nw); # $i=itoadr($ii); | 
|---|
| 572 |  | 
|---|
| 573 | #  printf "ip=$ip|width=$width|nm=%0x|$netmask|br=%0x|$broadcast|$i|\n",$nm,$br; | 
|---|
| 574 |  | 
|---|
| 575 | return($ip,$netmask,$broadcast,$network,$width); | 
|---|
| 576 | } | 
|---|
| 577 |  | 
|---|
| 578 | sub itoadr | 
|---|
| 579 | { | 
|---|
| 580 | local($ip)=@_; | 
|---|
| 581 | local($a,$b,$c,$d); | 
|---|
| 582 | $a=($ip & 0xff000000) >> 24; | 
|---|
| 583 | $b=($ip & 0x00ff0000) >> 16; | 
|---|
| 584 | $c=($ip & 0x0000ff00) >> 8; | 
|---|
| 585 | $d=($ip & 0x000000ff); | 
|---|
| 586 | return("$a.$b.$c.$d"); | 
|---|
| 587 | } | 
|---|
| 588 |  | 
|---|
| 589 | sub changeline | 
|---|
| 590 | { | 
|---|
| 591 | local($file,$old,$new)=@_; | 
|---|
| 592 | open(OLD,$file) || die "Could not open old file: $file\n"; | 
|---|
| 593 | open(NEW,">$file.genesis.$$") || die "Could not create new file: $file.genesis.$$"; | 
|---|
| 594 | while(<OLD>) | 
|---|
| 595 | { | 
|---|
| 596 | if (/$old/) {print NEW "$new\n";} | 
|---|
| 597 | else {print NEW $_;} | 
|---|
| 598 | } | 
|---|
| 599 | close(NEW); | 
|---|
| 600 | close(OLD); | 
|---|
| 601 | rename("$file.genesis.$$",$file) || die "Could not overwrite old file: $file"; | 
|---|
| 602 | } | 
|---|
| 603 |  | 
|---|
| 604 |  | 
|---|
| 605 | sub open_files | 
|---|
| 606 | { | 
|---|
| 607 | open (SH,">/etc/wireless.conf.sh"); # Voor firewall script. | 
|---|
| 608 | open (NWCFG,">/etc/wl/nwcfg.sh"); # Voor network config | 
|---|
| 609 | open (DHCP,">/etc/dhcpd.conf") || die "Could not create dhcpd.conf"; | 
|---|
| 610 | open (ZEBRA,">/etc/zebra/zebra.conf") || die "Could not create zebra.conf"; | 
|---|
| 611 | open (OSPFD,">/etc/zebra/ospfd.conf") || die "Could not create ospfd.conf"; | 
|---|
| 612 | open (MRTG,">/etc/mrtg/mrtg.cfg") || die "Could not create mrtg.cfg"; | 
|---|
| 613 | open (RCCONF,">/etc/rc.conf") || die "Could not create rc.conf"; | 
|---|
| 614 | open (FREEBSD,">/etc/rc.node.conf") || die "Could not create rc.node.conf"; | 
|---|
| 615 | open (RESOLV,">/etc/resolv.conf") || die "Could not create resolv.conf"; | 
|---|
| 616 | open (NAMED,">/etc/named.conf") || die "Could not create named.conf"; | 
|---|
| 617 | } | 
|---|
| 618 |  | 
|---|
| 619 |  | 
|---|
| 620 | sub close_files | 
|---|
| 621 | { | 
|---|
| 622 | close (SH); | 
|---|
| 623 | close (NWCFG); | 
|---|
| 624 | close (DHCP); | 
|---|
| 625 | close (ZEBRA); | 
|---|
| 626 | close (OSPFD); | 
|---|
| 627 | close (MRTG); | 
|---|
| 628 | close(RCCONF); | 
|---|
| 629 | close(FREEBSD); | 
|---|
| 630 | close(RESOLV); | 
|---|
| 631 | close(NAMED); | 
|---|
| 632 | } | 
|---|
| 633 |  | 
|---|
| 634 | sub print_files | 
|---|
| 635 | { | 
|---|
| 636 | print SH $sh; | 
|---|
| 637 | print NWCFG $nwcfg; | 
|---|
| 638 | print DHCP $dhcp; | 
|---|
| 639 | print ZEBRA $zebra; | 
|---|
| 640 | print OSPFD $ospfd; | 
|---|
| 641 | print MRTG $mrtg; | 
|---|
| 642 | print RCFONG $rcconf; | 
|---|
| 643 | print FREEBSD $freebsd; | 
|---|
| 644 | print RESOLV $resolv; | 
|---|
| 645 | print NAMED $named; | 
|---|
| 646 | } | 
|---|
| 647 |  | 
|---|
| 648 |  | 
|---|
| 649 | sub init_files | 
|---|
| 650 | { | 
|---|
| 651 | $sh=sprintf  <<EOSH; | 
|---|
| 652 | #! /bin/bash | 
|---|
| 653 | # | 
|---|
| 654 | # Generated by $source | 
|---|
| 655 | # on $now | 
|---|
| 656 | # | 
|---|
| 657 | $svn_version | 
|---|
| 658 |  | 
|---|
| 659 |  | 
|---|
| 660 | gw_open=$gw_open | 
|---|
| 661 | EOSH | 
|---|
| 662 |  | 
|---|
| 663 | $nwcfg=sprintf <<EONW; | 
|---|
| 664 | #! /bin/bash | 
|---|
| 665 | # | 
|---|
| 666 | # Generated by $source | 
|---|
| 667 | # on $now | 
|---|
| 668 | # | 
|---|
| 669 | #  DO NOT CHANGE! | 
|---|
| 670 | # | 
|---|
| 671 | # $author | 
|---|
| 672 | # home: /etc/wl/nwcfg | 
|---|
| 673 | # | 
|---|
| 674 | $svn_version | 
|---|
| 675 |  | 
|---|
| 676 | EONW | 
|---|
| 677 |  | 
|---|
| 678 |  | 
|---|
| 679 | $dhcp=sprintf <<EOD; | 
|---|
| 680 | # dhcpd.conf | 
|---|
| 681 | # | 
|---|
| 682 | # Generated by $source | 
|---|
| 683 | # on $now | 
|---|
| 684 | # | 
|---|
| 685 | #  $author | 
|---|
| 686 | # home: /usr/local/etc/dhcpd.conf | 
|---|
| 687 | # | 
|---|
| 688 | $svn_version | 
|---|
| 689 |  | 
|---|
| 690 | option domain-name "$domain"; | 
|---|
| 691 |  | 
|---|
| 692 | default-lease-time 7200; | 
|---|
| 693 | max-lease-time 2592000; | 
|---|
| 694 |  | 
|---|
| 695 | ddns-update-style none; | 
|---|
| 696 |  | 
|---|
| 697 | # Hack for the WET11 | 
|---|
| 698 | # | 
|---|
| 699 | always-broadcast on; | 
|---|
| 700 |  | 
|---|
| 701 | EOD | 
|---|
| 702 | #foreach $ns (split(/\s+/,$NS_forward)) | 
|---|
| 703 | #       {$dhcp.="option domain-name-servers ${ns};\n";} | 
|---|
| 704 | {$dhcp.="option domain-name-servers ${master_ip};\n";} | 
|---|
| 705 |  | 
|---|
| 706 | $dhcp.="\n\n"; | 
|---|
| 707 |  | 
|---|
| 708 | $zebra= sprintf <<EOZ; | 
|---|
| 709 | ! -*- zebra -*- | 
|---|
| 710 | ! | 
|---|
| 711 | ! Zebra configuration for $hostname | 
|---|
| 712 | ! | 
|---|
| 713 | ! Generated by $source | 
|---|
| 714 | ! on $now | 
|---|
| 715 | ! | 
|---|
| 716 | !  DO NOT CHANGE! | 
|---|
| 717 | ! | 
|---|
| 718 | !   $author | 
|---|
| 719 | !   home=/usr/local/etc/zebra/zebra.conf | 
|---|
| 720 | ! | 
|---|
| 721 | $svn_version | 
|---|
| 722 |  | 
|---|
| 723 | hostname $hostname | 
|---|
| 724 | password getronics | 
|---|
| 725 | enable password getronics | 
|---|
| 726 |  | 
|---|
| 727 | ! Interfaces | 
|---|
| 728 |  | 
|---|
| 729 | interface lo0 | 
|---|
| 730 | description loopback | 
|---|
| 731 | ip address 127.0.0.1/8 | 
|---|
| 732 |  | 
|---|
| 733 |  | 
|---|
| 734 | EOZ | 
|---|
| 735 |  | 
|---|
| 736 | $ospfd=init_ospfd(); | 
|---|
| 737 |  | 
|---|
| 738 | $mrtg=sprintf <<EOM; | 
|---|
| 739 |  | 
|---|
| 740 | # | 
|---|
| 741 | # mrtg configuration for $hostname | 
|---|
| 742 | # | 
|---|
| 743 | # Generated by $source | 
|---|
| 744 | # on $now | 
|---|
| 745 | # | 
|---|
| 746 | #  DO NOT CHANGE! | 
|---|
| 747 | # | 
|---|
| 748 | #   $author | 
|---|
| 749 | #   home=/etc/mrtg | 
|---|
| 750 | # | 
|---|
| 751 | $svn_version | 
|---|
| 752 |  | 
|---|
| 753 | Workdir: /var/www/html/mrtg | 
|---|
| 754 |  | 
|---|
| 755 |  | 
|---|
| 756 | # | 
|---|
| 757 | # | 
|---|
| 758 | # | 
|---|
| 759 |  | 
|---|
| 760 | Target[${hostname}_load]: `/usr/local/sbin/cpuload.pl` | 
|---|
| 761 | MaxBytes[${hostname}_load]: 1000 | 
|---|
| 762 | Title[${hostname}_load]: CPU load on $hostname | 
|---|
| 763 | PageTop[${hostname}_load]: <H1>CPU load on ${hostname}</H1> | 
|---|
| 764 | Options[${hostname}_load]: transparent, gauge, nopercent | 
|---|
| 765 | Legendi[${hostname}_load]: 5min | 
|---|
| 766 | Legendo[${hostname}_load]: 15min | 
|---|
| 767 | ShortLegend[${hostname}_load]: % | 
|---|
| 768 | YLegend[${hostname}_load]: % | 
|---|
| 769 | WithPeak[${hostname}_load]: wmy | 
|---|
| 770 |  | 
|---|
| 771 | Target[${hostname}_mem]: `/usr/local/sbin/memusage.pl` | 
|---|
| 772 | MaxBytes[${hostname}_mem]: 256000000 | 
|---|
| 773 | Title[${hostname}_mem]: Memory usage on ${hostname} | 
|---|
| 774 | PageTop[${hostname}_mem]: <H1>Memory usage on ${hostname}</H1> | 
|---|
| 775 | Options[${hostname}_mem]: transparent, gauge, nopercent | 
|---|
| 776 | Legendi[${hostname}_mem]: free | 
|---|
| 777 | Legendo[${hostname}_mem]: swap | 
|---|
| 778 | ShortLegend[${hostname}_mem]: Bytes | 
|---|
| 779 | YLegend[${hostname}_mem]: Bytes | 
|---|
| 780 | WithPeak[${hostname}_mem]: wmy | 
|---|
| 781 |  | 
|---|
| 782 | Target[${hostname}_up]: `/usr/local/sbin/uptime.pl` | 
|---|
| 783 | MaxBytes[${hostname}_up]: 10000 | 
|---|
| 784 | Title[${hostname}_up]: ${hostname} Uptime | 
|---|
| 785 | PageTop[${hostname}_up]: <H1>${hostname} Uptime</H1> | 
|---|
| 786 | Options[${hostname}_up]: transparent, gauge, nopercent | 
|---|
| 787 | Legendi[${hostname}_up]: uptime | 
|---|
| 788 | Legendo[${hostname}_up]: | 
|---|
| 789 | ShortLegend[${hostname}_up]: Days | 
|---|
| 790 | YLegend[${hostname}_up]: Days | 
|---|
| 791 | WithPeak[${hostname}_up]: wmy | 
|---|
| 792 |  | 
|---|
| 793 | EOM | 
|---|
| 794 |  | 
|---|
| 795 | $rcconf.=sprintf <<EORC1; | 
|---|
| 796 | # This file is read by /etc/rc.conf - and specific to wireless | 
|---|
| 797 | # leiden. Please make all changes in Genesis. | 
|---|
| 798 | # | 
|---|
| 799 | # Generated by $source | 
|---|
| 800 | # on $now | 
|---|
| 801 | # | 
|---|
| 802 | #  $author | 
|---|
| 803 | # | 
|---|
| 804 | $svn_version | 
|---|
| 805 |  | 
|---|
| 806 | hostname="$hostname.wLeiden.NET" | 
|---|
| 807 | location="$location" | 
|---|
| 808 |  | 
|---|
| 809 | #ifconfig_lo0_alias0="inet $master_ip/32" | 
|---|
| 810 | ifconfig_lo0_alias0="inet 172.31.255.1/32" | 
|---|
| 811 | EORC1 | 
|---|
| 812 |  | 
|---|
| 813 | #$freebsd.=sprintf <<EOFB1; | 
|---|
| 814 | # Wireless Leiden startup script om wireless kaarten te initialiseren | 
|---|
| 815 | # | 
|---|
| 816 | # Generated by $source | 
|---|
| 817 | # on $now | 
|---|
| 818 | # | 
|---|
| 819 | #  $author | 
|---|
| 820 | # home=/etc/wl/freebsd.sh | 
|---|
| 821 | # | 
|---|
| 822 | #$svn_version | 
|---|
| 823 | #EOFB1 | 
|---|
| 824 |  | 
|---|
| 825 | $resolv.=sprintf <<EOR1; | 
|---|
| 826 | search wleiden.net . | 
|---|
| 827 |  | 
|---|
| 828 | # Local machine / own nameserver. | 
|---|
| 829 | nameserver 127.0.0.1 | 
|---|
| 830 | EOR1 | 
|---|
| 831 |  | 
|---|
| 832 | #foreach $ns (split(/\s+/,$NS_resolv)) { | 
|---|
| 833 | #       $resolv.="nameserver $ns\n"; | 
|---|
| 834 | #} | 
|---|
| 835 |  | 
|---|
| 836 | foreach $if (sort keys %config) { | 
|---|
| 837 | foreach $ns (split(/[\s$separator]+/,$OSPF_NEIGHBORS{$if})) { | 
|---|
| 838 | next unless $ns =~  m/\d+/; | 
|---|
| 839 | $resolv.="# Nameserver on adjacent node - $DESC{$if} over $if\nnameserver $ns\n\n"; | 
|---|
| 840 | }; | 
|---|
| 841 | }; | 
|---|
| 842 |  | 
|---|
| 843 |  | 
|---|
| 844 |  | 
|---|
| 845 | $named.=sprintf <<EON1; | 
|---|
| 846 | # named.conf | 
|---|
| 847 | # | 
|---|
| 848 | # Generated by $source | 
|---|
| 849 | # on $now | 
|---|
| 850 | # | 
|---|
| 851 | #  $author | 
|---|
| 852 | #  home=/etc/namedb/named.conf | 
|---|
| 853 | # | 
|---|
| 854 | $svn_version | 
|---|
| 855 |  | 
|---|
| 856 | options { | 
|---|
| 857 | directory "/var/db/namedb"; | 
|---|
| 858 | forward only; | 
|---|
| 859 | forwarders { | 
|---|
| 860 | 172.17.143.4; | 
|---|
| 861 | 172.17.8.68; | 
|---|
| 862 | 172.20.128.98; | 
|---|
| 863 | //                   172.18.8.66;  // Internet GW Jasper | 
|---|
| 864 | //                 172.17.32.66; // Internet GW Dirkx | 
|---|
| 865 | EON1 | 
|---|
| 866 |  | 
|---|
| 867 | %x=(); | 
|---|
| 868 | foreach $ns (split(/\s+/,$NS_forward)) { | 
|---|
| 869 | next if $ns eq $master_ip; | 
|---|
| 870 | $named.="                   ${ns};\n"; | 
|---|
| 871 | $x{ $ns } = 1; | 
|---|
| 872 | } | 
|---|
| 873 |  | 
|---|
| 874 | foreach $if (sort keys %config) { | 
|---|
| 875 | foreach $ns (split(/[\s$separator]+/,$OSPF_NEIGHBORS{$if})) { | 
|---|
| 876 | next unless $ns =~  m/\d+/; | 
|---|
| 877 | $x{ $ns } = 0; | 
|---|
| 878 | }; | 
|---|
| 879 | }; | 
|---|
| 880 |  | 
|---|
| 881 | #foreach(sort keys(%x)) { | 
|---|
| 882 | #       next if $x{$_}; | 
|---|
| 883 | #       $named.="//                 $_; // Next door Neighbour..\n"; | 
|---|
| 884 | #       } | 
|---|
| 885 |  | 
|---|
| 886 | $named.=sprintf <<EON2; | 
|---|
| 887 | }; | 
|---|
| 888 | }; | 
|---|
| 889 |  | 
|---|
| 890 | zone "." { | 
|---|
| 891 | type hint; | 
|---|
| 892 | file "/etc/namedb/named.root"; | 
|---|
| 893 | }; | 
|---|
| 894 |  | 
|---|
| 895 | zone "0.0.127.IN-ADDR.ARPA" { | 
|---|
| 896 | type master; | 
|---|
| 897 | file "/etc/namedb/localhost.rev"; | 
|---|
| 898 | }; | 
|---|
| 899 |  | 
|---|
| 900 | zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.INT" { | 
|---|
| 901 | type master; | 
|---|
| 902 | file "/etc/namedb/localhost-v6.rev"; | 
|---|
| 903 | }; | 
|---|
| 904 |  | 
|---|
| 905 | EON2 | 
|---|
| 906 |  | 
|---|
| 907 | push (@ZONES,"wLeiden.NET"); | 
|---|
| 908 | for ($i=16;$i<32;$i++) {push(@ZONES,"$i.172.in-addr.arpa");} | 
|---|
| 909 | foreach $zone (@ZONES) | 
|---|
| 910 | { | 
|---|
| 911 | $named.=sprintf<<EON3; | 
|---|
| 912 | zone "$zone" { | 
|---|
| 913 | type slave; | 
|---|
| 914 | file "slave-$zone"; | 
|---|
| 915 | masters { 172.18.8.66; 212.61.66.38;}; | 
|---|
| 916 | }; | 
|---|
| 917 |  | 
|---|
| 918 | EON3 | 
|---|
| 919 | } | 
|---|
| 920 |  | 
|---|
| 921 |  | 
|---|
| 922 | $snmpd=<<EOM; | 
|---|
| 923 | # /usr/local/share/snmp/snmpd.local.conf | 
|---|
| 924 | # overwrites/augments the data in snmpd.conf | 
|---|
| 925 | # which is identical on each node with data | 
|---|
| 926 | # specific to this node. | 
|---|
| 927 | # | 
|---|
| 928 | mibs +LIGHT80211-MIB | 
|---|
| 929 | EOM | 
|---|
| 930 |  | 
|---|
| 931 | $snmpd .= qq| | 
|---|
| 932 | # Location of the physical node. | 
|---|
| 933 | # | 
|---|
| 934 | syslocation "$location" | 
|---|
| 935 |  | 
|---|
| 936 | |       if defined $location; | 
|---|
| 937 |  | 
|---|
| 938 | $snmpd .= qq| | 
|---|
| 939 | # Location of the physical node. | 
|---|
| 940 | # | 
|---|
| 941 | syscontact "$contact" | 
|---|
| 942 |  | 
|---|
| 943 | |       if defined $contact; | 
|---|
| 944 |  | 
|---|
| 945 | $snmpd .= | 
|---|
| 946 | "# Verify that disk is RO\n". | 
|---|
| 947 | "sh diskro /usr/local/sbin/diskro.sh\n\n" | 
|---|
| 948 | if ($DISK eq 'FLASH'); | 
|---|
| 949 |  | 
|---|
| 950 | $snmpd.=<<EOM; | 
|---|
| 951 |  | 
|---|
| 952 | # Also listen to tcp | 
|---|
| 953 | agentaddress 161,tcp:161 | 
|---|
| 954 |  | 
|---|
| 955 |  | 
|---|
| 956 | # end of file | 
|---|
| 957 | EOM | 
|---|
| 958 | } | 
|---|
| 959 |  | 
|---|
| 960 |  | 
|---|
| 961 |  | 
|---|
| 962 | sub init_ospfd | 
|---|
| 963 | { | 
|---|
| 964 |  | 
|---|
| 965 | local($init)=sprintf <<EOO; | 
|---|
| 966 | ! -*- ospfd -*- | 
|---|
| 967 | ! | 
|---|
| 968 | ! osfpd configuration for $hostname | 
|---|
| 969 | ! | 
|---|
| 970 | ! Configuration generated by $source | 
|---|
| 971 | ! on $now | 
|---|
| 972 | ! | 
|---|
| 973 | !  DO NOT CHANGE! | 
|---|
| 974 | ! | 
|---|
| 975 | !   $author | 
|---|
| 976 | !   home=/usr/local/etc/zebra/ospfd.conf | 
|---|
| 977 | ! | 
|---|
| 978 | $svn_version | 
|---|
| 979 |  | 
|---|
| 980 | hostname $hostname | 
|---|
| 981 | password getronics | 
|---|
| 982 | enable password getronics | 
|---|
| 983 |  | 
|---|
| 984 | interface lo0 | 
|---|
| 985 | EOO | 
|---|
| 986 | return($init); | 
|---|
| 987 | } | 
|---|
| 988 |  | 
|---|
| 989 |  | 
|---|
| 990 | sub mrtg1 | 
|---|
| 991 | { | 
|---|
| 992 | $mrtg.=sprintf <<EOM2; | 
|---|
| 993 | Target[${if}_traf]: `/usr/local/sbin/ipchains_traf.pl ${if}` | 
|---|
| 994 | MaxBytes[${if}_traf]: $SPEED{$if} | 
|---|
| 995 | Title[${if}_traf]: Traffic Analysis ${if} $SDESC{$if} | 
|---|
| 996 | PageTop[${if}_traf]: <H1>Traffic on $if $DESC{$if}</H1> | 
|---|
| 997 | Options[${if}_traf]: transparent | 
|---|
| 998 | WithPeak[${if}_traf]: wmy | 
|---|
| 999 |  | 
|---|
| 1000 | EOM2 | 
|---|
| 1001 |  | 
|---|
| 1002 | if ($functions_only<1) | 
|---|
| 1003 | { | 
|---|
| 1004 | ipchains("-N ${if}-i"); | 
|---|
| 1005 | ipchains("-N ${if}-o"); | 
|---|
| 1006 | ipchains("-I input -i ${if} -j ${if}-i"); | 
|---|
| 1007 | ipchains("-I output -i ${if} -j ${if}-o"); | 
|---|
| 1008 |  | 
|---|
| 1009 | } | 
|---|
| 1010 | if ($TYPE{$if}=~/wireless/i) | 
|---|
| 1011 | { | 
|---|
| 1012 | $mrtg.=sprintf  <<EOM3; | 
|---|
| 1013 | Target[${if}_quality]: `/usr/local/sbin/wlan_quality.pl ${if}` | 
|---|
| 1014 | MaxBytes1[${if}_quality]: 100 | 
|---|
| 1015 | MaxBytes2[${if}_quality]: 100 | 
|---|
| 1016 | Title[${if}_quality]:  Quality $if $SDESC{$if} | 
|---|
| 1017 | PageTop[${if}_quality]: <H1>Quality $if $DESC{$if}</H1> | 
|---|
| 1018 | Options[${if}_quality]: transparent, gauge, nopercent | 
|---|
| 1019 | Legendi[${if}_quality]: Quality | 
|---|
| 1020 | Legendo[${if}_quality]: Noise | 
|---|
| 1021 | ShortLegend[${if}_quality]: /100 | 
|---|
| 1022 | YLegend[${if}_quality]: /100 | 
|---|
| 1023 | WithPeak[${if}_quality]: wmy | 
|---|
| 1024 |  | 
|---|
| 1025 | Target[${if}_rate]: `/usr/local/sbin/wlan_bitrate.pl ${if}` | 
|---|
| 1026 | MaxBytes1[${if}_rate]: 11 | 
|---|
| 1027 | MaxBytes2[${if}_rate]: 11 | 
|---|
| 1028 | Title[${if}_rate]: Bitrate $if $SDESC{$if} | 
|---|
| 1029 | PageTop[${if}_rate]: <H1>Bitrate $if $DESC{$if}</H1> | 
|---|
| 1030 | Options[${if}_rate]: transparent, gauge, nopercent | 
|---|
| 1031 | Legendi[${if}_rate]: Bitrate | 
|---|
| 1032 | ShortLegend[${if}_rate]: Mb/s | 
|---|
| 1033 | YLegend[${if}_rate]: Mb/s | 
|---|
| 1034 | WithPeak[${if}_rate]: wmy | 
|---|
| 1035 |  | 
|---|
| 1036 | EOM3 | 
|---|
| 1037 | if ($MODE{$if}=~/master/i) | 
|---|
| 1038 | { | 
|---|
| 1039 | $mrtg.=sprintf  <<EOM4; | 
|---|
| 1040 | Target[${if}_users]: `/usr/local/sbin/wlan_users.pl ${if}` | 
|---|
| 1041 | MaxBytes[${if}_users]: 100 | 
|---|
| 1042 | Title[${if}_users]: Users on $if $SDESC{$if} | 
|---|
| 1043 | PageTop[${if}_users]: <H1>Users on $if $DESC{$if}</H1> | 
|---|
| 1044 | Options[${if}_users]: transparent, gauge, nopercent | 
|---|
| 1045 | Legendi[${if}_users]: Users | 
|---|
| 1046 | ShortLegend[${if}_users]: users | 
|---|
| 1047 | YLegend[${if}_users]: users | 
|---|
| 1048 | WithPeak[${if}_users]: wmy | 
|---|
| 1049 |  | 
|---|
| 1050 | EOM4 | 
|---|
| 1051 | } | 
|---|
| 1052 | }  # wireless | 
|---|
| 1053 |  | 
|---|
| 1054 |  | 
|---|
| 1055 | } | 
|---|
| 1056 |  | 
|---|
| 1057 | sub mrtg2 | 
|---|
| 1058 | { | 
|---|
| 1059 | $mrtg.=sprintf <<EOM5; | 
|---|
| 1060 | Target[${if}_lat]: `/usr/local/sbin/latency.pl $p` | 
|---|
| 1061 | MaxBytes1[${if}_lat]: 100 | 
|---|
| 1062 | MaxBytes2[${if}_lat]: 200 | 
|---|
| 1063 | Title[${if}_lat]: Latency/PktLoss Analysis to $p on $if $SDESC{$if} | 
|---|
| 1064 | PageTop[${if}_lat]: <H1>Latency/PktLoss to $p on $if $DESC{$if}</H1> | 
|---|
| 1065 | Options[${if}_lat]: transparent, gauge, nopercent | 
|---|
| 1066 | Legendi[${if}_lat]: PacketLoss% | 
|---|
| 1067 | Legendo[${if}_lat]: Max Latency (ms) | 
|---|
| 1068 | ShortLegend[${if}_lat]: %/ms | 
|---|
| 1069 | YLegend[${if}_lat]: %/ms | 
|---|
| 1070 | WithPeak[${if}_lat]: wmy | 
|---|
| 1071 |  | 
|---|
| 1072 | EOM5 | 
|---|
| 1073 |  | 
|---|
| 1074 | } | 
|---|
| 1075 |  | 
|---|
| 1076 | sub ahum | 
|---|
| 1077 | { | 
|---|
| 1078 | print "AHUM!\n"; | 
|---|
| 1079 | } | 
|---|
| 1080 |  | 
|---|
| 1081 | #return(1); | 
|---|
| 1082 |  | 
|---|