Re: Unusual packet forwarding task

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

 



Rob,
I have a feeling that this can be accomplished with some manually
added match/actions inside of ovs. Specifically using ovs-ofctl.
I would add both ports into an ovs bridge
Using your criteria to specify the match and action. Writing a flow
match by hand involves some trial and error. Something like the
following, though I haven't tried it out
ovs-ofctl add-flow br0
in_port=0,udp,nw_src=192.168.17.36,nw_dst=172.16.20.3
actions=mod_nw_src:10.0.0.2,mod_nw_dst:10.0.0.1,output:1
This there is a lot of flexibility on matching [1] and the actions
[2]. If the network is is full of traffic that you don't care about,
you could add a rule to drop a lot of traffic that you don't care
about.

I hope this helps.

[1] https://www.man7.org/linux/man-pages/man7/ovs-fields.7.html
[2] https://www.man7.org/linux/man-pages/man7/ovs-actions.7.html


On Fri, Oct 25, 2024 at 9:57 AM Rob Roschewsk <rob@xxxxxxxxx> wrote:
>
> Thanks Martin!
>
> I'm not at the point of adding code to this project yet ... close but
> not yet :) This will certainly give me a head start if that happens.
> -> Rob
>
>
> On Fri, Oct 25, 2024 at 4:39 AM Martin Tonusoo <martin@xxxxxxxxxx> wrote:
> >
> > 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
>


-- 
Logan





[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