Получение MAC и IP адресов без утилиты ifconfig.

legacy
parent 6c2103d92b
commit 29425ac4e2

@ -21486,30 +21486,11 @@ network %s")%net)
def getMacInIp(self, ip):
"""Находит mac адрес по ip адресу"""
netInterfaces=cl_utils.getdirlist("/sys/class/net/")
flagFound = False
for i in netInterfaces:
execStr = "/sbin/ifconfig %s"%i
res = self.execProg(execStr, None, False)
if not res:
break
mac = ""
for line in res:
sMac = re.search('HWaddr\s+(([0-9a-f]{2}:){5}[0-9a-f]{2})',\
line)
if sMac:
# mac адрес
mac = sMac.groups()[0]
continue
sIP = re.search('addr:([0-9\.]+).+Bcast:', line)
if sIP:
Ip = sIP.groups()[0]
if ip == Ip and mac:
flagFound = True
break
if not flagFound:
mac = ""
return mac
for iface in cl_utils.getInterfaces():
mac,iface_ip = cl_utils.getMac(iface),cl_utils.getIp(iface)
if iface_ip == ip and mac:
return mac.lower()
return ""
def setupDhcpServer(self, options):
"""Начальная настройка DHCP сервиса"""

Loading…
Cancel
Save