Send ICMP to update ARP/NDP target’s cache
This commit is contained in:
parent
52dc461d28
commit
833a06ce8d
|
@ -194,6 +194,8 @@ for ID_RANGE_V4 in ${ID_RANGES_V4}; do
|
||||||
if [ $? = 2 ]; then
|
if [ $? = 2 ]; then
|
||||||
ip neigh replace ${VM_IPV4} lladdr ${MAC} dev ${IFACE}
|
ip neigh replace ${VM_IPV4} lladdr ${MAC} dev ${IFACE}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
GW_IPv4=$(jq -r ".data[] | select(.is_gateway==\"1\") | .ip" ${CHEMIN_CACHE}/${ID_RANGE_V4})
|
||||||
else
|
else
|
||||||
# En cas d'echec, on continue de parcourir les autres RANGES
|
# En cas d'echec, on continue de parcourir les autres RANGES
|
||||||
write_log WARN 'Empty value or doen’t correspond to an IPv4'
|
write_log WARN 'Empty value or doen’t correspond to an IPv4'
|
||||||
|
@ -237,11 +239,16 @@ for ID_RANGE_V6 in ${ID_RANGES_V6}; do
|
||||||
if [ $? = 2 ]; then
|
if [ $? = 2 ]; then
|
||||||
ip neigh replace ${VM_NH} lladdr ${MAC} dev ${IFACE}
|
ip neigh replace ${VM_NH} lladdr ${MAC} dev ${IFACE}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
GW_IPv6="fe80::204:92:100:1"
|
||||||
else
|
else
|
||||||
# En cas d'echec, on continue de parcourir les autres RANGES
|
# En cas d'echec, on continue de parcourir les autres RANGES
|
||||||
echo "Valeur vide ou ne correspond pas à un range IPV6"
|
echo "Valeur vide ou ne correspond pas à un range IPV6"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Send ICMP to update ARP/NDP cache
|
||||||
|
send-icmp.py ${MAC} ${IFACE} ${VM_IPV4} ${GW_IPv4} ${VM_NH} ${GW_IPv6}
|
||||||
|
|
||||||
write_log INFO 'Script ended'
|
write_log INFO 'Script ended'
|
||||||
exit 0
|
exit 0
|
||||||
|
|
18
send-icmp.py
Executable file
18
send-icmp.py
Executable file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
from scapy.all import *
|
||||||
|
|
||||||
|
etherDest= sys.argv[1]
|
||||||
|
iface= sys.argv[2]
|
||||||
|
|
||||||
|
ipDest= sys.argv[3]
|
||||||
|
ipSrc= sys.argv[4]
|
||||||
|
|
||||||
|
# send 10 IPv4 ICMP echo requests
|
||||||
|
sendp(Ether(dst=etherDest)/IP(dst=ipDest, src=ipSrc, ttl=(1,10))/ICMP(), iface=iface)
|
||||||
|
|
||||||
|
ipDest= sys.argv[5]
|
||||||
|
ipSrc= sys.argv[6]
|
||||||
|
|
||||||
|
# send 10 IPv6 ICMP echo requests
|
||||||
|
sendp(Ether(dst=etherDest)/IPv6(dst=ipDest, src=ipSrc, hlim=(1,10))/ICMPv6EchoRequest(), iface=iface)
|
Loading…
Reference in a new issue