Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to generate UDP packet to test a program, something equivalent to using telnet to test TCP port (Can telnet generate UDP packet?)

How can I do this?

share|improve this question
add comment

2 Answers

up vote 10 down vote accepted

One word: Netcat

Netcat is the go-to tool for this sort of thing.

You can thrash whatever port you choose with udp packets with something like:

nc -u host.example.com 53 << /dev/random

(53 is your port number)

Or you can send an actual file, or tell it to bind that port and listen as a service, or whatever you like.

share|improve this answer
    
I don' think << is a valid Bash redirect. You probably mean <? –  mehaase Mar 21 '13 at 18:07
add comment

If you want to merely send one UDP packet with some specified data, as opposed to Satanicpuppy's answer which continuously sends random data, you can do:

echo "foo" | nc -w1 -u 111.22.333.4 20000
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.