Forrest logo
back to the ss tool

ss:tldr:96a00

ss: Show all UDP sockets connected on specific source and destination ports.
$ ss -u 'sport == :${source_port} and dport == :${destination_port}'
try on your machine

The command you provided is using the ss command-line tool with the -u option, which instructs ss to display UDP sockets.

The argument 'sport == :${source_port} and dport == :${destination_port}' is a filter expression that is passed to ss. Let's break it down:

  • sport == :${source_port}: This part checks if the source port of a UDP socket matches the value specified by the source_port variable. The :${source_port} syntax is used to reference a variable value.

  • and: This operator is used to combine multiple conditions. In this case, it is used to combine the source port condition and the destination port condition.

  • dport == :${destination_port}: This part checks if the destination port of a UDP socket matches the value specified by the destination_port variable. Similar to the previous condition, :${destination_port} references the value of the destination_port variable.

In summary, the ss command with this filter expression is used to display UDP sockets where both the source port and destination port match the values stored in the source_port and destination_port variables, respectively.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the ss tool