Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Scapy ping an IP using ICMP

  • In one window use ifconfig to get the name of the interface or use "any"
tcpdump -nn host 8.8.8.8 -i any
tcpdump -nn host 8.8.8.8
  • In another window run
ping -c 1 8.8.8.8
10:15:40.705266 IP 192.168.1.204 > 8.8.8.8: ICMP echo request, id 17, seq 1, length 64
10:15:40.761960 IP 8.8.8.8 > 192.168.1.204: ICMP echo reply, id 17, seq 1, length 64
import scapy.all as scapy
scapy.send(scapy.IP(dst="8.8.8.8")/scapy.ICMP())
sudo /opt/venv3/bin/python ping_other.py
10:18:18.497851 IP 192.168.1.204 > 8.8.8.8: ICMP echo request, id 0, seq 0, length 8
10:18:18.554260 IP 8.8.8.8 > 192.168.1.204: ICMP echo reply, id 0, seq 0, length 8