Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 07-18-2018, 01:34 PM   #1
LQ Newbie
Registered: Jul 2018
Posts: 1

Rep: Reputation: Disabled
Using the mangle packet filter with netfilter and iptables


I am trying to alter packets using iptables and netfilter in a c program based off the sample nfqnl_test.c file. In that file, it only showed that packets could be queue’d with the NF_QUEUE target (using the -j switch). I modified the utility to change the packets and then send it off using the nfq_set_verdict with a length and the packet:
return nfq_set_verdict(QueueHandle, id, NF_ACCEPT, len, pktb_data(pkt));
If I am using something like netcat to send UDP packets on the same machine, I am able to modify the packets and using tcpdump verify that they were altered:

iptables -A OUTPUT -d <dest ip address> -p udp -j NFQUEUE --queue-num 0
However, if I am doing something like a client sending out UDP packets to a server, and modifying them before being received by the server, I don’t see any evidence that the packets have been modified. In fact, the packets are only captured in the INPUT chain, and they never get sent out on the POSTROUTING chain. Here is one combination that I’ve tried that did not work:

iptables -t mangle -A INPUT -d <dest ip address> -p udp -j NFQUEUE --queue-num 1
iptables -t mangle -A POSTROUTING -d <dest ip address> -p udp -j NFQUEUE --queue-num 1
I’ve also tried different tables such as nat and raw with the same effect. Does anyone have any experience with trying to do this?



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to mangle a packet(Qos) using iptables houmingc Linux - Newbie 0 02-04-2015 12:44 PM
[SOLVED] what is advantage of nftables over iptables packet filter ? kikilinux Linux - Security 1 10-01-2014 04:26 PM
iptables -t filter INPUT first rule counter not updating on incoming packet zhjim Linux - Networking 6 09-07-2012 06:38 AM
Netfilter: mangle vs. filter zerg4141 Linux - Networking 2 04-28-2008 01:31 PM
How to filter this packet using iptables? montyleesam Linux - Security 1 05-12-2007 01:22 PM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:47 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration