How to use nc (netcat) to print headers sent by a browser

Unix utility nc (netcat) is a pretty handy utility for many network tasks. One such use is to see what headers are being sent by a browser to the server. Here are the steps:

  1. First run nc in server listening mode on a specific port. Use the command:
    nc -l 8080
    This will immediate create a quick server listening on port 8080. You can use some other port also. In case you want to use 80 which is default web server port then you will need to run this command as root.
    sudo nc -l 80
    For the purpose of this post we will use 8080.
  2. Assuming you have a domain name which is mapped to the ip address of this machine you can try to access that domain on port 8080 in browser (chrome, firefox or internet explorer). Or use the ip address of the machine where you are running nc e.g. http://192.168.100.103:8080/
    nc-netcat-browser-8080
  3. Here is the outcome for chrome:
    nc netcat chrome headers

This can be pretty handy at times when you don’t have any easy way to view headers sent by the browser or any other client process.

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments