LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


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

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


Hello,

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:
Code:
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:

Code:
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:

Code:
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?


Thanks,
Todd
 
  


Reply


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 11:44 AM
[SOLVED] what is advantage of nftables over iptables packet filter ? kikilinux Linux - Security 1 10-01-2014 03:26 PM
iptables -t filter INPUT first rule counter not updating on incoming packet zhjim Linux - Networking 6 09-07-2012 05:38 AM
Netfilter: mangle vs. filter zerg4141 Linux - Networking 2 04-28-2008 12:31 PM
How to filter this packet using iptables? montyleesam Linux - Security 1 05-12-2007 12:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:40 AM.

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