How to access a Linux server with a dynamic IP Address

Source: Internet
Author: User
The general method can use peanut shells (but we do not recommend these domestic domain name registrars, these registrars can at will and can stop parsing your domain name without talking about the law, then you want to cry also don't rush .), If you are in trouble, use the following script and use crontab to execute it every 10 minutes. If the ip address changes, you can send

The general method can use peanut shells (but we do not recommend these domestic domain name registrars, these registrars can at will and can stop parsing your domain name without talking about the law, then you want to cry also don't rush .), If you are in trouble, use the following script and then useCrontabRun the command once every 10 minutes. If the ip address changes, an email containing the updated ip address is sent to your specified email address.

Ipsender

----------------------------------------------

#! /Usr/bin/perl

Use LWP: Simple;
Use sTrIct;

My $ pub_ip _File= '/Etc/ipsender/mypubip ';

My $ old_pub_ip ='Cat$ Pub_ip_file ';
Chomp ($ old_pub_ip );

My $ new_pub_ip = get ('HTTP: // whatismyip.org ');
Chomp ($ new_pub_ip );

If ($ new_pub_ip ne "" & $ new_pub_ip ne $ old_pub_ip)
{
Open (IPFILE, "> $ pub_ip_file") | die "cannot open $ pub_ip_file: $! ";
Print IPFILE $ new_pub_ip;
Close (IPFILE );

My $ sendmail = "/usr/sbin/sendmail-t ";
My $ sendto = 'a: your@mailbox.com ';
My $SuBject = 'subject: pubIP @ home ';

Open (SENDMAIL, "| $ sendmail") or die "Cannot open $ sendmail: $! ";
Print SENDMAIL $ sendto. "/n ";
Print SENDMAIL $ subject. "/n ";
Print SENDMAIL "Content-type: tExT/html/n ";
Print SENDMAIL "Hi, the public ip at home is changEdTo $ new_pub_ip .";
Close (SENDMAIL );

System ("logger/" public ip upDateD /"");
}
ELsE
{
System ("logger/" public ip uNcHanged /"");
}

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.