import socket s = socket.socket() s.bind((get_ip_address('eth0'), 0)) s.connect(('http://www.google.com/', 80))