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
32 hook_check_config_settings
() {
37 hook_parse_cmdline
() {
41 while [ $# -gt 0 ]; do
44 IPV6
="$(cli_get_bool "${1}")"
47 IPV4
="$(cli_get_bool "${1}")"
50 warning
"Ignoring unknown option '${1}'"
56 # Check if the user disabled ipv6 and ipv4
57 if ! enabled IPV6
&& ! enabled IPV4
; then
58 error
"You disabled IPv6 and IPv4. At least one must be enabled"
68 if ! device_exists
${zone}; then
69 error
"Zone '${zone}' doesn't exist."
73 zone_config_settings_read
"${zone}" "${config}"
75 # Start dhclient for IPv6 on this zone if enabled.
77 dhclient_start
${zone} ipv6
80 # Start dhclient for IPv4 on this zone if enabled.
82 dhclient_start
${zone} ipv4
93 if ! device_exists
${zone}; then
94 error
"Zone '${zone}' doesn't exist."
98 # Stop dhclient for IPv6 on this zone.
99 dhclient_stop
${zone} ipv6
101 # Stop dhclient for IPv4 on this zone.
102 dhclient_stop
${zone} ipv4
112 if ! device_exists
${zone}; then
113 error
"Zone '${zone}' doesn't exist."
117 zone_config_settings_read
"${zone}" "${config}"
120 if dhclient_status
${zone} ipv4 || dhclient_status
${zone} ipv6
; then
121 status
="${MSG_HOOK_UP}"
123 status
="${MSG_HOOK_DOWN}"
125 cli_statusline
3 "${HOOK}" "${status}"
130 for proto
in "IPv6" "IPv4"; do
131 local _proto
=${proto,,}
133 cli_print_fmt1
3 "${proto}"
135 if enabled
"${proto^^}"; then
136 cli_print_fmt1
4 "Status" "enabled"
138 local address
="$(db_get "${zone}/${_proto}/local-ip-address
")"
139 if isset address
; then
140 cli_print_fmt1
4 "Address" "${address}"
143 local gateway
="$(db_get "${zone}/${_proto}/remote-ip-address
")"
144 if isset gateway
; then
145 cli_print_fmt1
4 "Gateway" "${gateway}"
148 local dns_servers
="$(db_get "${zone}/${_proto}/domain-name-servers
")"
149 if isset dns_servers
; then
150 cli_print_fmt1
4 "DNS Servers" "${dns_servers}"
153 cli_print_fmt1
4 "Status" "disabled"