HELLO_wORLD
Very Senior Member
Hello,
I hope everyone is having a great Sunday
I am looking for help from the master gurus out here.
My goal is simple: I want to be able to capture in iptables some packets generated locally by raw sockets to tee them to my IDS (I am able to tee everything coming through the router, to the router and from the router, except those few packets generated in the router via raw sockets like dhcpd does for example).
Raw socket packets are bypassing iptables, and can only be seen in the OUTPUT chain of ebtables.
Unfortunately, it is too late there to redirect it to iptables.
My initial solution was to force the packets to go through the BROUTING chain and to use the -j redirect --redirect-target DROP rule to force it to go through iptables.
So far, after a lot of experiments and failures, I was able to see the packet in BROUTING using veth interfaces, one in brwan, etc. But unfortunately, it appears to be a lot more complicated as this solution is changing the destination MAC address, and therefore the packets (DHCP are broadcast ones), hit iptables, but not anymore with the MAC of the veth in brwan instead of ff:ff:ff:ff:ff:ff. This is however normal behavior for the BROUTING redirect rule.
This way seems a lot too complicated, and now, I am thinking of a totally different route: programmatically catch all packets leaving the router with a specific mark.
tcpdump does not seem to allow this (it does not deal at all with the eth/ip stack where the marking is taking place).
I can do a program in C, using sockets or pcap, but is it possible to catch only asked packets?
Or I may go a totally different way again and use tc mirror to a virtual interface on which destination MAC is changed of the one of the IDS device…
I hope everyone is having a great Sunday
I am looking for help from the master gurus out here.
My goal is simple: I want to be able to capture in iptables some packets generated locally by raw sockets to tee them to my IDS (I am able to tee everything coming through the router, to the router and from the router, except those few packets generated in the router via raw sockets like dhcpd does for example).
Raw socket packets are bypassing iptables, and can only be seen in the OUTPUT chain of ebtables.
Unfortunately, it is too late there to redirect it to iptables.
My initial solution was to force the packets to go through the BROUTING chain and to use the -j redirect --redirect-target DROP rule to force it to go through iptables.
So far, after a lot of experiments and failures, I was able to see the packet in BROUTING using veth interfaces, one in brwan, etc. But unfortunately, it appears to be a lot more complicated as this solution is changing the destination MAC address, and therefore the packets (DHCP are broadcast ones), hit iptables, but not anymore with the MAC of the veth in brwan instead of ff:ff:ff:ff:ff:ff. This is however normal behavior for the BROUTING redirect rule.
This way seems a lot too complicated, and now, I am thinking of a totally different route: programmatically catch all packets leaving the router with a specific mark.
tcpdump does not seem to allow this (it does not deal at all with the eth/ip stack where the marking is taking place).
I can do a program in C, using sockets or pcap, but is it possible to catch only asked packets?
Or I may go a totally different way again and use tc mirror to a virtual interface on which destination MAC is changed of the one of the IDS device…