Project

General

Profile

Download (8.2 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 6b07c15a Matthew Grooms
##|+PRIV
41
##|*IDENT=page-firewall-virtualipaddresses
42
##|*NAME=Firewall: Virtual IP Addresses page
43
##|*DESCR=Allow access to the 'Firewall: Virtual IP Addresses' page.
44
##|*MATCH=firewall_virtual_ip.php*
45
##|-PRIV
46
47
48 b0ae75c5 Bill Marquette
require("guiconfig.inc");
49
50
if (!is_array($config['virtualip']['vip'])) {
51
	$config['virtualip']['vip'] = array();
52
}
53
$a_vip = &$config['virtualip']['vip'];
54
55
if ($_POST) {
56
	$pconfig = $_POST;
57
58
	if ($_POST['apply']) {
59
		$retval = 0;
60 920b3bb0 Scott Ullrich
61
		config_lock();
62
		$retval = services_proxyarp_configure();
63
		/* Bring up any configured CARP interfaces */
64 9beb982e Scott Ullrich
		reset_carp();
65 920b3bb0 Scott Ullrich
		$retval |= filter_configure();
66
		config_unlock();
67 a04de17f Chris Buechler
		interfaces_ipalias_configure();
68 37e9212c Scott Ullrich
		
69
		/* reset carp states */
70
		reset_carp();
71
		interfaces_carp_configure();
72
		
73 b0ae75c5 Bill Marquette
		$savemsg = get_std_save_message($retval);
74
		unlink_if_exists($d_vipconfdirty_path);
75
	}
76
}
77
78
if ($_GET['act'] == "del") {
79
	if ($a_vip[$_GET['id']]) {
80
		/* make sure no inbound NAT mappings reference this entry */
81
		if (is_array($config['nat']['rule'])) {
82
			foreach ($config['nat']['rule'] as $rule) {
83 7c99b15c Scott Ullrich
				if($rule['external-address'] <> "") {
84
					if ($rule['external-address'] == $a_vip[$_GET['id']]['ipaddr']) {
85
						$input_errors[] = "This entry cannot be deleted because it is still referenced by at least one NAT mapping.";
86
						break;
87
					}
88 b0ae75c5 Bill Marquette
				}
89
			}
90
		}
91
92
		if (!$input_errors) {
93
			unset($a_vip[$_GET['id']]);
94
			write_config();
95
			touch($d_vipconfdirty_path);
96
			header("Location: firewall_virtual_ip.php");
97
			exit;
98
		}
99
	}
100
}
101
102 d88c6a9f Scott Ullrich
$pgtitle = array("Firewall","Virtual IP Addresses");
103 b0ae75c5 Bill Marquette
include("head.inc");
104
105
?>
106
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
107
<?php include("fbegin.inc"); ?>
108
<form action="firewall_virtual_ip.php" method="post">
109 b760a120 Scott Ullrich
<?php 
110
	if ($input_errors) 
111
		print_input_errors($input_errors);
112
	else
113
	if ($savemsg) 
114
		print_info_box($savemsg); 
115
	else
116
	if (file_exists($d_vipconfdirty_path))
117
		print_info_box_np("The VIP configuration has been changed.<br>You must apply the changes in order for them to take effect.");
118
?>
119
<br>
120 49424ec0 Bill Marquette
<table width="100%" border="0" cellpadding="0" cellspacing="0">
121
  <tr><td class="tabnavtbl">
122
  <?php
123
        /* active tabs */
124
        $tab_array = array();
125
        $tab_array[] = array("Virtual IPs", true, "firewall_virtual_ip.php");
126
        $tab_array[] = array("CARP Settings", false, "pkg_edit.php?xml=carp_settings.xml&id=0");
127
        display_top_tabs($tab_array);
128
  ?>
129 b0ae75c5 Bill Marquette
  </td></tr>
130
  <tr>
131
    <td>
132
	<div id="mainarea">
133
              <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
134
                <tr>
135
                  <td width="30%" class="listhdrr">Virtual IP address</td>
136 9f3103a9 Bill Marquette
                  <td width="10%" class="listhdrr">Type</td>
137 b0ae75c5 Bill Marquette
                  <td width="40%" class="listhdr">Description</td>
138 d415d821 Seth Mos
                  <td width="10%" class="list">
139
                    <table border="0" cellspacing="0" cellpadding="1">
140
                      <tr>
141
			<td width="17"></td>
142
                        <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>
143
                      </tr>
144
                    </table>
145
		  </td>
146
		</tr>
147 b0ae75c5 Bill Marquette
			  <?php $i = 0; foreach ($a_vip as $vipent): ?>
148 21784301 Scott Ullrich
			  <?php if($vipent['subnet'] <> "" or $vipent['range'] <> "" or
149 2db680e1 Scott Ullrich
			        $vipent['subnet_bits'] <> "" or $vipent['range']['from'] <> "" or $vipent['mode'] == "carpdev-dhcp"): ?>
150 b0ae75c5 Bill Marquette
                <tr>
151
                  <td class="listlr" ondblclick="document.location='firewall_virtual_ip_edit.php?id=<?=$i;?>';">
152
					<?php	if (($vipent['type'] == "single") || ($vipent['type'] == "network"))
153 2db680e1 Scott Ullrich
								if($vipent['subnet_bits'])
154
									echo "{$vipent['subnet']}/{$vipent['subnet_bits']}";
155 b0ae75c5 Bill Marquette
							if ($vipent['type'] == "range")
156
								echo "{$vipent['range']['from']}-{$vipent['range']['to']}";
157
					?>
158 2db680e1 Scott Ullrich
					<?php if($vipent['mode'] == "carpdev-dhcp") echo "DHCP"; ?>
159 7633ddd8 Scott Ullrich
					<?php if($vipent['mode'] == "carp" or $vipent['mode'] == "carpdev-dhcp") echo " (vhid {$vipent['vhid']})"; ?>
160 b0ae75c5 Bill Marquette
                  </td>
161
                  <td class="listlr" align="center" ondblclick="document.location='firewall_virtual_ip_edit.php?id=<?=$i;?>';">
162 2db680e1 Scott Ullrich
                    <? 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_ipalias.gif' title='IP Alias'>";?>
163 b0ae75c5 Bill Marquette
                  </td>
164
                  <td class="listbg" ondblclick="document.location='firewall_virtual_ip_edit.php?id=<?=$i;?>';">
165
                    <font color="#FFFFFF"><?=htmlspecialchars($vipent['descr']);?>&nbsp;
166
                  </td>
167
                  <td class="list" nowrap>
168
                    <table border="0" cellspacing="0" cellpadding="1">
169
                      <tr>
170 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>
171
                        <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>
172 b0ae75c5 Bill Marquette
                      </tr>
173
                    </table>
174
                  </td>
175
                </tr>
176 21784301 Scott Ullrich
		<?php endif; ?>
177 b0ae75c5 Bill Marquette
                <?php $i++; endforeach; ?>
178
                <tr>
179 9f3103a9 Bill Marquette
                  <td class="list" colspan="3"></td>
180 b0ae75c5 Bill Marquette
                  <td class="list">
181
                    <table border="0" cellspacing="0" cellpadding="1">
182
                      <tr>
183 d415d821 Seth Mos
			<td width="17"></td>
184 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>
185 b0ae75c5 Bill Marquette
                      </tr>
186
                    </table>
187
                  </td>
188
                </tr>
189
		<tr>
190
		  <td colspan="4">
191
		      <p><span class="vexpl"><span class="red"><strong>Note:<br>
192 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>
193 03acfa4a Chris Buechler
                      You can check the status of your CARP Virtual IPs and interfaces <a href="carp_status.php">here</a>.</span></p>
194 b0ae75c5 Bill Marquette
		  </td>
195
		</tr>
196
              </table>
197
	   </div>
198
	</table>
199
            </form>
200
<?php include("fend.inc"); ?>
201
</body>
202
</html>