#!/usr/bin/perl use Net::RawIP qw(:pcap); # create PCAP object # $in = new Net::RawIP({ udp => {} }); $out = new Net::RawIP({ udp => {} }); # set capture parameters # $device = 'ne3'; $filt = 'ip proto UDP and src port not 2200 and dst port 123'; $size = 65535; $tout = 1; $pcap = $in->pcapinit($device,$filt,$size,$tout); loop $pcap,-1,\&callback,\@out; # callback for every capture # sub callback{ print "Captured ntp and re-transmit to port 2200...\n"; $out->set({ip => {saddr => 'nimbus4.localnet', daddr => '192.168.2.255'}, udp => {source => 2200, dest => 123, data => substr($_[2], 42, length($_[2]))} }); $out->send(10,1); }