#! /usr/bin/env python # # pmtu.py client_ip server_ip rouer_ip mtu # # (c) 2009 by packetlevel.ch # # version 0.3 / 8.Nov.2009 # # # based on # ICMP message Type 3 code 4 (destination unreachable, don't fragment (DF) bit sent and fragmentation required) # # import requert parts # from scapy.all import * from sys import argv from sys import exit # # command line options # if len(argv) !=5: print"Usage:\n\tpmtu.py Client_IP Server_IP Router_IP MTU" print"\tExample pmtu.py 192.168.0.12 172.16.1.1 10.1.1.1 1000" sys.exit(0) ip_client = argv[1] ip_server = argv[2] ip_router = argv[3] mtu = int(argv[4]) # # build answer packet # ip = IP() icmp = ICMP() # # IP Packet sent to client # ip.dst = ip_client ip.src = ip_router # # icmp type 3 + code 4 # icmp.type = 3 icmp.code = 4 icmp.unused = mtu # # build original packet for ICMP ping request # ip_orig = IP() ip_orig.src = ip_client ip_orig.dst = ip_server icmp_orig = ICMP() icmp_orig.type = 8 icmp_orig.code = 0 # # send the packet # send (ip/icmp/ip_orig/icmp_orig)