Tag Archive for ip

IP address

<script language="Javascript" src="http://myipadress.info/index.php?template=Your IP is <IP>."></script>

source

Python – get Interface ethernet

from socket import *
import fcntl
import struct

def get_ip_address(ifname):

s = socket(AF_INET, SOCK_STREAM)
return inet_ntoa(fcntl.ioctl(s.fileno(), 0x8915, struct.pack('256s', ifname[:15]))[20:24])

source

Detect IP

if (getenv("HTTP_X_FORWARDED_FOR")) $ip = getenv("HTTP_X_FORWARDED_FOR");
else $ip = getenv("REMOTE_ADDR");

source

Dynamic IP update (to DNS service like zoneedit or dyndns) inside a local LAN or behind a router

#!/bin/sh
newip=`wget -o /dev/null -O - <a href="http://simple.showmyip.com" >http://simple.showmyip.com</a> | cut -f1 -d' ' | sed -n 1p`
presentip=`host myweb.com | sed -n 1p | cut -d' ' -f4`
if [ "$newip" != "$presentip" ]; then update_dns_ip.sh; fi

source