Skip to contentSkip to conversation

Mangling IP Options fields

DISCUSSION Quinton Hoole 3 participants 7 messages May 16, 2005

lore
Share & tools
lore
#0 lore raw

Hi

This newbie needs to add and/or rewrite data in the IP Options fields. The MANGLE chain looks like the place to do this, but I don't see the appropriate target extensions to achieve it. It seems easy to mangle most other fields (DSCP, ECN, TOS, TTL etc) but no mention of the OPTIONS fields.

Is mangling of IP options fields supported by netfilter/iptables?

If not, I'm going to have to make it happen some how. Any pointers towards the recommended approach in this regard would be appreciated. I'm assuming that I'll have to alter the netfilter/iptables code appropriately, which is not a problem.

Thanks in advance...

Quinton

#1 lore raw
Quoted 7 lines · Quinton Hoole

This newbie needs to add and/or rewrite data in the IP Options fields. The MANGLE chain looks like the place to do this, but I don't see the appropriate target extensions to achieve it. It seems easy to mangle most other fields (DSCP, ECN, TOS, TTL etc) but no mention of the OPTIONS fields.

Is mangling of IP options fields supported by netfilter/iptables?

Which IP options are you looking to be able to mangle? If you just need to be able to mangle the MSS, then check out the TCPMSS target included in the vanilla Linux kernel. This would also be a good place to start if you need to create an iptables target that mangles an IP option of another type. You might also check out the IPV4OPTSSTRIP target in patch-o-matic (http://svn.netfilter.org), but I don't know how much utility this will have for you.

Signature · 2 lines
[ Tobias DiPasquale ]
0x636f6465736c696e67657240676d61696c2e636f6d
#2 lore raw
Quoted 9 lines · Tobias DiPasquale
Quoted 6 lines · Quinton Hoole

This newbie needs to add and/or rewrite data in the IP Options fields. The MANGLE chain looks like the place to do this, but I don't see the appropriate target extensions to achieve it. It seems easy to mangle most other fields (DSCP, ECN, TOS, TTL etc) but no mention of the OPTIONS fields.

Quoted 8 lines
Quoted 3 lines

Is mangling of IP options fields supported by netfilter/iptables?

Which IP options are you looking to be able to mangle? If you just need to be able to mangle the MSS, then check out the TCPMSS target included in the vanilla Linux kernel.

I'll be needing to mangle other fields. My ultimate goal is to "stamp" a 32 or 64 bit value into each packet for security reasons.

Quoted 4 lines

This would also be a good place
to start if you need to create an iptables target that mangles an IP option of another type.

Great, thanks.

Q

#3 lore raw
In reply to Quinton Hoole

Hi all!
You don't want "to alter the netfilter/iptables code", libipq can resolve your problem if you dont't want high speed or if you only need you mangle some packet. besides you can uses libipq to prototype the final implementation. Look up in this list messages which have in subject the word libipq. Other source of information is man libipq. In the web there is many examples of programs that alter the IP header.

Salute
Frank Abel

----- Original Message -----
From: "Quinton Hoole" <[email protected]>
To: <[email protected]>
Sent: Monday, May 16, 2005 5:22 AM
Subject: Mangling IP Options fields

Quoted 19 lines

Hi

This newbie needs to add and/or rewrite data in the IP Options fields. The MANGLE chain looks like the place to do this, but I don't see the appropriate target extensions to achieve it. It seems easy to mangle most other fields (DSCP, ECN, TOS, TTL etc) but no mention of the OPTIONS fields.

Is mangling of IP options fields supported by netfilter/iptables?

If not, I'm going to have to make it happen some how. Any pointers towards the recommended approach in this regard would be appreciated. I'm assuming that I'll have to alter the netfilter/iptables code appropriately, which is not a problem.

Thanks in advance...

Quinton

#4 lore raw
Quoted 8 lines · Frank Abel

Hi all!
You don't want "to alter the netfilter/iptables code", libipq can resolve your problem if you dont't want high speed or if you only need you mangle some packet. besides you can uses libipq to prototype the final implementation. Look up in this list messages which have in subject the word libipq. Other source of information is man libipq. In the web there is many examples of programs that alter the IP header.

Quoted 5 lines

Salute
Frank Abel

Thanks Frank

I looked into the libipq user space queueing option, but unfortunately switching to user space is not feasble in my case (every single packet on a GBit ethernet needs to be stamped, and resource utilisation is a big issue). Some further reading of the netfilter FAQ has revealed that patch-o-matic based extensions seem to be the way that others have achieved things similar to my aims.

http://www.netfilter.org/documentation/HOWTO//netfilter-extensions-HOWTO-4.html

Can anyone confirm that I'm heading in the right direction?

Thanks in advance...

Quinton

Quoted 40 lines

----- Original Message -----
From: "Quinton Hoole" <[email protected]>
To: <[email protected]>
Sent: Monday, May 16, 2005 5:22 AM
Subject: Mangling IP Options fields

Quoted 21 lines

Hi

This newbie needs to add and/or rewrite data in the IP Options fields. The MANGLE chain looks like the place to do this, but I don't see the appropriate target extensions to achieve it. It seems easy to mangle most other fields (DSCP, ECN, TOS, TTL etc) but no mention of the OPTIONS fields.

Is mangling of IP options fields supported by netfilter/iptables?

If not, I'm going to have to make it happen some how. Any pointers towards the recommended approach in this regard would be appreciated. I'm assuming that I'll have to alter the netfilter/iptables code appropriately, which is not a problem.

Thanks in advance...

Quinton

#5 lore raw
Quoted 10 lines · Quinton Hoole

I looked into the libipq user space queueing option, but unfortunately switching to user space is not feasble in my case (every single packet on a GBit ethernet needs to be stamped, and resource utilisation is a big issue). Some further reading of the netfilter FAQ has revealed that patch-o-matic based extensions seem to be the way that others have achieved things similar to my aims.

http://www.netfilter.org/documentation/HOWTO//netfilter-extensions-HOWTO-4.html

Can anyone confirm that I'm heading in the right direction?

You are headed in the right direction. I will say two more things:

1. What you are trying to do is very simple and shouldn't require much deviation from iptables targets that already exist w/r/t coding ability. Just make sure you know the pertinent RFCs and have a fast machine to compile on.

2. You will need 2-3 CPUs (x86) to keep up with GBit forwarding + netfilter.

Signature · 2 lines
[ Tobias DiPasquale ]
0x636f6465736c696e67657240676d61696c2e636f6d
#6 lore raw
Quoted 8 lines · Quinton Hoole
Quoted 6 lines

big issue). Some further reading of the netfilter FAQ has revealed that patch-o-matic based extensions seem to be the way that others have achieved things similar to my aims.

Quoted 8 lines
Quoted 5 lines

http://www.netfilter.org/documentation/HOWTO//netfilter-extensions-HOWTO-4.html

Can anyone confirm that I'm heading in the right direction?

Incidently, I'd ideally like to avoid patching the kernel (for fairly obvious reasons). Is anyone aware of a way to instruct something in kernel space (in the standard kernel) to stamp values into the IP options fields. I understand that this does not appear to be possible with the standard netfilter implementation, but perhaps there is another kernel module which will do the trick? Any pointers appreciated.

Quinton