Our company uses the record management system of flag filing
Recently, because of the authority requirements, all the domain name of the record information to verify the accuracy of the record information, whether there is a record IP is not my company's domain name.
Special to do this script, automatically from the filing system database to query all the record IP and filter.
This script is only applicable to the flag record system V3.0
Use this script money please manually open the record system database remote access permission
This script is Shell script, please run it inside the Linux system
# Record Accuracy Query script # This script automatically query the filing system database of the record domain name, the record IP, and the record person's contact information,# through the script to ping each domain name, and the target IP and the IP in the filing system to compare , the comparison results are exported to the corresponding table # when the target IP and the IP in the filing system are different, the target IP is compared with the western IP database, and the domain name is compared in the IP library of the west. # Export the results to the appropriate table. # This script will export 4 tables. # ipdiff.csv ====> IP and destination IP different domain name information # ipsame.csv ====> record IP and destination IP same domain name information # ipinsimpul.csv ====> Filing IP domain name information # ipoutsimpul.csv ====> in the database of the West Record IP domain name information in the database #使用以下命令添加crontab自动下载列表 I'm adding a 00:01 run script every Tuesday. Restart the Crond service after the add is complete # Here I save the script file in the file folder in the Cacti folder, save the script elsewhere, and add the virtual directory to Apache for file browsing. # echo "01 01 * * 2 root /root/ipquery.sh > / Dev/null 2>&1 " > /etc/cron.d/export # Shaanxi West PU Data Communication Co., Ltd. operation and maintenance department by:fenei 2016 August 1 # qq:407603129 email:[email protected]# http:// babyfenei.blog.51cto.com #!/bin/bashdbhost= "Record server IP" username= "database user name" #数据库用户名PASSWORD = "Database Password" # Database Password Dbname= "Trunkeydb" #Cacti使用的数据库名称 mysql_cmd= "Mysql -h${DBHOST } -u${username} -p${password} " rm /root/beian.tarrm /tmp/url.csv #删除旧的下载列表文件rm /tmp/beian/ipdiff.csv #删除旧的下载列表文件rm /tmp/beian/ipsame.csv #删除旧的下载列表文件rm /tmp/beian/ipinsimpul.csv rm /tmp/beian/ipoutsimpul.csvmkdir -p /tmp/beian/echo "DOMAIN", "Icpip", "$ Destip "," Icptel "," ICPMB "," $ICPMAIL ">> /tmp/beian/ipdiff.csvecho " DOMAIN "," Icpip "," $DESTIP "," Icptel "," ICPMB "," $ICPMAIL ">> /tmp/beian/ipsame.csvecho "DOMAIN", "Icpip", "$DESTIP", "Icptel", "ICPMB", "$ICPMAIL" >> /tmp/ beian/ipinsimpul.listecho "DOMAIN", "Icpip", "$DESTIP", "Icptel", "ICPMB", "$ICPMAIL" >> /tmp/beian/ Ipoutsimpul.listselect_db_sql= "Select a.syurl,b.qsip,a.fzr_dhhm,a.fzr_sjhm,a.fzr_dzyj from tab_icpweb a LEFT JOIN tab_icpip b on a.IspWzid=b.IspJrid; " #通过数据库查询出备案系统中经过备案的域名, IP, name, phone, cell phone, email echo ${select_db_sql} | ${mysql_cmd} ${ Dbname} > /tmp/url.csvif [ $? -ne 0 ]then echo "select databases ${dbname} failed  ..." >>/var/log/export/log #数据库查询失败时将添加失败日志到日志文件中fised -i ' s/;/\n/g ' /tmp/url.csv #将URL列表中的域名调整为单列 Cat /tmp/url.csv | awk ' nr>1 ' | while read icpurl icpip icpdh icpsj icpyj# Read each column value in Url.csv row by line and assign a value to the variable doipa=$ (ping $ICPURL -c 1 | awk ' {print $3} ' |head -1) #获取域名解析的IP地址IPB =${ipa//(/}destip=${ipb//)/}# Remove the parentheses symbol in the resolved IP address if [ "$DESTIP" != "$ICPIP" ];then# determine if the IP address is the same as that in the filing system Echo "$ICPURL", "$ICPIP", "$DESTIP", "$ICPDH", "$ICPSJ", "$ICPYJ" >> /tmp/beian/ipdiff.csv# export resolves IP and record IP domain name # This part of the bit determines whether the IP is while read maskdomin= '/bin/ipcalc -n $MASK in the West IP library |awk -f "=" ' {print $2} ' #获取IP库中每行子网的最小IPmax = '/bin/ipcalc -b $MASK |awk -f "=" ' {print $2} ' #获取IP库中每行子网的最大IPMIN = ' echo $min |awk -f '. " ' {printf '%.0f\n ', $1*256*256*256+$2*256*256+$3*256+$4} ' max= ' echo $max |awk -f '. ' {printf '%.0f\n ', $1*256*256*256+$2*256*256+$3*256+$4} ' ipvalue= ' echo $DESTIP |awk -f '. ' {printf "%.0f\n", $1*256*256*256+$2*256*256+$3*256+$4} "#此三行将IP地址又点分十进制转换位普通数值if [ " $IPvalue " -gt "$MIN" ] && [ "$IPvalue" -lt "$MAX" &NBSP;] #判断解析IP是否在IP库的子网范围内then echo "$ICPURL", "$ICPIP", "$DESTIP", "$ICPDH", "$ICPSJ" , "$ICPYJ" >> /tmp/beian/ipinsimpul.listelseecho "$ICPURL", "$ICPIP", "$DESTIP", "$ICPDH", "$ICPSJ", "$ICPYJ" >> /tmp/beian/ipoutsimpul.listfidone</root/ipset.conf#ipset.conf for else IP library file echo "$ICPURL", "$ICPIP", "$DESTIP", "$ICPDH", "$ICPSJ", "$ICPYJ" >> /tmp/beian/ipsame.csvfi donesort -u /tmp/beian/ipinsimpul.list > /tmp /beian/ipinsimpul.csvsort -u /tmp/beian/ipoutsimpul.list > /tmp/beian/ipoutsimpul.csvrm /tmp/beian/ipinsimpul.listrm /tmp/beian/ipoutsimpul.list# Delete duplicate rows in the export list tar zcvf /root/beian.tar /tmp/beian/mail -s "The results of the -a /root/beian.tar [email protected data record Week" < /root/mailtitlemail -s " -a /root/beian.tar [email data record Week results" protected] < /root/mailtitle
The company's IP list is as follows:
Cat/root/ipset.conf127.0.0.1/24111.111.111.1/23
Automatic script for filing IP verification