Redirect bridged traffic

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

 



      Hello,

   I have a device with 3 NICs connected to two networks as follow:
1. eth0 connected to monitor network used for accessing my device and do configurations.
2. eth1 connected to main network which contains routers, DHCP server, NTP server, etc.
3. eth2 connected with a direct cable to a device (PC0) supposed to be part of the main network.

My device needs to pass through the entire traffic between PC0 and the main network excepting the one connecting on port 3000 of PC0 which needs to be redirected to a local process. The local process at it's turn needs to connect to PC0 on port 3000 and the replies to be passed back to the main network client.

For this I have created a bridge which is able to pass all the traffic between eth1 and eth2:
brctl addbr br0
brctl addif br0 eth1
brctl addif br0 eth2

ip link set br0 up

Using this, the PC0 is able to access all services from the main network (i.e DHCP for getting the IP address). Though the performances of the bridge is much lower than expected, the speed being almost 6x lower comparing to direct access of PC0 to main network.

For redirecting the traffic I was trying to use the nftables configuration below:

#!/usr/sbin/nft -f

flush ruleset

define MON_MAC=00:0c:29:15:7b:a0
define TPORT

table bridge tbrFilter {
    chain cbrRedirect {
      type filter hook prerouting priority 0;
      log tcp dport $TPORT meta pkttype set host ether daddr set $MON_MAC counter
    }
}

table inet tlcRedirect {
    chain clcRedirect {
      type nat hook prerouting priority 0;
      log tcp dport $TPORT counter redirect to $TPORT
    }
}

Using this configuration, the connection to PC0:3000 seems that it is captured by the nft but is not going to the local process.

What I am missing here?

Thanks and best regards,
Jaga.



[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