Return to Snippet

Revision: 1815
at November 9, 2006 23:59 by whitetiger


Updated Code
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])

Revision: 1814
at November 9, 2006 23:55 by whitetiger


Initial Code
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])

Initial URL

                                

Initial Description

                                

Initial Title
Python - get Interface ethernet

Initial Tags
regex, python, ip

Initial Language
Python