my linux pc has a udp port listening, however, the application does not seem to receive any packets from this port. Is there any tool that I can use to show the number of packets received on this port?

  • Note that any answers about iptables assume that you have iptables running, which is probably likely, but not guaranteed. – Jed Daniels Nov 20 '15 at 19:46

You can log them using iptables:

iptables -A INPUT -p udp -j LOG --log-prefix "udp connection: "
|improve this answer|||||
  • Thanks. But I get the following result "iptables: No chain/target/match by that name." what is wrong? – pepero Nov 18 '15 at 16:54
  • It sounds like iptables is disabled on your server. What distribution are you using? – chicks Nov 18 '15 at 19:43
  • it is centos 6. iptables is there. but when i use the command "iptables -A INPUT -j LOG", it will complain: iptables: No chain/target/match by that name." what is special with LOG target? – pepero Nov 19 '15 at 10:37

Use tcpdump. For example, on my machine, the interface I'm looking for the traffic on is eth0, and in this case I'm checking port 123.

jed@myhost:~$ sudo tcpdump -nei eth0 udp port 123

If you don't know what the interfaces on your machine are, you can get them with ifconfig -a or ip link (either might require sudo, depending on your permissions).

|improve this answer|||||

If you just want counters for a particular protocol, then you can create an iptables rule to accept those packets, and it will keep track of how many packets and bytes matched the rule.

If you wanted to match packets on UDP port 44, the iptables command would look like:

iptables -A INPUT -i eth0 -p udp --dport 44 -j ACCEPT

If you want more details about those packets, then as Jed Daniels has said, tcpdump is gonna be your best bet.

tcpdump -nei eth0 udp port 44
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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