Linux for Network Engineers: Identify a TCP connection with p0f

By April 22, 2020Linux

We have talked about how to use nmap to detect the OS of a remote host. Nmap does that by sending probing packets and depending on the responses may or may not be able to identify the remote OS with a certain accuracy. 

That can work well in many cases, but there are two drawbacks: a) it can be slow, taking several seconds to complete the process b) if the remote host doesn’t respond to the probing packets the identification fails.

Another tool that can do OS identification is p0f. The main difference with nmap is that p0f relies on passively capturing TCP connection information and by fingerprinting it, it manages to identify the OS of the remote host. This has the advantage of being real-time and very fast, but the drawback is that it needs the remote host to initiate a TCP connection to capture the traffic and do the identification. 

Both nmap and p0f may give wrong information, or not be as specific as we’d like it (for example, they may say it’s a Windows remote host without being able to identify between Windows 7 or 10). Both solve the same problem in their own unique way, and you need to decide which one to use depending on the specifics or your problem.

p0f is mainly used when doing forensics or security scans, and it’s a well known tool to infosec and a standard package for Kali Linux, the Linux distributions tailored to security engineers.

Let’s see how p0f is used and what information provides.


Installing p0f on Debian based Linux can be done with:


To get a list of all available interfaces on your system use the following:

As you may have guessed the interfaces I can readily use are “eth0” and “wlan0”.

Let’s capture traffic on interface eth0 and identify the OS the remote hosts:

Once you start p0f you won’t see any output unless a remote host tries to initiate a connection. To get the previous output, I started an ssh connection with ssh from my Windows 10 machine. As you can see p0f identified that my machine is running “Windows NT kernel.” Not as accurate as I would like it to be, but it looks like p0f has no way to identify between the different Windows distributions at the time being.

In addition, it gives the ports used on the two ends of the connection, the MTU (“raw_mtu  = 1500”), the type of connection (“link = Ethernet or modem”), and the number of hops between the two hosts (“dist = 0”). The “raw_sig” field is the signature encoding used by p0f in it’s fingerprint library.

You can get similar results by opening a browser and typing in the address bar. Even if there is no HTTP server running on, the HTTP request generates TCP traffic which is enough to identify the OS.

The good thing is that if a new way comes up to differentiate between Windows distributions, you can update the p0f fingerprint library ( /etc/p0f/p0f.fp) and improve p0f’s accuracy. You can also give your own fingerprint library with ( -f file_path) option.

Going back to the difference between nmap and p0f, I tried (  nmap -O ( is my Windows 10 machine) and I didn’t get a response because Windows doesn’t respond to nmap’s probe requests. 

p0f is simple to use and has a few more options, such as running  as a daemon on the background ( -d), logging the output in a file ( -o), or getting input from a pcap file instead of an interface ( -r). 

It is a specialized tool, and for what it does is pretty good at it. Comparing it directly to nmap is a bit of apples-vs.-oranges comparison because nmap does so much more, but nmap is the closet tool I know off. All said and done, I think it’s the clear choice if you are looking to do OS identification of incoming connections on a host.