# from pyroute2 import IPRoute
# ip = IPRoute()
# index = ip.link_lookup(ifname='eth0')
# print(index)
# ip.addr('add', index, address='192.168.1.0', mask=24)
# ip.close()

import os
ip='192.168.2.4'.split(".")
res= True if (ip[0]+"."+ip[1]+"."+ip[2] in str(os.popen('ip addr show dev eth0|grep "net "| sed "s/\/24.*//g" | sed "s/inet //g"').read())) else os.system('sudo ip address add '+ip[0]+"."+ip[1]+"."+ip[2]+'.0/24 dev eth0')
print(res)
# print('192.168.0.0' in str(res))
print(ip[0]+"."+ip[1]+"."+ip[2])