|
Cisco Router config reverse dns
|
|
04-14-2010, 05:43 PM
Mesaj: #1
|
|||
|
|||
|
Cisco Router config reverse dns
Asagida yer alan script cisco router konfigurasyonlarindan reverse dns kaydi girmek icin gerekli olan bilgileri yorumlar:
register.sh #!/bin/bash echo > register.txt ls *.cfg|while read file do host=`echo $file|cut -d"." -f1` cat $file|grep "ip address"|grep -v "no ip address"|awk '{print $3}'|while read value do ipf=`echo $value|cut -d"." -f1` ips=`echo $value|cut -d"." -f2` ipt=`echo $value|cut -d"." -f3` iplast=`echo $value|cut -d"." -f4` ipall=$ipf.$ips.$ipt reverse=`echo rev.$ipall|grep -v address` record=`echo $iplast IN PTR $host.netone.com.tr|grep -v address` echo $reverse $record. >> register.txt done done Özdemir Şarman aka (Charmant-zavanetratan) |
|||
|
04-14-2010, 05:43 PM
Mesaj: #2
|
|||
|
|||
|
RE: Cisco Router config reverse dns
Asagida kodu yer alan 2. script ise register.sh scriptinin calismasi sonucu
olusan register.txt içeriğine göre reverse dns dosyalarını oluşturmaktadır. Örnek register.txt içeriği: rev.10.150.1 3 IN PTR acbrtr01.sistemodasi.net. rev.10.150.1 12 IN PTR acbrtr01.sistemodasi.net. rev.10.150.1 56 IN PTR acbrtr01.sistemodasi.net. revreg.sh #!/usr/bin/bash cat register.txt|while read records do search=`echo $records|awk '{print $2}'` file=`echo $records |awk '{print $1}'` oldrecord=`grep "^$search IN" $file` newrecord=`echo $records|awk '{print $2,$3,$4,$5}'` process=`vim -esnc ":argdo %s/$oldrecord/$newrecord/g" -c ":wq" $file` done Not: Scriptlerin işlemesi için vi yerine vim gereklidir. Özdemir Şarman aka (Charmant-zavanetratan) |
|||
|
04-14-2010, 05:44 PM
Mesaj: #3
|
|||
|
|||
|
RE: Cisco Router config reverse dns
Bu versşyonda Cisco routerlarin ip adreslerine ait olan interfacelerde bulunmakta ve buna gore reverse dns dosyasi olusturulmaktadır.
reverse.sh #!/usr/bin/bash echo > register.txt ls *.cfg|while read file do host=`echo $file|cut -d"." -f1` cat $file|grep "ip address"|grep -v "no ip address"|awk '{print $3}'|while read value do ipf=`echo $value|cut -d"." -f1` ips=`echo $value|cut -d"." -f2` ipt=`echo $value|cut -d"." -f3` iplast=`echo $value|cut -d"." -f4` ipall=$ipf.$ips.$ipt match=`cat $file|grep -v "no ip address"|grep -5 "$value"|grep interface|head -1|awk '{print $2}'` reverse=`echo rev.$ipall|grep -v address` record=`echo $iplast IN PTR $match-$host.netone.com.tr|grep -v address` echo $reverse $record. >> register.txt done done Kodun sonucunda oluşan örnek çıktı aşağıda yer almaktadır: rev.212.154.20 245 IN PTR Serial2/3:1-acbrtr01.netone.com.tr. Özdemir Şarman aka (Charmant-zavanetratan) |
|||
|
04-14-2010, 05:44 PM
Mesaj: #4
|
|||
|
|||
|
RE: Cisco Router config reverse dns
Hataları düzeltilmiş son sürüm Cisco konfigürasyon dosyasından:
rev.10.10.19 5 IN PTR sallama-local.netone.com.tr. şeklinde reverse dns kaydı üreten script. reverse4.sh #!/usr/local/bin/bash echo > register.txt ls *.cfg|while read file do host=`echo $file|cut -d"." -f1` cat $file|grep interface|grep -v "no ip route"|cut -d":" -f 2,3|grep ^interface|while read value do cursor=`nl $file |grep -w "$value"|head -1|awk '{print $1}'` positiona=`echo $cursor +1|bc` positionb=`echo $positiona +1|bc` positionc=`echo $positionb +1|bc` positiond=`echo $positionc +1|bc` #Debug #echo Dosya:$file #echo Interface:$value #echo Interface Pozisyonu:$cursor #echo Pozisyon A:$positiona #echo Pozisyon B:$positionb #echo Pozisyon C:$positionc #echo Pozisyon D:$positiond location=`echo $file|cut -d"." -f 1` interface=`echo $value|awk '{print $2}'` warning=`grep \! $file` warningb=`nl $file|grep -w " $positionb"|grep \!|wc -c` warningc=`nl $file|grep -w " $positionc"|grep \!|wc -c` warningd=`nl $file|grep -w " $positiond"|grep \!|wc -c` checka=`nl $file |grep -w " $positiona"|grep "ip address"|grep -v no|grep -v peer|wc -c` ipthreea=`nl $file |grep -w " $positiona"|grep "ip address"|grep -v no|grep -v peer|awk '{print $4}'|cut -d"." -f 1,2,3` iplasta=`nl $file |grep -w " $positiona"|grep "ip address"|grep -v no|grep -v peer|awk '{print $4}'|cut -d"." -f 4` checkb=`nl $file |grep -w " $positionb"|grep "ip address"|grep -v no|grep -v peer|wc -c` ipthreeb=`nl $file |grep -w " $positionb"|grep "ip address"|grep -v no|grep -v peer|awk '{print $4}'|cut -d"." -f 1,2,3` iplastb=`nl $file |grep -w " $positionb"|grep "ip address"|grep -v no|grep -v peer|awk '{print $4}'|cut -d"." -f 4` checkc=`nl $file |grep -w " $positionc"|grep "ip address"|grep -v no|grep -v peer|wc -c` ipthreec=`nl $file |grep -w " $positionc"|grep "ip address"|grep -v no|grep -v peer|awk '{print $4}'|cut -d"." -f 1,2,3` iplastc=`nl $file |grep -w " $positionc"|grep "ip address"|grep -v no|grep -v peer|awk '{print $4}'|cut -d"." -f 4` checkd=`nl $file |grep -w " $positiond"|grep "ip address"|grep -v no|grep -v peer|wc -c` ipthreed=`nl $file |grep -w " $positiond"|grep "ip address"|grep -v no|grep -v peer|awk '{print $4}'|cut -d"." -f 1,2,3` iplastd=`nl $file |grep -w " $positiond"|grep "ip address"|grep -v no|grep -v peer|awk '{print $4}'|cut -d"." -f 4` if [ $checka -gt 5 ];then echo "rev.$ipthreea $iplasta IN PTR $interface-$location.netone.com.tr." elif [ $warningb -gt 0 ];then echo > /dev/null elif [ $checkb -gt 5 ];then echo "rev.$ipthreeb $iplastb IN PTR $interface-$location.netone.com.tr." elif [ $warningc -gt 0 ];then echo > /dev/null elif [ $checkc -gt 5 ];then echo "rev.$ipthreec $iplastc IN PTR $interface-$location.netone.com.tr." elif [ $warningd -gt 0 ];then echo > /dev/null elif [ $checkd -gt 5 ];then echo "rev.$ipthreed $iplastd IN PTR $interface-$location.netone.com.tr." else echo > /dev/null fi done done Özdemir Şarman aka (Charmant-zavanetratan) |
|||
|
04-14-2010, 05:45 PM
Mesaj: #5
|
|||
|
|||
|
RE: Cisco Router config reverse dns
revreg.sh için bug fix:
#!/usr/bin/bash cat register.txt|while read records do search=`echo $records|awk '{print $2}'` echo $search file=`echo $records |awk '{print $1}'` echo $file oldrecord=`grep -w "^$search" $file` echo $oldrecord newrecord=`echo $records|awk '{print $2,$3,$4,$5}'` echo $newrecord process=`vim -esnc ":argdo %s/$oldrecord/$newrecord/g" -c ":wq" $file` done Özdemir Şarman aka (Charmant-zavanetratan) |
|||
|
04-14-2010, 05:45 PM
Mesaj: #6
|
|||
|
|||
|
RE: Cisco Router config reverse dns
Yeni versiyon revreg.sh (Hatasız)
#!/usr/bin/bash cat register.txt|while read records do search=`echo $records|awk '{print $2}'` echo $search file=`echo $records |awk '{print $1}'` echo $file oldrecord=`grep -w "^$search" $file` echo $oldrecord newrecord=`echo $records|awk '{print $2,$3,$4,$5}'` echo $newrecord #process=`vim -esnc ":argdo %s/$oldrecord/$newrecord/g" -c ":wq" $file` rm -rf $file.tmp cat $file|grep -vw "^$search" >> $file.tmp echo $newrecord >> $file.tmp rm -rf $file mv $file.tmp $file echo $file dosyasi islenmistir. Özdemir Şarman aka (Charmant-zavanetratan) |
|||
|
04-14-2010, 05:45 PM
Mesaj: #7
|
|||
|
|||
|
RE: Cisco Router config reverse dns
reverse.sh
#!/usr/local/bin/bash echo > register.txt ls *.cfg|while read file do host=`echo $file|cut -d"." -f1` interface_sayi=`nl $file|grep interface|grep -v Async|wc -l` echo "$host routerinda $interface_sayi kayit bulunmaktadir." nl $file|grep interface|grep -v Async|while read perform do interface=`echo $perform|awk '{print $3}'` baslangic_pozisyonu=`echo $perform|awk '{print $1}'` etki_alan_numarasi1=`echo $perform|awk '{print $1+1}'` etki_alan_numarasi2=`echo $perform|awk '{print $1+2}'` etki_alan_numarasi3=`echo $perform|awk '{print $1+3}'` etki_alan_numarasi4=`echo $perform|awk '{print $1+4}'` etki_alan_numarasi5=`echo $perform|awk '{print $1+5}'` etki_alan_numarasi6=`echo $perform|awk '{print $1+6}'` etki_alan_numarasi7=`echo $perform|awk '{print $1+7}'` echo echo "Interface Bilgisi:$perform" echo "Interface Baslangic Pozisyonu:$baslangic_pozisyonu" echo "Interface Kapsam Alanlari:" echo echo $etki_alan_numarasi1 echo $etki_alan_numarasi2 echo $etki_alan_numarasi3 echo $etki_alan_numarasi4 echo $etki_alan_numarasi5 echo $etki_alan_numarasi6 echo $etki_alan_numarasi7 echo unlem_alan=`nl $file|egrep "$etki_alan_numarasi1|$etki_alan_numarasi2|$etki_alan_numarasi3|$etki_alan_numarasi4|$etki_alan_numarasi5|$etki_alan_numarasi6|$etki_alan_numarasi7"|grep "\!"|head -1` echo "Unlem Alani:$unlem_alan" echo arama_bolgesi_baslangic=$baslangic_pozisyonu arama_bolgesi_son=`echo $unlem_alan|awk '{print $1}'` aranilacak_alan_sayisi=`expr $arama_bolgesi_son - $arama_bolgesi_baslangic - 1` echo "Arama Bolgesi Baslangic:$arama_bolgesi_baslangic" echo "Arama Bolgesi Son:$arama_bolgesi_son" echo "Aranilacak Alan Sayisi:$aranilacak_alan_sayisi" echo "Aranilan Alanlar:" echo baslat=`expr $baslangic_pozisyonu + 1` for (( i = $baslat ; i < "$arama_bolgesi_son"; i++ )) do #echo $i ip=`nl $file|grep -w $i|grep "ip address"|grep -v peer|grep -v no|grep -v grep|awk '{print $4}'` ipc=`nl $file|grep -w $i|grep "ip address"|grep -v peer|grep -v no|grep -v grep|wc -l` if [ $ipc -eq 1 ] then echo "$host $interface $ip" >> register.txt else echo "ip adresi bulunamamistir." > /dev/null fi done done done Özdemir Şarman aka (Charmant-zavanetratan) |
|||
'Cisco Router config reverse dns' Konusunu PaylaÅŸ |
| Benzeyen Konular | |||||
| Konu: | Yazar | Cevaplar: | Gösterim: | Son Mesaj | |
| Expect olmadan bash ile router ve diÄŸr cihazlara login olmak | ozsarman | 0 | 428 |
04-14-2010 11:45 AM Son Mesaj: ozsarman |
|
| Dns forward zone'dan reverse zone dosyasi üretmek | ozsarman | 0 | 396 |
04-07-2010 06:09 PM Son Mesaj: ozsarman |
|
| Bind dns reverse bulk update | ozsarman | 0 | 385 |
03-30-2010 06:11 PM Son Mesaj: ozsarman |
|
| Router backuplarini almak | ozsarman | 0 | 429 |
03-29-2010 05:46 PM Son Mesaj: ozsarman |
|
| Router backup'larını işlemek | ozsarman | 1 | 451 |
03-26-2010 07:36 PM Son Mesaj: ozsarman |
|

Arama
Üye Listesi
Takvim
Yardım














