1
|
<?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
|
pfSense_BUILDER_BINARIES: /sbin/ifconfig
|
41
|
pfSense_MODULE: interfaces
|
42
|
*/
|
43
|
|
44
|
##|+PRIV
|
45
|
##|*IDENT=page-firewall-virtualipaddresses
|
46
|
##|*NAME=Firewall: Virtual IP Addresses page
|
47
|
##|*DESCR=Allow access to the 'Firewall: Virtual IP Addresses' page.
|
48
|
##|*MATCH=firewall_virtual_ip.php*
|
49
|
##|-PRIV
|
50
|
|
51
|
require("guiconfig.inc");
|
52
|
require_once("functions.inc");
|
53
|
require_once("filter.inc");
|
54
|
require_once("shaper.inc");
|
55
|
|
56
|
if (!is_array($config['virtualip']['vip'])) {
|
57
|
$config['virtualip']['vip'] = array();
|
58
|
}
|
59
|
$a_vip = &$config['virtualip']['vip'];
|
60
|
|
61
|
if ($_POST) {
|
62
|
$pconfig = $_POST;
|
63
|
|
64
|
if ($_POST['apply']) {
|
65
|
|
66
|
if ($a_vip[$_POST['id']]) {
|
67
|
switch ($a_vip[$_POST['id']]['mode']) {
|
68
|
case "ipalias":
|
69
|
interface_ipalias_configure($a_vip[$_POST['id']]);
|
70
|
break;
|
71
|
case "proxyarp":
|
72
|
interface_proxyarp_configure();
|
73
|
break;
|
74
|
case "carp":
|
75
|
interface_carp_configure($a_vip[$_POST['id']]);
|
76
|
break;
|
77
|
case "carpdev-dhcp":
|
78
|
interface_carpdev_configure($a_vip[$_POST['id']]);
|
79
|
break;
|
80
|
default:
|
81
|
break;
|
82
|
}
|
83
|
}
|
84
|
$retval = 0;
|
85
|
$retval |= filter_configure();
|
86
|
$savemsg = get_std_save_message($retval);
|
87
|
|
88
|
clear_subsystem_dirty('vip');
|
89
|
}
|
90
|
}
|
91
|
|
92
|
if ($_GET['act'] == "del") {
|
93
|
if ($a_vip[$_GET['id']]) {
|
94
|
/* make sure no inbound NAT mappings reference this entry */
|
95
|
if (is_array($config['nat']['rule'])) {
|
96
|
foreach ($config['nat']['rule'] as $rule) {
|
97
|
if($rule['external-address'] <> "") {
|
98
|
if ($rule['external-address'] == $a_vip[$_GET['id']]['ipaddr']) {
|
99
|
$input_errors[] = "This entry cannot be deleted because it is still referenced by at least one NAT mapping.";
|
100
|
break;
|
101
|
}
|
102
|
}
|
103
|
}
|
104
|
}
|
105
|
|
106
|
if (!$input_errors) {
|
107
|
// Special case since every proxyarp vip is handled by the same daemon.
|
108
|
if ($a_vip[$_GET['id']]['mode'] == "proxyarp") {
|
109
|
unset($a_vip[$_GET['id']]);
|
110
|
interface_proxyarp_configure();
|
111
|
} else {
|
112
|
interface_vip_bring_down($a_vip[$_GET['id']]);
|
113
|
unset($a_vip[$_GET['id']]);
|
114
|
}
|
115
|
if (count($config['virtualip']['vip']) == 0)
|
116
|
unset($config['virtualip']['vip']);
|
117
|
write_config();
|
118
|
mark_subsystem_dirty('vip');
|
119
|
header("Location: firewall_virtual_ip.php");
|
120
|
exit;
|
121
|
}
|
122
|
}
|
123
|
} else if ($_GET['changes'] == "mods")
|
124
|
$id = $_GET['id'];
|
125
|
|
126
|
$pgtitle = array("Firewall","Virtual IP Addresses");
|
127
|
include("head.inc");
|
128
|
|
129
|
?>
|
130
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
131
|
<?php include("fbegin.inc"); ?>
|
132
|
<form action="firewall_virtual_ip.php" method="post">
|
133
|
<?php
|
134
|
if ($input_errors)
|
135
|
print_input_errors($input_errors);
|
136
|
else
|
137
|
if ($savemsg)
|
138
|
print_info_box($savemsg);
|
139
|
else
|
140
|
if (is_subsystem_dirty('vip'))
|
141
|
print_info_box_np("The VIP configuration has been changed.<br>You must apply the changes in order for them to take effect.");
|
142
|
?>
|
143
|
<br>
|
144
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
145
|
<tr><td class="tabnavtbl">
|
146
|
<?php
|
147
|
/* active tabs */
|
148
|
$tab_array = array();
|
149
|
$tab_array[] = array("Virtual IPs", true, "firewall_virtual_ip.php");
|
150
|
$tab_array[] = array("CARP Settings", false, "pkg_edit.php?xml=carp_settings.xml&id=0");
|
151
|
display_top_tabs($tab_array);
|
152
|
?>
|
153
|
</td></tr>
|
154
|
<tr>
|
155
|
<td><input type="hidden" id="id" name="id" value="<? echo $id; ?>"></td>
|
156
|
</tr>
|
157
|
<tr>
|
158
|
<td>
|
159
|
<div id="mainarea">
|
160
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
|
161
|
<tr>
|
162
|
<td width="30%" class="listhdrr">Virtual IP address</td>
|
163
|
<td width="10%" class="listhdrr">Type</td>
|
164
|
<td width="40%" class="listhdr">Description</td>
|
165
|
<td width="10%" class="list">
|
166
|
<table border="0" cellspacing="0" cellpadding="1">
|
167
|
<tr>
|
168
|
<td width="17"></td>
|
169
|
<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>
|
170
|
</tr>
|
171
|
</table>
|
172
|
</td>
|
173
|
</tr>
|
174
|
<?php $i = 0; foreach ($a_vip as $vipent): ?>
|
175
|
<?php if($vipent['subnet'] <> "" or $vipent['range'] <> "" or
|
176
|
$vipent['subnet_bits'] <> "" or (isset($vipent['range']['from']) && $vipent['range']['from'] <> "") or $vipent['mode'] == "carpdev-dhcp"): ?>
|
177
|
<tr>
|
178
|
<td class="listlr" ondblclick="document.location='firewall_virtual_ip_edit.php?id=<?=$i;?>';">
|
179
|
<?php if (($vipent['type'] == "single") || ($vipent['type'] == "network"))
|
180
|
if($vipent['subnet_bits'])
|
181
|
echo "{$vipent['subnet']}/{$vipent['subnet_bits']}";
|
182
|
if ($vipent['type'] == "range")
|
183
|
echo "{$vipent['range']['from']}-{$vipent['range']['to']}";
|
184
|
?>
|
185
|
<?php if($vipent['mode'] == "carpdev-dhcp") echo "DHCP"; ?>
|
186
|
<?php if($vipent['mode'] == "carp" or $vipent['mode'] == "carpdev-dhcp") echo " (vhid {$vipent['vhid']})"; ?>
|
187
|
</td>
|
188
|
<td class="listr" align="center" ondblclick="document.location='firewall_virtual_ip_edit.php?id=<?=$i;?>';">
|
189
|
<? if($vipent['mode'] == "proxyarp") echo "<img src='./themes/".$g['theme']."/images/icons/icon_parp.gif' title='Proxy ARP'>"; elseif($vipent['mode'] == "carp" or $vipent['mode'] == "carpdev-dhcp") 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'>"; elseif($vipent['mode'] == "ipalias") echo "<img src='./themes/".$g['theme']."/images/icons/icon_ifalias.gif' title='IP Alias'>";?>
|
190
|
</td>
|
191
|
<td class="listbg" ondblclick="document.location='firewall_virtual_ip_edit.php?id=<?=$i;?>';">
|
192
|
<?=htmlspecialchars($vipent['descr']);?>
|
193
|
</td>
|
194
|
<td class="list" nowrap>
|
195
|
<table border="0" cellspacing="0" cellpadding="1">
|
196
|
<tr>
|
197
|
<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>
|
198
|
<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>
|
199
|
</tr>
|
200
|
</table>
|
201
|
</td>
|
202
|
</tr>
|
203
|
<?php endif; ?>
|
204
|
<?php $i++; endforeach; ?>
|
205
|
<tr>
|
206
|
<td class="list" colspan="3"></td>
|
207
|
<td class="list">
|
208
|
<table border="0" cellspacing="0" cellpadding="1">
|
209
|
<tr>
|
210
|
<td width="17"></td>
|
211
|
<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>
|
212
|
</tr>
|
213
|
</table>
|
214
|
</td>
|
215
|
</tr>
|
216
|
<tr>
|
217
|
<td colspan="4">
|
218
|
<p><span class="vexpl"><span class="red"><strong>Note:<br>
|
219
|
</strong></span>The virtual IP addresses defined on this page may be used in <a href="firewall_nat.php">NAT</a> mappings.<br>
|
220
|
You can check the status of your CARP Virtual IPs and interfaces <a href="carp_status.php">here</a>.</span></p>
|
221
|
</td>
|
222
|
</tr>
|
223
|
</table>
|
224
|
</div>
|
225
|
</table>
|
226
|
</form>
|
227
|
<?php include("fend.inc"); ?>
|
228
|
</body>
|
229
|
</html>
|