add dhcp
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
461f72678f
commit
8fcfefc900
3 changed files with 143 additions and 2 deletions
|
|
@ -3,6 +3,7 @@
|
|||
. ./lib/db.sh
|
||||
. ./lib/colors.sh
|
||||
. ./lib/vpc.sh
|
||||
. ./lib/dhcp.sh
|
||||
|
||||
function check_subnet_exist {
|
||||
local vpc_name="${1}"
|
||||
|
|
@ -78,7 +79,11 @@ function create_subnet {
|
|||
print_in_color "${COLOR_GREEN}" " - add subnet route"
|
||||
ip -n "${vpc_name}" r add "${subnet}" dev "br-${subnet_id}" scope link
|
||||
print_in_color "${COLOR_GREEN}" " - add subnet firewall"
|
||||
ebtables -A FORWARD -p arp --arp-op Request --arp-ip-dst "${gateway_ip}" --out-interface "br-${subnet_id}" -j DROP
|
||||
ebtables -A FORWARD --out-interface "br-${subnet_id}" -p arp --arp-op Request --arp-ip-dst "${gateway_ip}" -j DROP
|
||||
ebtables -A FORWARD --out-interface "br-${subnet_id}" -p IPv4 --ip-protocol udp --ip-source-port 67:68 --ip-destination-port 67:68 -j DROP
|
||||
|
||||
generate_dhcp_file "${subnet}" "${vpc_name}_br-${subnet_id}"
|
||||
systemctl start "dnsmasq@${vpc_name}_br-${subnet_id}.service"
|
||||
|
||||
}
|
||||
return 0
|
||||
|
|
@ -98,7 +103,10 @@ function delete_subnet {
|
|||
delete_in_db "subnet" "${subnet_name}"
|
||||
ip -n "${vpc_name}" route del "${subnet}" dev "br-${subnet_id}"
|
||||
ip link del dev "vxlan-${vxlan_id}"
|
||||
systemctl stop "dnsmasq@${vpc_name_br}-br-${subnet_id}.service"
|
||||
rm /etc/dnsmasq.d/${vpc_name}_br-${subnet_id}.conf
|
||||
ebtables -D FORWARD -p arp --arp-op Request --arp-ip-dst "${gateway_ip}" --out-interface "br-${subnet_id}" -j DROP
|
||||
ebtables -D FORWARD --out-interface "br-${subnet_id}" -p IPv4 --ip-protocol udp --ip-source-port 67:68 --ip-destination-port 67:68 -j DROP
|
||||
ip link del dev "br-${subnet_id}"
|
||||
ip -n "${vpc_name}" link del dev "br-${subnet_id}"
|
||||
ip link del dev "veth-${subnet_id}-ext"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue