linux环境获取接口IP地址
来源:互联网 发布:mac ae2017百度云盘 编辑:程序博客网 时间:2024/06/05 03:13
获取IP:
#!/usr/bin/env python
import socket
def Get_local_ip():
"""
Returns the actual ip of thelocal machine.
This code figures out whatsource address would be used if some traffic
were to be sent out to somewell known address on the Internet. In this
case, a Google DNS server isused, but the specific address does not
matter much. No traffic isactually sent.
"""
try:
csock =socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
#csock.connect(('8.8.8.8',80))
csock.connect(('8.8.8.8',80))
(addr, port) =csock.getsockname()
csock.close()
return addr
except socket.error:
return"127.0.0.1"
if __name__ == "__main__":
local_IP = Get_local_ip()
print(local_IP)
阅读全文
0 0
- linux环境获取接口IP地址
- linux 接口IP地址获取
- IP地址获取接口
- linux获取IP地址
- Linux 接口地址的获取-暨获取本地IP地址(所有地址,包括IPv4,IPV6,MAC 地址)
- linux C获取IP地址
- linux c获取IP地址
- Linux不能获取ip地址
- linux编程获取ip地址
- C#获取IP地址接口编程
- 获取指定网络接口的IP地址
- 获取ethx 接口的IP地址
- 调用新浪IP接口,获取地址信息
- 获取调用接口的客户端ip地址
- 根据网络接口名获取IP地址
- linux下获取MAC地址,IP地址
- linux和Qt下获取本机每个接口的ip地址
- 在scapy上获取接口IP地址和mac地址
- 关于Mysql的死锁问题(未完待续)
- unity-与skynet通信二三事(sproto,crypt)
- maas中node的几种状态和动作
- JVM配置远程debug
- MySQL索引原理及慢查询优化
- linux环境获取接口IP地址
- js获取两个日期之间的所有日期
- Oracle GoldenGate内存要求
- eclipse oxygen4.7.0: html标签<option></option>内嵌入jstl报错
- JVM 工作原理和流程
- C/C++ 程序中的多文件组织
- Okio读写流源码详解(第四篇(GzipSink压缩源码详解))
- 垃圾回收
- iTunes升级 如何获取app stores 应用连接