Tag: address

Python

Hostname, Internal and External IP address in Python

Let’s see the code: import socket print "Hostname:", socket.gethostname() print "Internal IP:", socket.gethostbyname(socket.gethostname())   s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("google.com", 80)) print "External IP:", s.getsockname()[0] s.close()import socket print "Hostname:", socket.gethostname() print "Internal IP:", socket.gethostbyname(socket.gethostname()) s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("google.com", 80)) print "External IP:", s.getsockname()[0] s.close()

Linux

Configure Linux ip address, netmask and gateway

Change ip address of network interface card: ifconfig eth0 192.168.1.5ifconfig eth0 192.168.1.5 Change netmask of network interface card: ifconfig eth0 netmask 255.255.255.0ifconfig eth0 netmask 255.255.255.0 How to bring up the network interface card: ifconfig eth0 192.168.1.5 upifconfig eth0 192.168.1.5 up How to bring down the network interface card: ifconfig eth0 downifconfig eth0 down How to …