<# This script will monitor your IP for change, and email you if/when it changes The email send feature uses a valid Gmail account to send the emails, if you don't have one it's easy to get one. #> #Get your current public IP address. I use 1and1.com here as they are a large provider and reply to ping requests. $a = ping -r 1 1and1.com | Select-String "Route: *." | Get-Unique | Out-String #In order to check your IP against it's last value it's written to a file each time it is checked. If the file or folder do not exist they are created. #confirm that the file c:\temp\ip.txt exists, if not create it $path = Test-Path C:\temp\ If ($PATH -ne 'True'){mkdir c:\temp} $path = Test-Path C:\temp\ip.txt If ($PATH -ne 'True'){New-Item -ItemType file C:\temp\ip.txt} $b = Get-Content "C:\temp\ip.txt" | Select-String "Route: *." | Out-String #compare $a to $b $c = $a.compareTo($b) #If $a and $b are not the same, email new IP address If ($c -ne '0') { $data = $a $a > C:\temp\ip.txt #Email $EmailFrom = "Yoursendingaccoutn@gmail.com" $EmailTo = "recipient@domain.com" $Subject = "IP Has Changed" $Body = $data | Out-String $SMTPServer = "smtp.gmail.com" $SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587) $SMTPClient.EnableSsl = $true $SMTPClient.Credentials = New-Object System.Net.NetworkCredential("username", "password"); $SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body) EXIT } ELSE { #If $a and $b are the same, exit echo 'IP Address has not changed' EXIT }
② 리눅스 [출처 https://bbs.archlinux.org/ ]
curl ifconfig.me | mailx -s "my IP" login@gmail.com
이외의 사이트 :
icanhazip.com