Re: Unusual packet forwarding task

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

 



Hi Rob,

perhaps something like this will do:
https://gist.github.com/tonusoo/0490bc5cf564689f3999f1de4eef098d

On Debian based distributions the dependencies can be installed with
"apt install --no-install-recommends python3-pcapy python3-scapy".
Pcapy is a wrapper library for libpcap which processes the filter in
Berkeley Packet Filter syntax, builds the binary bytecode and
eventually sends it to the kernel via the SO_ATTACH_FILTER. Thus,
there should be very little impact on throughput or CPU usage.

I used a following systemd service to manage the script:

root@deb12-1:~# systemctl cat packet-forwarder
# /etc/systemd/system/packet-forwarder.service
[Unit]
Description=Forwards certain packets received on eth0 out from eth1
After=network.target

[Service]
Type=simple
Restart=always
ExecStart=/usr/local/sbin/packet-forwarder.py

[Install]
WantedBy=multi-user.target
root@deb12-1:~#


Martin




[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