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
|
|
@ -59,6 +59,37 @@ func DropDHCPFrom(ip string) string {
|
|||
return "ip saddr " + ip + " udp sport 67-68 udp dport 67-68 drop"
|
||||
}
|
||||
|
||||
func DropSourceMACOtherThan(mac string) string {
|
||||
return "ether saddr != " + mac + " drop"
|
||||
}
|
||||
|
||||
func DropEtherTypesOtherThanIPAndARP() string {
|
||||
return "ether type != { ip, arp, ip6 } drop"
|
||||
}
|
||||
|
||||
func DropARPSenderMACOtherThan(mac string) string {
|
||||
return "arp saddr ether != " + mac + " drop"
|
||||
}
|
||||
|
||||
func DropARPSenderIPOtherThan(ip string) string {
|
||||
return "arp saddr ip != { 0.0.0.0, " + ip + " } drop"
|
||||
}
|
||||
|
||||
func DropDHCPServer() string {
|
||||
return "udp sport 67 drop"
|
||||
}
|
||||
|
||||
func DropIPSourceOtherThan(ip string) string {
|
||||
return "ip saddr != { 0.0.0.0, " + ip + " } drop"
|
||||
}
|
||||
|
||||
func DropUnspecifiedSourceOutsideDHCP() []string {
|
||||
return []string{
|
||||
"ip saddr 0.0.0.0 ip protocol != udp drop",
|
||||
"ip saddr 0.0.0.0 udp dport != 67 drop",
|
||||
}
|
||||
}
|
||||
|
||||
func run(args []string, script string) ([]byte, error) {
|
||||
cmd := exec.Command("nft", args...)
|
||||
if script != "" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue