2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2010 Michael Tremer & Christian Schmidt #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 .
/usr
/lib
/network
/header-config
24 HOOK_CONFIG_SETTINGS
="HOOK ENABLE_IPV6 ENABLE_IPV4"
30 hook_check_config_settings
() {
31 assert isset ENABLE_IPV6
32 assert isbool ENABLE_IPV6
33 assert isset ENABLE_IPV4
34 assert isbool ENABLE_IPV4
37 hook_parse_cmdline
() {
38 while [ $# -gt 0 ]; do
53 warning
"Ignoring unknown option '${1}'"
64 if zone_config_hook_is_configured
${zone} "dhcp"; then
65 log ERROR
"You can configure the dhcp hook only once for a zone"
69 if ! hook_parse_cmdline $@
; then
70 # Return an error if the parsing of the cmd line fails
74 # Check if the user disabled ipv4 and ipv6
76 if ! enabled ENABLE_IPV6
&& ! enabled ENABLE_IPV4
; then
77 log ERROR
"You disabled IPv6 and IPv4. At least one must be enabled"
81 zone_config_settings_write
"${zone}" "${HOOK}"
91 if ! device_exists
${zone}; then
92 error
"Zone '${zone}' doesn't exist."
96 zone_config_settings_read
"${zone}" "${config}"
98 # Start dhclient for IPv6 on this zone if enabled.
99 if enabled ENABLE_IPV6
; then
100 dhclient_start
${zone} ipv6
103 # Start dhclient for IPv4 on this zone if enabled.
104 if enabled ENABLE_IPV4
; then
105 dhclient_start
${zone} ipv4
116 if ! device_exists
${zone}; then
117 error
"Zone '${zone}' doesn't exist."
121 # Stop dhclient for IPv6 on this zone.
122 dhclient_stop
${zone} ipv6
124 # Stop dhclient for IPv4 on this zone.
125 dhclient_stop
${zone} ipv4
135 if ! device_exists
${zone}; then
136 error
"Zone '${zone}' doesn't exist."
140 zone_config_settings_read
"${zone}" "${config}"
143 if dhclient_status
${zone} ipv4 || dhclient_status
${zone} ipv6
; then
144 status
="${MSG_HOOK_UP}"
146 status
="${MSG_HOOK_DOWN}"
148 cli_statusline
3 "${HOOK}" "${status}"
153 for proto
in "IPv6" "IPv4"; do
154 local _proto
=${proto,,}
156 cli_print_fmt1
3 "${proto}"
158 if enabled ENABLE_
${proto^^}; then
159 cli_print_fmt1
4 "Status" "enabled"
161 local address
="$(db_get "${zone}/${_proto}/local-ip-address
")"
162 if isset address
; then
163 cli_print_fmt1
4 "Address" "${address}"
166 local gateway
="$(db_get "${zone}/${_proto}/remote-ip-address
")"
167 if isset gateway
; then
168 cli_print_fmt1
4 "Gateway" "${gateway}"
171 local dns_servers
="$(db_get "${zone}/${_proto}/domain-name-servers
")"
172 if isset dns_servers
; then
173 cli_print_fmt1
4 "DNS Servers" "${dns_servers}"
176 cli_print_fmt1
4 "Status" "disabled"