Iptables auto-Bind dynamic IP

Source: Internet
Author: User

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

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.