f-28: fix: add proper dhcp handle
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
848f965883
commit
32b78a84f9
3 changed files with 46 additions and 35 deletions
|
|
@ -13,46 +13,48 @@ func deleteRule(args ...string) error {
|
|||
return exec.Command("ebtables", append([]string{"-D"}, args...)...).Run()
|
||||
}
|
||||
|
||||
func DropARPToGateway(bridge, gatewayIP string) error {
|
||||
func DropARPToGateway(iface, ip string) error {
|
||||
if err := addRule("FORWARD",
|
||||
"--out-interface", bridge,
|
||||
"--out-interface", iface,
|
||||
"-p", "arp",
|
||||
"--arp-op", "Request",
|
||||
"--arp-ip-dst", gatewayIP,
|
||||
"--arp-ip-dst", ip,
|
||||
"-j", "DROP"); err != nil {
|
||||
return fmt.Errorf("ebtables arp rule: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DropDHCP(bridge string) error {
|
||||
func DropDHCP(iface, ip string) error {
|
||||
if err := addRule("FORWARD",
|
||||
"--out-interface", bridge,
|
||||
"--out-interface", iface,
|
||||
"-p", "IPv4",
|
||||
"--ip-protocol", "udp",
|
||||
"--ip-source-port", "67:68",
|
||||
"--ip-destination-port", "67:68",
|
||||
"--ip-source", ip,
|
||||
"-j", "DROP"); err != nil {
|
||||
return fmt.Errorf("ebtables dhcp rule: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeleteARPToGateway(bridge, gatewayIP string) error {
|
||||
func DeleteARPToGateway(iface, ip string) error {
|
||||
return deleteRule("FORWARD",
|
||||
"--out-interface", bridge,
|
||||
"--out-interface", iface,
|
||||
"-p", "arp",
|
||||
"--arp-op", "Request",
|
||||
"--arp-ip-dst", gatewayIP,
|
||||
"--arp-ip-dst", ip,
|
||||
"-j", "DROP")
|
||||
}
|
||||
|
||||
func DeleteDHCP(bridge string) error {
|
||||
func DeleteDHCP(iface, ip string) error {
|
||||
return deleteRule("FORWARD",
|
||||
"--out-interface", bridge,
|
||||
"--out-interface", iface,
|
||||
"-p", "IPv4",
|
||||
"--ip-protocol", "udp",
|
||||
"--ip-source-port", "67:68",
|
||||
"--ip-destination-port", "67:68",
|
||||
"--ip-source", ip,
|
||||
"-j", "DROP")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue