<div dir="ltr">Hello!<div><br></div><div>I'm trying to use OVS as a stateful firewall for all the VMs connected to a OVS bridge. I'm trying to use the conntrack feature to achieve this based off examples I've put together, but have yet to make it work fully.</div><div><br></div><div>My end goal is to be able to block or allow a port for a VM for egress or ingress.<br></div><div><br></div><div>In the below example I'm trying to block all ports to a VM except for 80 while also allowing all outbound connections from the VM.</div><div><br></div><div>Setup: (00:16:3e:5a:ff:c2 is the mac address of the VMs eth0)</div><div><br></div><div>1) ovs-ofctl del-flows br0 && sudo ovs-ofctl add-flow br0 action=normal<br></div><div>2) ovs-ofctl add-flow br0 "table=10 action=normal"<br>3) ovs-ofctl add-flow br0 "table=0, tcp, dl_dst=00:16:3e:5a:ff:c2 priority=38000 actions=ct(table=1)"<br>4) ovs-ofctl add-flow br0 "table=1, ip, dl_dst=00:16:3e:5a:ff:c2 priority=202,ct_state=+est+rpl+trk actions=normal"<br>5) ovs-ofctl add-flow br0 "table=1, tcp, priority=200,dl_dst=00:16:3e:5a:ff:c2 actions=resubmit(,2)"<br>6) ovs-ofctl add-flow br0 "table=2, tcp, priority=1000,ct_state=+new+trk,dl_dst=00:16:3e:5a:ff:c2,tcp_dst=80 actions=ct(commit,table=10)"<br>7) ovs-ofctl add-flow br0 "table=2, tcp, priority=100,dl_dst=00:16:3e:5a:ff:c2 actions=drop"<br></div><div><br></div><div>Here's the dump from ovs-ofctl:</div><div> cookie=0x0, duration=27.099s, table=0, n_packets=316, n_bytes=103582, priority=38000,tcp,dl_dst=00:16:3e:5a:ff:c2 actions=ct(table=1)<br> cookie=0x0, duration=27.486s, table=0, n_packets=581, n_bytes=127617, actions=NORMAL<br> cookie=0x0, duration=27.090s, table=1, n_packets=0, n_bytes=0, priority=202,ct_state=+est+rpl+trk,ip,dl_dst=00:16:3e:5a:ff:c2 actions=NORMAL<br> cookie=0x0, duration=27.081s, table=1, n_packets=316, n_bytes=103582, priority=200,tcp,dl_dst=00:16:3e:5a:ff:c2 actions=resubmit(,2)<br> cookie=0x0, duration=27.072s, table=2, n_packets=205, n_bytes=65022, priority=1000,ct_state=+new+trk,tcp,dl_dst=00:16:3e:5a:ff:c2,tp_dst=80 actions=ct(commit,table=10)<br> cookie=0x0, duration=26.830s, table=2, n_packets=111, n_bytes=38560, priority=100,tcp,dl_dst=00:16:3e:5a:ff:c2 actions=drop<br> cookie=0x0, duration=27.107s, table=10, n_packets=205, n_bytes=65022, actions=NORMAL<br></div><div><br></div><div>Odd thing is #4 rule looks to never get hit (based off ovs-ofctl dump-flows br0). If I change the rule to +inv+trk, it gets hits. Does that mean invalid packets are coming through? I checked and the host OS has nf_conntrack_ipv4 loaded.</div><div><br></div><div>It kind of works if I change command #6 to ovs-ofctl add-flow br0 "table=1, ip, dl_dst=00:16:3e:5a:ff:c2 priority=202,ct_state=+est+rpl+trk actions=normal"</div><div>However all outbound traffic is still blocked and entry #4 never gets hit still either.</div><div><br></div><div>I'm fairly new to OVS and have been google'ing / stackoverflow'ing for the last few days with no luck.</div><div></div><div><br></div><div>I apologize for my newbie'ness and thank you in advance for any help or direction!</div><div><br></div></div>