Skip to content

Instantly share code, notes, and snippets.

@pwrliang
Last active November 25, 2018 13:06
Show Gist options
  • Save pwrliang/4e9076015d7f41ead2b8d4c87fef16ae to your computer and use it in GitHub Desktop.
Save pwrliang/4e9076015d7f41ead2b8d4c87fef16ae to your computer and use it in GitHub Desktop.
ReportIP
url=https://***************/post_ip.php?ip=
while true
do
main_ipv4=`ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'|head -n 1`
main_ipv6=`ifconfig | awk '/inet6/{print $2}'|head -n 1`
curl -k $url"\"$main_ipv4-$main_ipv6\""
sleep 5
done
#crontab -e
#@reboot nohup /opt/post_ip.sh &
<?php
$ip_path = '/tmp/request.log';
if(isset($_GET['ip'])) {
$ip = $_GET['ip'];
$fp = fopen($ip_path, 'w');
fwrite($fp, $ip);
fclose($fp);
} else if(file_exists($ip_path)) {
$fp = fopen($ip_path, 'r');
$ip = fgets($fp);
fclose($fp);
echo $ip;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment