I’ve written a short netfilter hook to help snoop some outgoing packets. You can view the source code here. I read a few articles to get an idea of how to put things together.