Linux Netfilter discussions
 help / color / mirror / Atom feed
* Re: iptables resources consumed
@ 2008-07-04  5:22 Elison Niven
  2008-07-04  6:26 ` Grant Taylor
  0 siblings, 1 reply; 12+ messages in thread
From: Elison Niven @ 2008-07-04  5:22 UTC (permalink / raw)
  To: netfilter

Hi,

I'd just like to clarify a few things I should have done before.

1) Eth0 and eth2 will always be in different subnets.
2) All RTP traffic that has to be sent to the DSPs will always arrive to
eth0.

> I'm concerned about traffic coming in eth0 going to the DSP connected to 
> eth2.  What IP do you send it to, the one being spoofed or the internal 
> one?  When the client send this traffic, will the reply come from the 
> same IP or will it be a different IP?  I see too much that could go 
> wrong in this that should not happen in normal traffic.

> *OR* is the IP spoofing not for the source IP of the packets leaving the 
> DSP but rather for an IP that is included as a value with in the payload 
> in the packet from the DSP, much like FTP packets include the port 
> number that they want to use or how you sometimes have to specify an 
> external IP for SIP VoIP devices behind a NAT.

Eth2 is an internal IP address. The system is known only by one IP address
to the outer world - that of eth0.

Consider an example: My System's IP is eth0 - 192.168.1.50, subnet mask -
255.255.255.0
Eth2 (internal) is 192.168.2.50, The DSPs are 192.168.2.51 to 192.168.2.58,
subnet mask - 255.255.255.0
The default gateway of the DSPs is eth2 - 192.168.2.50.

There is a voice call from another device at 192.168.1.100 to 192.168.1.50.

Outside the system, the following transfers are visible (say in
wireshark/ethereal):

192.168.1.100 --> Sends RTP:
src IP = 192.168.1.100
dest IP = 192.168.1.50
src port = 8000
dest port = 10000

My system 192.168.1.50 --> Sends RTP:
Src IP = 192.168.1.50
Dest IP = 192.168.1.100
Src port = 10000
Dest port = 8000

Inside the system, the RTP is actually generated by the DSPs, say DSP1 here.

DSP1 --> Sends RTP:
Src IP = 192.168.1.50 - This is IP spoofing. DSP1's actual IP is
192.168.2.51. This is the IP as seen in the source IP field in the IP
header.
Dest IP = 192.168.1.100
Src port = 10000
Dest port = 8000

This traffic is received on eth2 and must be sent out through eth0.
The purpose of faking the IP is not to have to do SNAT on such packets.

The traffic that the other device is sending is received on eth0.
Such traffic is forwarded to DSP1.

Each of the DSPs also sends control packets that are always sent as:

Src IP = DSPs actual IP address = 192.168.2.51
Dest IP = eth2 = 192.168.2.50

Such packets need to be sent to a local process on the CPU.

So I guess the minimal rules needed will be:

1) For packets received on interface eth2

IF Destination IP != eth2 IP
THEN send the packet out from eth0
ELSE send it to the CPU

2) For packets received on interface eth0

Now the system will be listening for http, telnet and ftp connections on
their fixed port numbers.
The system will also be listening for SIP connections to a fixed port - say
5060.
Such packets obviously need to be sent to the CPU.
Does that mean I have to check the destination port number of all the
packets received?

IF Dest port of packet == 80 (http) OR 21(ftp) OR 23(telnet) OR 5060(sip).
(Does this becomes a single rule or more than one?)
THEN send packet to the CPU
ELSE goto below rules

For all other packets received, the rule will be (for the example above):

IF Source IP == 192.168.1.100 and destination port == 10000. Again does this
become 2 different rules?
If I also check the source port of the packet here, will that add a new
rule?
THEN send the packet to DSP1. This will require a DNAT I think.
ELSE drop the packet.

Now I intend to (horribly) support 256 such calls and I need to figure out
the minimal rules that would be required.

(Ofcourse, I see above that there would be some (don't know how many)
problems when an external device with IP = 192.168.2.51 wants to talk to my
system, But we'll get to it later.)

Best Regards,
Elison



^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: iptables resources consumed
@ 2008-07-03  5:09 Elison Niven
  2008-07-03  7:25 ` G.W. Haywood
  2008-07-03  9:34 ` Grant Taylor
  0 siblings, 2 replies; 12+ messages in thread
From: Elison Niven @ 2008-07-03  5:09 UTC (permalink / raw)
  To: netfilter

Hi, 

Grant - Thanks a lot for your reply. 

>Question:  What do you want to do with packets that do not match the 
>above rules?
I would just like to discard them.

Yes, I would be using a custom built kernel for PowerPc.
It is now clear that I will have a maximum of 256 (may be 256*2 or 3 !)
rules on eth0 and just 1 rule on eth2.

To make things complex, the PowerPc communicates with the DSPs through
ethernet on eth2.
Each DSP has a control Port number and the PowerPc controls the DSPs through
packets sent at this port number on the DSP. The DSPs respond to these
commands through ethernet packets (that are received on eth2).

Such packets need to be sent to a process on the PowerPc and not forwarded
out on eth0.

The rule on eth2 will be :  If source port of the packet is not a DSP
control Port Number , send the packet out from eth0 and replace source IP
with ip = eth0.

If all the DSPs have different control port numbers that would increase the
checking - Source IP and Source Port per packet, So I prefer to have the
same control port numbers on all the DSPs.

Now If the DSP itself *fakes* the source IP of the packets it generates,
then may be the rule can be simpler : Check the source port of the packet.
If it is not equal to the control port number just send it out *as it is*
from eth0. If source port is equal to the control port number, send it to a
local process.

Please correct me if I am missing something.

>>There will be a lot of traffic flying through this kernel.

Yeah, the mere thought of it puts me in panic! I do not have any prior
experience with iptables. As from your experience, Do you a think a custom
powerc kernel running at 400 MHx,256 MB DDR2 RAM should be able to perform
this task well.

Best Regards,
Elison



^ permalink raw reply	[flat|nested] 12+ messages in thread
* iptables resources consumed
@ 2008-07-02  4:29 Elison.Niven
  2008-07-02 19:00 ` Grant Taylor
  0 siblings, 1 reply; 12+ messages in thread
From: Elison.Niven @ 2008-07-02  4:29 UTC (permalink / raw)
  To: netfilter

Hi List,

I am looking to run iptables on an embedded powerpc system.
It’s the first time I’ll be using it. I need to have a few confusions cleared out.

There are three ethernet interfaces on the system: eth0, eth1 and eth2.
___________________________________
|                                  |
|         ___________              |
|        |           |             |
|        |  Powerpc  |             |
|        |           eth2          |
|        |           |             |
|        |_eth0_eth1_|             |
|                                  |
|       _______        ________    |
|_______|      |_______|       |___|
         eth0           eth1

eth0 and eth1 are external interfaces to the system. eth2 is internal.
eth2 is connected to another L2 switch on the same board behind which are 8 DSPs.

For now do not consider eth1. There are only 2 interfaces eth0 and eth2.

I need to forward UDP packets received on eth0 to eth2 and send them to a particular DSP, and also forward packets received on eth2 to eth0.

General rule: All outgoing packets from eth0 should have src ip = eth0 ip.

Example rules:

Rule 1: a)Packets received on eth0 with src IP address = X, dest port = 8000 should be sent to DSP1, port = 8000.
b)Packets received on eth2 (i.e from the L2switch) with src IP = DSP1 IP OR dest IP = X, dest port = 10000 should be sent on eth0 to IP address X, port = 10000.

Rule 2: a)Packets received on eth0 with src IP address = Y, dest port = 9000 should be sent to DSP2, port = 9000.
b)Packets received on eth2 (i.e from the L2switch) with src ip = DSP2 IP OR dest IP = Y, dest port = 11000 should be sent on eth0 to IP address Y, port = 11000.

I will have a maximum of 256 such rules i.e effectively 256*2 = 512 rules. (256 for packets received on eth0, 256 for packets received on eth2)

I am assuming that a packet is received every 20 ms on eth0 and eth2 for a single rule.
So for a total of 256, 256 packets are received every 20 ms on eth0 and 256 packets are received every 20 ms on eth2.

Or I can make eth2 IP address as the default gateway of all the DSPs. The DSPs will send packets with dest IP address = X, Y etc. These packets should be sent out through eth0 and should have source IP = eth0. This will eliminate rules 1b and 2b above. Thus, packet filtering to read src IP and dest port will only be on eth0. Now total rules will be 256.

The processor will be running at 400 MHz, 256 MB DDR2 RAM using Linux kernel 2.6.10.

Will it be able to do this task and also run the main application? How much resources will iptables require?

Regards,
Elison




^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2008-07-07 15:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-04  5:22 iptables resources consumed Elison Niven
2008-07-04  6:26 ` Grant Taylor
2008-07-04  9:12   ` re : " Elison Niven
2008-07-05 23:46     ` Grant Taylor
2008-07-07  5:32       ` Elison Niven
2008-07-07 15:04         ` Grant Taylor
2008-07-07 15:49         ` Grant Taylor
  -- strict thread matches above, loose matches on Subject: below --
2008-07-03  5:09 Elison Niven
2008-07-03  7:25 ` G.W. Haywood
2008-07-03  9:34 ` Grant Taylor
2008-07-02  4:29 Elison.Niven
2008-07-02 19:00 ` Grant Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox