Project

General

Profile

Download (9.18 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 7ac5a4cb Scott Ullrich
/*
40
	pfSense_BUILDER_BINARIES:	/sbin/ifconfig
41
	pfSense_MODULE:	interfaces
42
*/
43 b0ae75c5 Bill Marquette
44 6b07c15a Matthew Grooms
##|+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 b0ae75c5 Bill Marquette
require("guiconfig.inc");
52 7a927e67 Scott Ullrich
require_once("functions.inc");
53
require_once("filter.inc");
54
require_once("shaper.inc");
55 b0ae75c5 Bill Marquette
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 abcb2bed Ermal Lu?i
		
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 123f030c Chris Buechler
                        interface_proxyarp_configure();
73 abcb2bed Ermal Lu?i
                        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 b0ae75c5 Bill Marquette
		$retval = 0;
85 920b3bb0 Scott Ullrich
		$retval |= filter_configure();
86 b0ae75c5 Bill Marquette
		$savemsg = get_std_save_message($retval);
87 abcb2bed Ermal Lu?i
88 a368a026 Ermal Lu?i
		clear_subsystem_dirty('vip');
89 b0ae75c5 Bill Marquette
	}
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 7c99b15c Scott Ullrich
				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 b0ae75c5 Bill Marquette
				}
103
			}
104
		}
105
106
		if (!$input_errors) {
107 1ba7a81b Ermal Lu?i
			// 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 b0ae75c5 Bill Marquette
			write_config();
116 a368a026 Ermal Lu?i
			mark_subsystem_dirty('vip');
117 b0ae75c5 Bill Marquette
			header("Location: firewall_virtual_ip.php");
118
			exit;
119
		}
120
	}
121 abcb2bed Ermal Lu?i
} else if ($_GET['changes'] == "mods")
122
	$id = $_GET['id'];
123 b0ae75c5 Bill Marquette
124 d88c6a9f Scott Ullrich
$pgtitle = array("Firewall","Virtual IP Addresses");
125 b0ae75c5 Bill Marquette
include("head.inc");
126
127
?>
128
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
129
<?php include("fbegin.inc"); ?>
130
<form action="firewall_virtual_ip.php" method="post">
131 b760a120 Scott Ullrich
<?php 
132
	if ($input_errors) 
133
		print_input_errors($input_errors);
134
	else
135
	if ($savemsg) 
136
		print_info_box($savemsg); 
137
	else
138 a368a026 Ermal Lu?i
	if (is_subsystem_dirty('vip'))
139 b760a120 Scott Ullrich
		print_info_box_np("The VIP configuration has been changed.<br>You must apply the changes in order for them to take effect.");
140
?>
141
<br>
142 49424ec0 Bill Marquette
<table width="100%" border="0" cellpadding="0" cellspacing="0">
143
  <tr><td class="tabnavtbl">
144
  <?php
145
        /* active tabs */
146
        $tab_array = array();
147
        $tab_array[] = array("Virtual IPs", true, "firewall_virtual_ip.php");
148
        $tab_array[] = array("CARP Settings", false, "pkg_edit.php?xml=carp_settings.xml&id=0");
149
        display_top_tabs($tab_array);
150
  ?>
151 b0ae75c5 Bill Marquette
  </td></tr>
152 abcb2bed Ermal Lu?i
  <tr>
153
	<td><input type="hidden" id="id" name="id" value="<? echo $id; ?>"></td>
154
  </tr>
155 b0ae75c5 Bill Marquette
  <tr>
156
    <td>
157
	<div id="mainarea">
158
              <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
159
                <tr>
160
                  <td width="30%" class="listhdrr">Virtual IP address</td>
161 9f3103a9 Bill Marquette
                  <td width="10%" class="listhdrr">Type</td>
162 b0ae75c5 Bill Marquette
                  <td width="40%" class="listhdr">Description</td>
163 d415d821 Seth Mos
                  <td width="10%" class="list">
164
                    <table border="0" cellspacing="0" cellpadding="1">
165
                      <tr>
166
			<td width="17"></td>
167
                        <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>
168
                      </tr>
169
                    </table>
170
		  </td>
171
		</tr>
172 b0ae75c5 Bill Marquette
			  <?php $i = 0; foreach ($a_vip as $vipent): ?>
173 21784301 Scott Ullrich
			  <?php if($vipent['subnet'] <> "" or $vipent['range'] <> "" or
174 2064fb9d Ermal Lu?i
			        $vipent['subnet_bits'] <> "" or (isset($vipent['range']['from']) && $vipent['range']['from'] <> "") or $vipent['mode'] == "carpdev-dhcp"): ?>
175 b0ae75c5 Bill Marquette
                <tr>
176
                  <td class="listlr" ondblclick="document.location='firewall_virtual_ip_edit.php?id=<?=$i;?>';">
177
					<?php	if (($vipent['type'] == "single") || ($vipent['type'] == "network"))
178 2db680e1 Scott Ullrich
								if($vipent['subnet_bits'])
179
									echo "{$vipent['subnet']}/{$vipent['subnet_bits']}";
180 b0ae75c5 Bill Marquette
							if ($vipent['type'] == "range")
181
								echo "{$vipent['range']['from']}-{$vipent['range']['to']}";
182
					?>
183 2db680e1 Scott Ullrich
					<?php if($vipent['mode'] == "carpdev-dhcp") echo "DHCP"; ?>
184 7633ddd8 Scott Ullrich
					<?php if($vipent['mode'] == "carp" or $vipent['mode'] == "carpdev-dhcp") echo " (vhid {$vipent['vhid']})"; ?>
185 b0ae75c5 Bill Marquette
                  </td>
186 902b4e72 Bill Marquette
                  <td class="listr" align="center" ondblclick="document.location='firewall_virtual_ip_edit.php?id=<?=$i;?>';">
187 3dee90e6 Bill Marquette
                    <? 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'>";?>
188 b0ae75c5 Bill Marquette
                  </td>
189
                  <td class="listbg" ondblclick="document.location='firewall_virtual_ip_edit.php?id=<?=$i;?>';">
190 30d4c469 Scott Ullrich
                    <?=htmlspecialchars($vipent['descr']);?>&nbsp;
191 b0ae75c5 Bill Marquette
                  </td>
192
                  <td class="list" nowrap>
193
                    <table border="0" cellspacing="0" cellpadding="1">
194
                      <tr>
195 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>
196
                        <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>
197 b0ae75c5 Bill Marquette
                      </tr>
198
                    </table>
199
                  </td>
200
                </tr>
201 21784301 Scott Ullrich
		<?php endif; ?>
202 b0ae75c5 Bill Marquette
                <?php $i++; endforeach; ?>
203
                <tr>
204 9f3103a9 Bill Marquette
                  <td class="list" colspan="3"></td>
205 b0ae75c5 Bill Marquette
                  <td class="list">
206
                    <table border="0" cellspacing="0" cellpadding="1">
207
                      <tr>
208 d415d821 Seth Mos
			<td width="17"></td>
209 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>
210 b0ae75c5 Bill Marquette
                      </tr>
211
                    </table>
212
                  </td>
213
                </tr>
214
		<tr>
215
		  <td colspan="4">
216
		      <p><span class="vexpl"><span class="red"><strong>Note:<br>
217 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>
218 03acfa4a Chris Buechler
                      You can check the status of your CARP Virtual IPs and interfaces <a href="carp_status.php">here</a>.</span></p>
219 b0ae75c5 Bill Marquette
		  </td>
220
		</tr>
221
              </table>
222
	   </div>
223
	</table>
224
            </form>
225
<?php include("fend.inc"); ?>
226
</body>
227
</html>