Project

General

Profile

Download (7.13 KB) Statistics
| Branch: | Tag: | Revision:
1 b0ae75c5 Bill Marquette
<?php
2
/* $Id$ */
3
/*
4
	firewall_virtual_ip.php
5
	part of pfSense (http://www.pfsense.com/)
6
7
	Copyright (C) 2005 Bill Marquette <bill.marquette@gmail.com>.
8
	All rights reserved.
9
10
	Includes code from m0n0wall which is:
11
	Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
12
	All rights reserved.
13
14
	Includes code from pfSense which is:
15
	Copyright (C) 2004-2005 Scott Ullrich <geekgod@pfsense.com>.
16
	All rights reserved.
17
18
	Redistribution and use in source and binary forms, with or without
19
	modification, are permitted provided that the following conditions are met:
20
21
	1. Redistributions of source code must retain the above copyright notice,
22
	   this list of conditions and the following disclaimer.
23
24
	2. Redistributions in binary form must reproduce the above copyright
25
	   notice, this list of conditions and the following disclaimer in the
26
	   documentation and/or other materials provided with the distribution.
27
28
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
29
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
30
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
32
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37
	POSSIBILITY OF SUCH DAMAGE.
38
*/
39
40
require("guiconfig.inc");
41
42
if (!is_array($config['virtualip']['vip'])) {
43
	$config['virtualip']['vip'] = array();
44
}
45
$a_vip = &$config['virtualip']['vip'];
46
47
if ($_POST) {
48
	$pconfig = $_POST;
49
50
	if ($_POST['apply']) {
51
		$retval = 0;
52 920b3bb0 Scott Ullrich
53
		config_lock();
54
		$retval = services_proxyarp_configure();
55
		/* Bring up any configured CARP interfaces */
56
		interfaces_carp_configure();
57
		$retval |= filter_configure();
58
		config_unlock();
59
60 b0ae75c5 Bill Marquette
		$savemsg = get_std_save_message($retval);
61
		unlink_if_exists($d_vipconfdirty_path);
62
	}
63
}
64
65
if ($_GET['act'] == "del") {
66
	if ($a_vip[$_GET['id']]) {
67
		/* make sure no inbound NAT mappings reference this entry */
68
		if (is_array($config['nat']['rule'])) {
69
			foreach ($config['nat']['rule'] as $rule) {
70 7c99b15c Scott Ullrich
				if($rule['external-address'] <> "") {
71
					if ($rule['external-address'] == $a_vip[$_GET['id']]['ipaddr']) {
72
						$input_errors[] = "This entry cannot be deleted because it is still referenced by at least one NAT mapping.";
73
						break;
74
					}
75 b0ae75c5 Bill Marquette
				}
76
			}
77
		}
78
79
		if (!$input_errors) {
80
			unset($a_vip[$_GET['id']]);
81
			write_config();
82
			touch($d_vipconfdirty_path);
83
			header("Location: firewall_virtual_ip.php");
84
			exit;
85
		}
86
	}
87
}
88
89
$pgtitle = "Firewall: Virtual IP Addresses";
90
include("head.inc");
91
92
?>
93
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
94
<?php include("fbegin.inc"); ?>
95
<p class="pgtitle"><?=$pgtitle?></p>
96
<form action="firewall_virtual_ip.php" method="post">
97
<?php if ($input_errors) print_input_errors($input_errors); ?>
98
<?php if ($savemsg) print_info_box($savemsg); ?>
99
<?php if (file_exists($d_vipconfdirty_path)): ?><p>
100
<?php print_info_box_np("The VIP configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
101
<?php endif; ?>
102 49424ec0 Bill Marquette
<table width="100%" border="0" cellpadding="0" cellspacing="0">
103
  <tr><td class="tabnavtbl">
104
  <?php
105
        /* active tabs */
106
        $tab_array = array();
107
        $tab_array[] = array("Virtual IPs", true, "firewall_virtual_ip.php");
108
        $tab_array[] = array("CARP Settings", false, "pkg_edit.php?xml=carp_settings.xml&id=0");
109
        display_top_tabs($tab_array);
110
  ?>
111 b0ae75c5 Bill Marquette
  </td></tr>
112
  <tr>
113
    <td>
114
	<div id="mainarea">
115
              <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
116
                <tr>
117
                  <td width="30%" class="listhdrr">Virtual IP address</td>
118 9f3103a9 Bill Marquette
                  <td width="10%" class="listhdrr">Type</td>
119 b0ae75c5 Bill Marquette
                  <td width="40%" class="listhdr">Description</td>
120
                  <td width="10%" class="list"></td>
121
				</tr>
122
			  <?php $i = 0; foreach ($a_vip as $vipent): ?>
123 21784301 Scott Ullrich
			  <?php if($vipent['subnet'] <> "" or $vipent['range'] <> "" or
124
			        $vipent['subnet_bits'] <> "" or $vipent['range']['from'] <> ""): ?>
125 b0ae75c5 Bill Marquette
                <tr>
126
                  <td class="listlr" ondblclick="document.location='firewall_virtual_ip_edit.php?id=<?=$i;?>';">
127
					<?php	if (($vipent['type'] == "single") || ($vipent['type'] == "network"))
128
								echo "{$vipent['subnet']}/{$vipent['subnet_bits']}";
129
							if ($vipent['type'] == "range")
130
								echo "{$vipent['range']['from']}-{$vipent['range']['to']}";
131
					?>
132
                  </td>
133
                  <td class="listlr" align="center" ondblclick="document.location='firewall_virtual_ip_edit.php?id=<?=$i;?>';">
134 68a5dcd8 Bill Marquette
                    <? if($vipent['mode'] == "proxyarp") echo "<img src='./themes/".$g['theme']."/images/icons/icon_parp.gif' title='Proxy ARP'>"; elseif($vipent['mode'] == "carp") echo "<img src='./themes/".$g['theme']."/images/icons/icon_carp.gif' title='CARP'>"; elseif($vipent['mode'] == "other") echo "<img src='./themes/".$g['theme']."/images/icons/icon_other.gif' title='Other'>";?>
135 b0ae75c5 Bill Marquette
                  </td>
136
                  <td class="listbg" ondblclick="document.location='firewall_virtual_ip_edit.php?id=<?=$i;?>';">
137
                    <font color="#FFFFFF"><?=htmlspecialchars($vipent['descr']);?>&nbsp;
138
                  </td>
139
                  <td class="list" nowrap>
140
                    <table border="0" cellspacing="0" cellpadding="1">
141
                      <tr>
142 677c0869 Erik Kristensen
                        <td valign="middle"><a href="firewall_virtual_ip_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
143
                        <td valign="middle"><a href="firewall_virtual_ip.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this entry?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
144 b0ae75c5 Bill Marquette
                      </tr>
145
                    </table>
146
                  </td>
147
                </tr>
148 21784301 Scott Ullrich
		<?php endif; ?>
149 b0ae75c5 Bill Marquette
                <?php $i++; endforeach; ?>
150
                <tr>
151 9f3103a9 Bill Marquette
                  <td class="list" colspan="3"></td>
152 b0ae75c5 Bill Marquette
                  <td class="list">
153
                    <table border="0" cellspacing="0" cellpadding="1">
154
                      <tr>
155 677c0869 Erik Kristensen
                        <td valign="middle"><a href="firewall_virtual_ip_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
156 b0ae75c5 Bill Marquette
                      </tr>
157
                    </table>
158
                  </td>
159
                </tr>
160
		<tr>
161
		  <td colspan="4">
162
		      <p><span class="vexpl"><span class="red"><strong>Note:<br>
163 c55a8ab9 Holger Bauer
                      </strong></span>The virtual IP addresses defined on this page may be used in <a href="firewall_nat.php">NAT</a> mappings.<br>
164
                      You can check the status of your CARP-Interfaces <a href="carp_status.php">here</a>.</span></p>
165 b0ae75c5 Bill Marquette
		  </td>
166
		</tr>
167
              </table>
168
	   </div>
169
	</table>
170
            </form>
171
<?php include("fend.inc"); ?>
172
</body>
173
</html>