Project

General

Profile

Download (9.18 KB) Statistics
| Branch: | Tag: | Revision:
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
			write_config();
116
			mark_subsystem_dirty('vip');
117
			header("Location: firewall_virtual_ip.php");
118
			exit;
119
		}
120
	}
121
} else if ($_GET['changes'] == "mods")
122
	$id = $_GET['id'];
123

    
124
$pgtitle = array("Firewall","Virtual IP Addresses");
125
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
<?php 
132
	if ($input_errors) 
133
		print_input_errors($input_errors);
134
	else
135
	if ($savemsg) 
136
		print_info_box($savemsg); 
137
	else
138
	if (is_subsystem_dirty('vip'))
139
		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
<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
  </td></tr>
152
  <tr>
153
	<td><input type="hidden" id="id" name="id" value="<? echo $id; ?>"></td>
154
  </tr>
155
  <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
                  <td width="10%" class="listhdrr">Type</td>
162
                  <td width="40%" class="listhdr">Description</td>
163
                  <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
			  <?php $i = 0; foreach ($a_vip as $vipent): ?>
173
			  <?php if($vipent['subnet'] <> "" or $vipent['range'] <> "" or
174
			        $vipent['subnet_bits'] <> "" or (isset($vipent['range']['from']) && $vipent['range']['from'] <> "") or $vipent['mode'] == "carpdev-dhcp"): ?>
175
                <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
								if($vipent['subnet_bits'])
179
									echo "{$vipent['subnet']}/{$vipent['subnet_bits']}";
180
							if ($vipent['type'] == "range")
181
								echo "{$vipent['range']['from']}-{$vipent['range']['to']}";
182
					?>
183
					<?php if($vipent['mode'] == "carpdev-dhcp") echo "DHCP"; ?>
184
					<?php if($vipent['mode'] == "carp" or $vipent['mode'] == "carpdev-dhcp") echo " (vhid {$vipent['vhid']})"; ?>
185
                  </td>
186
                  <td class="listr" align="center" ondblclick="document.location='firewall_virtual_ip_edit.php?id=<?=$i;?>';">
187
                    <? 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
                  </td>
189
                  <td class="listbg" ondblclick="document.location='firewall_virtual_ip_edit.php?id=<?=$i;?>';">
190
                    <?=htmlspecialchars($vipent['descr']);?>&nbsp;
191
                  </td>
192
                  <td class="list" nowrap>
193
                    <table border="0" cellspacing="0" cellpadding="1">
194
                      <tr>
195
                        <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
                      </tr>
198
                    </table>
199
                  </td>
200
                </tr>
201
		<?php endif; ?>
202
                <?php $i++; endforeach; ?>
203
                <tr>
204
                  <td class="list" colspan="3"></td>
205
                  <td class="list">
206
                    <table border="0" cellspacing="0" cellpadding="1">
207
                      <tr>
208
			<td width="17"></td>
209
                        <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
                      </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
                      </strong></span>The virtual IP addresses defined on this page may be used in <a href="firewall_nat.php">NAT</a> mappings.<br>
218
                      You can check the status of your CARP Virtual IPs and interfaces <a href="carp_status.php">here</a>.</span></p>
219
		  </td>
220
		</tr>
221
              </table>
222
	   </div>
223
	</table>
224
            </form>
225
<?php include("fend.inc"); ?>
226
</body>
227
</html>
(64-64/214)