Project

General

Profile

Download (9.27 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 93e485e3 Renato Botelho
				if($rule['destination']['address'] <> "") {
98 3504e10b Renato Botelho
					if ($rule['destination']['address'] == $a_vip[$_GET['id']]['subnet']) {
99 7c99b15c Scott Ullrich
						$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 ed65eb04 Ermal Lu?i
			if (count($config['virtualip']['vip']) == 0)
116
				unset($config['virtualip']['vip']);
117 b0ae75c5 Bill Marquette
			write_config();
118 a368a026 Ermal Lu?i
			mark_subsystem_dirty('vip');
119 b0ae75c5 Bill Marquette
			header("Location: firewall_virtual_ip.php");
120
			exit;
121
		}
122
	}
123 abcb2bed Ermal Lu?i
} else if ($_GET['changes'] == "mods")
124
	$id = $_GET['id'];
125 b0ae75c5 Bill Marquette
126 d88c6a9f Scott Ullrich
$pgtitle = array("Firewall","Virtual IP Addresses");
127 b0ae75c5 Bill Marquette
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 b760a120 Scott Ullrich
<?php 
134
	if ($input_errors) 
135
		print_input_errors($input_errors);
136
	else
137
	if ($savemsg) 
138
		print_info_box($savemsg); 
139
	else
140 a368a026 Ermal Lu?i
	if (is_subsystem_dirty('vip'))
141 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.");
142
?>
143
<br>
144 49424ec0 Bill Marquette
<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 b0ae75c5 Bill Marquette
  </td></tr>
154 abcb2bed Ermal Lu?i
  <tr>
155
	<td><input type="hidden" id="id" name="id" value="<? echo $id; ?>"></td>
156
  </tr>
157 b0ae75c5 Bill Marquette
  <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 9f3103a9 Bill Marquette
                  <td width="10%" class="listhdrr">Type</td>
164 b0ae75c5 Bill Marquette
                  <td width="40%" class="listhdr">Description</td>
165 d415d821 Seth Mos
                  <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 b0ae75c5 Bill Marquette
			  <?php $i = 0; foreach ($a_vip as $vipent): ?>
175 21784301 Scott Ullrich
			  <?php if($vipent['subnet'] <> "" or $vipent['range'] <> "" or
176 2064fb9d Ermal Lu?i
			        $vipent['subnet_bits'] <> "" or (isset($vipent['range']['from']) && $vipent['range']['from'] <> "") or $vipent['mode'] == "carpdev-dhcp"): ?>
177 b0ae75c5 Bill Marquette
                <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 2db680e1 Scott Ullrich
								if($vipent['subnet_bits'])
181
									echo "{$vipent['subnet']}/{$vipent['subnet_bits']}";
182 b0ae75c5 Bill Marquette
							if ($vipent['type'] == "range")
183
								echo "{$vipent['range']['from']}-{$vipent['range']['to']}";
184
					?>
185 2db680e1 Scott Ullrich
					<?php if($vipent['mode'] == "carpdev-dhcp") echo "DHCP"; ?>
186 7633ddd8 Scott Ullrich
					<?php if($vipent['mode'] == "carp" or $vipent['mode'] == "carpdev-dhcp") echo " (vhid {$vipent['vhid']})"; ?>
187 b0ae75c5 Bill Marquette
                  </td>
188 902b4e72 Bill Marquette
                  <td class="listr" align="center" ondblclick="document.location='firewall_virtual_ip_edit.php?id=<?=$i;?>';">
189 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'>";?>
190 b0ae75c5 Bill Marquette
                  </td>
191
                  <td class="listbg" ondblclick="document.location='firewall_virtual_ip_edit.php?id=<?=$i;?>';">
192 30d4c469 Scott Ullrich
                    <?=htmlspecialchars($vipent['descr']);?>&nbsp;
193 b0ae75c5 Bill Marquette
                  </td>
194
                  <td class="list" nowrap>
195
                    <table border="0" cellspacing="0" cellpadding="1">
196
                      <tr>
197 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>
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 b0ae75c5 Bill Marquette
                      </tr>
200
                    </table>
201
                  </td>
202
                </tr>
203 21784301 Scott Ullrich
		<?php endif; ?>
204 b0ae75c5 Bill Marquette
                <?php $i++; endforeach; ?>
205
                <tr>
206 9f3103a9 Bill Marquette
                  <td class="list" colspan="3"></td>
207 b0ae75c5 Bill Marquette
                  <td class="list">
208
                    <table border="0" cellspacing="0" cellpadding="1">
209
                      <tr>
210 d415d821 Seth Mos
			<td width="17"></td>
211 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>
212 b0ae75c5 Bill Marquette
                      </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 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>
220 03acfa4a Chris Buechler
                      You can check the status of your CARP Virtual IPs and interfaces <a href="carp_status.php">here</a>.</span></p>
221 b0ae75c5 Bill Marquette
		  </td>
222
		</tr>
223
              </table>
224
	   </div>
225
	</table>
226
            </form>
227
<?php include("fend.inc"); ?>
228
</body>
229
</html>