aboutsummaryrefslogtreecommitdiffstats
path: root/packages/carp_rules.php
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2005-02-18 23:39:39 +0000
committerScott Ullrich <sullrich@pfsense.org>2005-02-18 23:39:39 +0000
commitf5f6767957f77100796416f44d1a19cabf525c39 (patch)
tree883bcc503f41f652771151569d78c115c295dea8 /packages/carp_rules.php
parent9162e491626b88f1be22eb44bbfa3df0fd439de8 (diff)
downloadpfsense-packages-f5f6767957f77100796416f44d1a19cabf525c39.tar.gz
pfsense-packages-f5f6767957f77100796416f44d1a19cabf525c39.tar.bz2
pfsense-packages-f5f6767957f77100796416f44d1a19cabf525c39.zip
Update carp package
* Add carp status page * Add carp tabs * Add carp rules which dynamically sets up NAT entries for non WAN
Diffstat (limited to 'packages/carp_rules.php')
-rw-r--r--packages/carp_rules.php66
1 files changed, 66 insertions, 0 deletions
diff --git a/packages/carp_rules.php b/packages/carp_rules.php
new file mode 100644
index 00000000..2c03fb83
--- /dev/null
+++ b/packages/carp_rules.php
@@ -0,0 +1,66 @@
+<?php
+/*
+ carp_rules.inc
+ part of pfSense (www.pfSense.com)
+ Copyright (C) 2004 Scott Ullrich (sullrich@gmail.com)
+ 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.
+
+*/
+
+require("guiconfig.inc");
+require("xmlparse_pkg.inc");
+
+/*
+ * available anchors:
+ * anchor natrules
+ * anchor firewallrules
+ * anchor loopback
+ * anchor firewallout
+ * anchor ftpproxy
+ * anchor dhcpserverlan
+ * anchor dhcpserver
+ * anchor staticrouted
+ * anchor wanspoof
+ * anchor wandhcp
+ * anchor anti-lockout
+ * anchor pptp
+ */
+
+/* return if there are no carp configured items */
+if(!$config['installedpackages']['carp']['config']) return;
+
+/* carp records exist, lets process */
+$wan_interface = get_real_wan_interface();
+foreach($config['installedpackages']['carp']['config'] as $carp) {
+ $ip = $carp['ipaddress'];
+ $int = find_ip_interface($ip);
+ $carp_int = find_carp_interface($ip);
+ if($int <> false && $int <> $wan_interface) {
+ $ipnet = convert_ip_to_network_format($ip, $carp['netmask']);
+ $rule = "nat on {$int} inet from {$ipnet} to any -> ({$carp_int}) \n";
+ add_rule_to_anchor("natrules", $rule);
+ }
+}
+
+?> \ No newline at end of file