f-76: vm: filtrage nftables par tap, champ dhcp_server, watchdog #76
Chaque NIC a sa chaîne pre-tap<id>, posée avant le tap et retirée après : MAC, ARP et IPv4 source limités à ceux de la NIC (0.0.0.0 pour le client DHCP et la sonde ARP), réponses DHCP refusées sauf si dhcp_server, seuls IPv4, ARP et IPv6 émis. Le watchdog vérifie la chaîne de chaque NIC. Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
d98e42e0a8
commit
74bfda7004
16 changed files with 295 additions and 15 deletions
28
internal/vm/filter.go
Normal file
28
internal/vm/filter.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package vm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.g3e.fr/syonad/two/internal/nft"
|
||||
)
|
||||
|
||||
func TapPort(tapID int, mac, ip string, dhcpServer bool) nft.Port {
|
||||
mac = strings.ToLower(mac)
|
||||
rules := []string{
|
||||
nft.DropSourceMACOtherThan(mac),
|
||||
nft.DropEtherTypesOtherThanIPAndARP(),
|
||||
nft.DropARPSenderMACOtherThan(mac),
|
||||
nft.DropARPSenderIPOtherThan(ip),
|
||||
nft.DropIPSourceOtherThan(ip),
|
||||
}
|
||||
rules = append(rules, nft.DropUnspecifiedSourceOutsideDHCP()...)
|
||||
if !dhcpServer {
|
||||
rules = append(rules, nft.DropDHCPServer())
|
||||
}
|
||||
return nft.Port{Name: fmt.Sprintf("tap%d", tapID), Prerouting: rules}
|
||||
}
|
||||
|
||||
func (n nicData) tapPort() nft.Port {
|
||||
return TapPort(n.tapID, n.mac, n.ip, n.dhcpServer)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue