#!/usr/local/bin/php . All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ $pgtitle = array("System", "Advanced setup"); require("guiconfig.inc"); $pconfig['filteringbridge_enable'] = isset($config['bridge']['filteringbridge']); $pconfig['cert'] = base64_decode($config['system']['webgui']['certificate']); $pconfig['key'] = base64_decode($config['system']['webgui']['private-key']); $pconfig['disableconsolemenu'] = isset($config['system']['disableconsolemenu']); $pconfig['disablefirmwarecheck'] = isset($config['system']['disablefirmwarecheck']); $pconfig['allowipsecfrags'] = isset($config['filter']['allowipsecfrags']); $pconfig['expanddiags'] = isset($config['system']['webgui']['expanddiags']); if ($g['platform'] == "generic-pc") $pconfig['harddiskstandby'] = $config['system']['harddiskstandby']; $pconfig['bypassstaticroutes'] = isset($config['filter']['bypassstaticroutes']); $pconfig['noantilockout'] = isset($config['system']['webgui']['noantilockout']); $pconfig['ipsecdnsinterval'] = $config['ipsec']['dns-interval']; $pconfig['tcpidletimeout'] = $config['filter']['tcpidletimeout']; $pconfig['preferoldsa_enable'] = isset($config['ipsec']['preferoldsa']); $pconfig['polling_enable'] = isset($config['system']['polling']); $pconfig['ipfstatentries'] = $config['diag']['ipfstatentries']; $pconfig['enableipv6'] = isset($config['system']['enableipv6']); $pconfig['portrangelow'] = $config['nat']['portrange-low']; $pconfig['portrangehigh'] = $config['nat']['portrange-high']; if ($_POST) { unset($input_errors); $savemsgadd = ""; if ($_POST['gencert']) { /* custom certificate generation requested */ $ck = generate_self_signed_cert("m0n0wall", $config['system']['hostname'] . "." . $config['system']['domain']); if ($ck === false) { $input_errors[] = "A self-signed certificate could not be generated because the system's clock is not set."; } else { $_POST['cert'] = $ck['cert']; $_POST['key'] = $ck['key']; $savemsgadd = "

A self-signed certificate and private key have been automatically generated."; } } $pconfig = $_POST; /* input validation */ if ($_POST['ipsecdnsinterval'] && !is_numericint($_POST['ipsecdnsinterval'])) { $input_errors[] = "The IPsec DNS check interval must be an integer."; } if ($_POST['tcpidletimeout'] && !is_numericint($_POST['tcpidletimeout'])) { $input_errors[] = "The TCP idle timeout must be an integer."; } if ($_POST['ipfstatentries'] && !is_numericint($_POST['ipfstatentries'])) { $input_errors[] = "The 'firewall states displayed' value must be an integer."; } if (($_POST['cert'] && !$_POST['key']) || ($_POST['key'] && !$_POST['cert'])) { $input_errors[] = "Certificate and key must always be specified together."; } else if ($_POST['cert'] && $_POST['key']) { if (!strstr($_POST['cert'], "BEGIN CERTIFICATE") || !strstr($_POST['cert'], "END CERTIFICATE")) $input_errors[] = "This certificate does not appear to be valid."; if (!strstr($_POST['key'], "BEGIN RSA PRIVATE KEY") || !strstr($_POST['key'], "END RSA PRIVATE KEY")) $input_errors[] = "This key does not appear to be valid."; } if (($_POST['portrangelow'] || $_POST['portrangehigh']) && (!is_port($_POST['portrangelow']) || !is_port($_POST['portrangehigh']))) $input_errors[] = "The outbound NAT port range start and end must be integers between 1 and 65535."; if (!$input_errors) { $config['bridge']['filteringbridge'] = $_POST['filteringbridge_enable'] ? true : false; $oldcert = $config['system']['webgui']['certificate']; $oldkey = $config['system']['webgui']['private-key']; $config['system']['webgui']['certificate'] = base64_encode($_POST['cert']); $config['system']['webgui']['private-key'] = base64_encode($_POST['key']); $config['system']['disableconsolemenu'] = $_POST['disableconsolemenu'] ? true : false; $config['system']['disablefirmwarecheck'] = $_POST['disablefirmwarecheck'] ? true : false; $config['filter']['allowipsecfrags'] = $_POST['allowipsecfrags'] ? true : false; $config['system']['webgui']['expanddiags'] = $_POST['expanddiags'] ? true : false; if ($g['platform'] == "generic-pc") { $oldharddiskstandby = $config['system']['harddiskstandby']; $config['system']['harddiskstandby'] = $_POST['harddiskstandby']; } $config['system']['webgui']['noantilockout'] = $_POST['noantilockout'] ? true : false; $config['filter']['bypassstaticroutes'] = $_POST['bypassstaticroutes'] ? true : false; $oldtcpidletimeout = $config['filter']['tcpidletimeout']; $config['filter']['tcpidletimeout'] = $_POST['tcpidletimeout']; $oldipsecdnsinterval = $config['ipsec']['dns-interval']; $config['ipsec']['dns-interval'] = $_POST['ipsecdnsinterval']; $oldpreferoldsa = $config['ipsec']['preferoldsa']; $config['ipsec']['preferoldsa'] = $_POST['preferoldsa_enable'] ? true : false; $oldpolling = $config['system']['polling']; $config['system']['polling'] = $_POST['polling_enable'] ? true : false; if (!$_POST['ipfstatentries']) unset($config['diag']['ipfstatentries']); else $config['diag']['ipfstatentries'] = $_POST['ipfstatentries']; $config['system']['enableipv6'] = $_POST['enableipv6'] ? true : false; $config['nat']['portrange-low'] = $_POST['portrangelow']; $config['nat']['portrange-high'] = $_POST['portrangehigh']; write_config(); if (($config['system']['webgui']['certificate'] != $oldcert) || ($config['system']['webgui']['private-key'] != $oldkey) || ($config['filter']['tcpidletimeout'] != $oldtcpidletimeout) || ($config['system']['polling'] != $oldpolling)) { touch($d_sysrebootreqd_path); } if (($g['platform'] == "generic-pc") && ($config['system']['harddiskstandby'] != $oldharddiskstandby)) { if (!$config['system']['harddiskstandby']) { // Reboot needed to deactivate standby due to a stupid ATA-protocol touch($d_sysrebootreqd_path); unset($config['system']['harddiskstandby']); } else { // No need to set the standby-time if a reboot is needed anyway system_set_harddisk_standby(); } } $retval = 0; if (!file_exists($d_sysrebootreqd_path)) { config_lock(); $retval = filter_configure(); $retval |= interfaces_optional_configure(); if ($config['ipsec']['preferoldsa'] != $oldpreferoldsa || $config['ipsec']['dns-interval'] != $oldipsecdnsinterval) $retval |= vpn_ipsec_configure(); $retval |= system_set_termcap(); config_unlock(); } $savemsg = get_std_save_message($retval) . $savemsgadd; } } ?>

Note: the options on this page are intended for use by advanced users only, and there's NO support for them.

IPv6 support
  > Enable IPv6 support
After enabling IPv6 support, configure IPv6 addresses on your LAN and WAN interfaces, then add IPv6 firewall rules.
Note: you must set an IPv6 address on the LAN interface for the IPv6 support to work.
 
Filtering bridge
  > Enable filtering bridge
This will cause bridged packets to pass through the packet filter in the same way as routed packets do (by default bridged packets are always passed). If you enable this option, you'll have to add filter rules to selectively permit traffic from bridged interfaces.
 
webGUI SSL certificate/key
Certificate
Paste a signed certificate in X.509 PEM format here.
Key
Paste an RSA private key in PEM format here.
 
Firewall
TCP idle timeout seconds
Idle TCP connections will be removed from the state table after no packets have been received for the specified number of seconds. Don't set this too high or your state table could become full of connections that have been improperly shut down. The default is 2.5 hours.
Static route filtering > Bypass firewall rules for traffic on the same interface
This option only applies if you have defined one or more static routes. If it is enabled, traffic that enters and leaves through the same interface will not be checked by the firewall. This may be desirable in some situations where multiple subnets are connected to the same interface.
IPsec fragmented packets > Allow fragmented IPsec packets
This will cause m0n0wall to allow fragmented IP packets that are encapsulated in IPsec ESP packets.
Outbound NAT port range -
This setting controls the range from which ports are randomly picked for outbound NAT. Do not change this unless you know exactly what you're doing.
Miscellaneous
Console menu > Disable console menu
Changes to this option will take effect after a reboot.
Firmware version check > Disable firmware version check
This will cause m0n0wall not to check for newer firmware versions when the System: Firmware page is viewed.
IPsec DNS check interval seconds
If at least one IPsec tunnel has a host name (instead of an IP address) as the remote gateway, a DNS lookup is performed at the interval specified here, and if the IP address that the host name resolved to has changed, the IPsec tunnel is reconfigured. The default is 60 seconds.
Hard disk standby time
Puts the hard disk into standby mode when the selected amount of time after the last access has elapsed. Do not set this for CF cards.
Navigation > Keep diagnostics in navigation expanded
webGUI anti-lockout > Disable webGUI anti-lockout rule
By default, access to the webGUI on the LAN interface is always permitted, regardless of the user-defined filter rule set. Enable this feature to control webGUI access (make sure to have a filter rule in place that allows you in, or you will lock yourself out!).
Hint: the "set LAN IP address" option in the console menu resets this setting as well.
IPsec SA preferral > Prefer old IPsec SAs
By default, if several SAs match, the newest one is preferred. Select this option to always prefer old SAs over new ones.
Device polling > Use device polling
Device polling is a technique that lets the system periodically poll network devices for new data instead of relying on interrupts. This can reduce CPU load and therefore increase throughput, at the expense of a slightly higher forwarding delay (the devices are polled 1000 times per second). Not all NICs support polling; see the m0n0wall homepage for a list of supported cards.
Firewall states displayed entries
Maxmimum number of firewall state entries to be displayed on the Diagnostics: Firewall state page. Default is 300. Setting this to a very high value will cause a slowdown when viewing the firewall states page, depending on your system's processing power.