Panabit automatically parses the domain name and adds the resolved IP

Source: Internet
Author: User

The company has a Panabit behavior manager installed. And then made some rule restrictions. Release a few domain names, such as QQ business mailbox.

And then like QQ Enterprise mailbox and so on sometimes often change the IP. So if you don't know, colleagues may not be able to receive e-mail ...


Look at the next panabit is based on FreeBSD. The company currently has two sets, one 8.0, and one 9.0.


The SED is really super hard to use. Fortunately there is awk. And it's csh, no bash. Consider the Panabit this is a custom environment. You may be able to install it if you want to install it. Even if installed, maybe unstable ...


There are no nslookup and dig inside panabit. All domain names can only be SSH to other servers to query.


Here is the specific code:

#!/bin/csh# create by bianlimitset sshhost =  "192.168.1.14" if  (  ' uname  -r '  ==  "9.2-release"  )  then     #分部用的是新的版本,  the  tid inside.   and  dns  that's going to pa_conf this file. View .    set ipectrl =  "/usr/system/bin /ipectrl "    set pa_conf = "/conf/panabit.conf "    set  pa_tid =  "1"     set pa_dns =  "1" else      #老版本     set ipectrl =  "/usr/panabit/bin/ipectrl"      set pa_conf =  "/usr/panaetc/panabit.conf"     set pa_tid =   "4"     set pa_dns =  "2" endifset pa_dir =  ' dirname   $PA _conf ' set ip_tmp= "192.168.1.11 192.168.1.12" set dns_tmp= ' awk -f  ' = '  -v  var= $pa _dns  '/^dns/&&$2==var " dns" {print $3} '   $pa _conf ' foreach i  (  $dns _tmp )      set www =  ' ssh  $sshhost   nslookup  $i  | awk  ' NR >4&&/^add/'  | awk  ' {print $2 '   '} '     if  (  $i  ==  "exmail.qq.com"  )  then        # Company QQ Enterprise Mailbox also have to add imap, smtp        set imap =  ' ssh   $sshhost   "Nslookup imap $i  | awk  ' nr>4&&/^add/'"  | awk   ' {print $2 '   '} '         set smtp =  ' ssh   $sshhost   "nslookup smtp $i  | awk  ' nr>4&&/^add/'"  | awk   ' {print $2 '   '} '         set ip_tmp =  ' $ ip_tmp  $imap   $SMTP "&NBSP;&NBsp;  endif    set ip_tmp =  "$ip _tmp  $www" Endset newip  =  ' echo  ' $ip _tmp '  | awk  ' {for (i=1;i<=nf;i++) {a[$i]}}end{if (Length (a) ==0) { print  "Exit"}else{for (i in a) {print i}} "if  ( " $newip " == " Exit "  )  then    exitendif# generate a new format. Check whether the same as the original .  output is empty awk -f  ' = '  -v  vtid= $pa _tid -v nip= "$newip"   "Begin{split (nip,t,"   ")}$1~/iprng tid/&&$2 ==vtid " ip" {w[$NF];x=1;next}{if (x) {c=c?c "\ n" $0:$0}else{a=a?a "\ n" $0:$0}}end{if (length (t) ==length (W)) {for (i  in t) {if (i in w) {delete w[i]}}if (Length (w) ==0) {print  ""}}else{for (i in  t) {b=b?b "\niprng tid=" Vtid " ip=" t[i]: "iprng tid=" Vtid " ip=" t[i]};p rint a "\ n" b "\ n "c}} '   $pa _conf > " ${pa_conf}.tmp "#文件为空则退出if   ( -z " ${pa_conf}.tmp " )  then    exitendifcp  $pa _conf  "${pa_conf}. ' Date +%f '"  && mv  "${pa_conf}.tmp "  $PA _conffind  $pa _dir -name " panabit.conf* " -a -mtime +15 -exec  rm -f {} \; $ipectrl  stopsleep 5$ipectrl start

The above code has been tested for adoption. Delete relevant Chinese comments at runtime

SSH Please do the relevant authentication first.


Add to Crontab OK again

Panabit automatically parses the domain name and adds the resolved IP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.