All Projects → greenpau → cni-plugins

greenpau / cni-plugins

Licence: Apache-2.0 license
CNI Plugins compatible with nftables

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects
shell
77523 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to cni-plugins

hybridnet
A CNI plugin, provides networking environment where overlay and underlay containers can run on the same node and have cluster-wide bidirectional network connectivity.
Stars: ✭ 188 (+548.28%)
Mutual labels:  cni, cni-plugin
net-network
Public collection of firewall dumps.
Stars: ✭ 40 (+37.93%)
Mutual labels:  firewall, nftables
nftables-example
A playground ruleset to get to know nftables syntax
Stars: ✭ 19 (-34.48%)
Mutual labels:  firewall, nftables
podman-static
static podman binaries and container image
Stars: ✭ 108 (+272.41%)
Mutual labels:  cni-plugins, podman
first-ten-seconds-redhat-ubuntu
A bash script to help secure a new CentOS or Ubuntu server quickly and easily.
Stars: ✭ 17 (-41.38%)
Mutual labels:  firewall
lede-dockerbuilder
A (container based) LEDE/OpenWrt image builder.
Stars: ✭ 53 (+82.76%)
Mutual labels:  podman
simplenetes
The sns tool is used to manage the full life cycle of your Simplenetes clusters. It integrates with the Simplenetes Podcompiler project podc to compile pods.
Stars: ✭ 731 (+2420.69%)
Mutual labels:  podman
Silverdog
An audio firewall for Chrome!
Stars: ✭ 65 (+124.14%)
Mutual labels:  firewall
cryostat
Secure JDK Flight Recorder management for containerized JVMs
Stars: ✭ 147 (+406.9%)
Mutual labels:  podman
mikrotik-fwban
Use your Mikrotik firewall to do fail2ban like blocking of unwanted IPs. Written in Go
Stars: ✭ 22 (-24.14%)
Mutual labels:  firewall
LAF
Linux Application Firewall
Stars: ✭ 8 (-72.41%)
Mutual labels:  firewall
ddos-mitigation
Tips to mitigate and secure your large-scale server against DDoS attacks.
Stars: ✭ 58 (+100%)
Mutual labels:  firewall
Anti-DDOS-Script
Anti DDOS Protection that will stop DDOS from taking down your Linux Server
Stars: ✭ 51 (+75.86%)
Mutual labels:  firewall
everoute
Everoute provide cloud-native networking and security solution
Stars: ✭ 26 (-10.34%)
Mutual labels:  cni
knox-firewall
Restrict mobile data on Samsung devices
Stars: ✭ 17 (-41.38%)
Mutual labels:  firewall
aws-network-firewall-deployment-automations-for-aws-transit-gateway
AWS Network Firewall Deployment Automations for AWS Transit Gateway configures the AWS resources needed to filter network traffic. This solution saves you time by automating the process of provisioning a centralized AWS Network Firewall to inspect traffic between your Amazon VPCs.
Stars: ✭ 20 (-31.03%)
Mutual labels:  firewall
Mikrotik-Blacklist
Mikrotik friendly blacklist to filter all these damn hackers.
Stars: ✭ 70 (+141.38%)
Mutual labels:  firewall
tlstun
A socks tunnel client and server using websockets over http and tls
Stars: ✭ 36 (+24.14%)
Mutual labels:  firewall
butterfly
Butterfly connects Virtual Machines and control their traffic flow
Stars: ✭ 48 (+65.52%)
Mutual labels:  firewall
hev-socks5-tproxy
A simple, lightweight socks5 transparent proxy for Linux. (IPv4/IPv6/TCP/UDP over TCP)
Stars: ✭ 209 (+620.69%)
Mutual labels:  nftables

CNI Plugins compatible with nftables

License

The plugins in this repository implement CNI Specification v0.4.0.

At the moment, the CNI Plugins maintained by the CNI team do not support nftables. The below plugins do.

This repository contains the following plugins:

  • cni-nftables-portmap: port mapping with nftables
  • cni-nftables-firewall: firewalling with nftables

Table of Contents

Supported Operating Systems

The plugins had been tested on the following systems:

  • CentOS 8:
    • kernel version: 4.18.0-193.14.2.el8_2.x86_64
    • nftables version v0.9.3 (Topsy)

Getting Started

First, download the plugins:

go get -u github.com/greenpau/cni-plugins/cmd/cni-nftables-portmap@latest
go get -u github.com/greenpau/cni-plugins/cmd/cni-nftables-firewall@latest

Check the location of the downloaded plugins:

$ which cni-nftables-portmap
~/dev/go/bin/cni-nftables-portmap

Next, copy the plugins to /usr/local/lib/cni/ directory.

mv ~/dev/go/bin/cni-nftables-{portmap,firewall} /usr/local/lib/cni/

After the above, copy assets/net.d/87-podman-bridge.conflist to /etc/cni/net.d/.

sudo cp assets/net.d/87-podman-bridge.conflist /etc/cni/net.d/

The configuration is as follows:

{
  "cniVersion": "0.4.0",
  "name": "podman",
  "plugins": [
    {
      "type": "bridge",
      "bridge": "cni-podman0",
      "isGateway": true,
      "ipMasq": false,
      "ipam": {
        "type": "host-local",
        "routes": [
          {
            "dst": "0.0.0.0/0"
          }
        ],
        "ranges": [
          [
            {
              "subnet": "10.88.0.0/16",
              "gateway": "10.88.0.1"
            }
          ]
        ]
      }
    },
    {
      "type": "cni-nftables-portmap",
      "capabilities": {
        "portMappings": true
      }
    },
    {
      "type": "cni-nftables-firewall",
      "forward_chain_name": "forward"
    }
  ]
}

Please note the ipMasq key is being set to false.

Review network config:

$ sudo podman network ls
NAME     VERSION   PLUGINS
podman   0.4.0     bridge,cni-nftables-portmap,cni-nftables-firewall

Next, run the following command to place a container in the previously created podman network and query AWS Check IP website:

podman run --net=podman -it nicolaka/netshoot curl http://checkip.amazonaws.com/

Run the following commands to test port-mapping plugin by placing a container in podman network and exposing a web server in the container.

First, start the container:

podman run --net=podman -P -d nginxdemos/hello

Alternatively, map the container port to port 8080:

podman run --net=podman -p 8080:80/tcp -d nginxdemos/hello

Verify connectivity to the container:

curl -v http://HOST_IP:8080

For localhost port mapping to work it is necessary to set route_localnet sysctl

sysctl -w net.ipv4.conf.all.route_localnet=1

Also, don't limit your sending and receiving of 127.0.0.1 to the lo interface.

nft add rule filter input iifname != 'lo' ip saddr 127.0.0.0/8 counter drop
nft add rule filter input iifname != 'lo' ip daddr 127.0.0.0/8 counter drop

This will block communication between the localhost and the container network. Instead, match the physical interfaces explicitly, like this.

nft add rule filter input iifname eth0 ip saddr 127.0.0.0/8 counter drop
nft add rule filter input iifname eth0 ip daddr 127.0.0.0/8 counter drop
nft add rule filter input iifname eth1 ip saddr 127.0.0.0/8 counter drop
nft add rule filter input iifname eth1 ip daddr 127.0.0.0/8 counter drop

This allows the container network to communicate with localhost.

Architecture

TBD.

Miscellaneous

Known Issues

There could be an issue with checksums when using portmap plugin.

Specifically, packets would arrive to a container, but they would be disregarded and no SYN/ACK would be sent.

When running tcpdump inside a container, there is checksum error cksum 0xd776 (incorrect -> 0xd8b9).

$ tcpdump -i eth0 -vvv -nne
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
01:05:16.704789 ee:58:3f:4d:1f:23 > ea:56:b4:c6:4f:c7, ethertype IPv4 (0x0800), length 58: (tos 0x0, ttl 63, id 8844, offset 0, flags [none], proto TCP (6), length 44)
    10.0.2.2.54017 > 10.88.0.116.80: Flags [S], cksum 0xd776 (incorrect -> 0xd8b9), seq 2337032705, win 65535, options [mss 1460], length 0

See similar issue here.

The solution is upgrading to nftables v0.9.3 (Topsy).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].