Re: How to redirect the package from eth0 to eth2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tuesday 2011-01-11 04:22, Roc Bai wrote:
>>> Dear all:
>>> Â Â in my service, there are four net card. Âeth0, eth1, eth2, eth3. I
>>> want to forward the data in from eth0 to eth1, eth2, eth3 with
>>> different application protocol. Does some body send me some ideas on
>>> it?
>>
>> If you want to re-route packages, that has to happen in pre-routing.
>> If you want to use DNAT for examples, just add a rule to the
>> PREROUTING chain in the nat table.
>
>I think the DNAT should change the package data, including the IP or
>higher level protocol header, isn't it?

That is the point of NAT. NAT is _not_ routing/forwarding (dammit).
And it's "packet", not "package".

>I think the best idea which can redirect the package is to add/change
>the route rule to do it. I have write some source codes which doesn't
>work.

That's redundant (and as you can see, error prone). Just use
the iproute utilities to define extra rules and routes, which
are known to work.

>ncf_get_entry() can generate a dst_entry whose dev point to the eth2
>net_device structure. But when i use tcpdum -i eth2. I cannot get the
>package from eth0. So it doesn't work.

I don't expect it to. You are using a global variable, which is not
SMP-safe without a lock.
You might find Paul McKenny's Parallel Programming Book helping.

>static struct dst_entry gdst;
>static int ncfflag = 0;
--
To unsubscribe from this list: send the line "unsubscribe netfilter" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Netfilter Development]     [Linux Kernel Networking Development]     [Netem]     [Berkeley Packet Filter]     [Linux Kernel Development]     [Advanced Routing & Traffice Control]     [Bugtraq]

  Powered by Linux