Because the company's SVN server is placed on the outside network, only certain IP is allowed to be accessed for security. (The company dials with PPPoE)
Almost every day to brush the company's IP, this is very inconvenient. So I want to automatically refresh the idea of moving IP.
Conditions:
1, router DDNS service, if not then use the computer to download peanut Shell client.
Implementing the dynamic Refresh Shell core code is as follows:
dyip=$ (ping **.kmdns.net-c1 | grep ping | awk ' {print $} ' | Cut-c 2-| cut-d\)-F1)
Iptables-a input-s $dyIP-P tcp-j ACCEPT #公司动态IP
Use the ping command to get the required IP address information, filter the required line information through group, and then filter the columns by using the awk command
Ping Baidu.com-c1 | grep PING | awk ' {print $} '
Figure 1
Figure 1 obtains the IP address with a pair of parentheses, and then the cut command again to remove the left (and the right), you can get the full IP.
Assigns the acquired IP to a variable and adds it to the iptables.
Re-Configure the timer (8-9 points per day for every 10 minutes)
*/10 8-9 * * */etc/firewall.sh
Iptables auto-Bind dynamic IP