how to know is ip is local code example Example: get local ip hostname = socket.gethostname() local_ip = socket.gethostbyname(hostname)