Project

General

Profile

Download (7.2 KB) Statistics
| Branch: | Tag: | Revision:
1 b0ae75c5 Bill Marquette
#!/usr/local/bin/php
2
<?php
3
/* $Id$ */
4
/*
5
	firewall_virtual_ip.php
6
	part of pfSense (http://www.pfsense.com/)
7
8
	Copyright (C) 2005 Bill Marquette <bill.marquette@gmail.com>.
9
	All rights reserved.
10
11
	Includes code from m0n0wall which is:
12
	Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
13
	All rights reserved.
14
15
	Includes code from pfSense which is:
16
	Copyright (C) 2004-2005 Scott Ullrich <geekgod@pfsense.com>.
17
	All rights reserved.
18
19
	Redistribution and use in source and binary forms, with or without
20
	modification, are permitted provided that the following conditions are met:
21
22
	1. Redistributions of source code must retain the above copyright notice,
23
	   this list of conditions and the following disclaimer.
24
25
	2. Redistributions in binary form must reproduce the above copyright
26
	   notice, this list of conditions and the following disclaimer in the
27
	   documentation and/or other materials provided with the distribution.
28
29
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
30
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
31
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
33
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38
	POSSIBILITY OF SUCH DAMAGE.
39
*/
40
41
require("guiconfig.inc");
42
43
if (!is_array($config['virtualip']['vip'])) {
44
	$config['virtualip']['vip'] = array();
45
}
46
$a_vip = &$config['virtualip']['vip'];
47
48
if ($_POST) {
49
	$pconfig = $_POST;
50
51
	if ($_POST['apply']) {
52
		$retval = 0;
53
		if (!file_exists($d_sysrebootreqd_path)) {
54
			config_lock();
55 eec4ff89 Bill Marquette
			$retval = services_proxyarp_configure();
56
			/* Bring up any configured CARP interfaces */
57
			interfaces_carp_configure();
58 b0ae75c5 Bill Marquette
			$retval |= filter_configure();
59
			config_unlock();
60
		}
61
		$savemsg = get_std_save_message($retval);
62
		unlink_if_exists($d_vipconfdirty_path);
63
	}
64
}
65
66
if ($_GET['act'] == "del") {
67
	if ($a_vip[$_GET['id']]) {
68
		/* make sure no inbound NAT mappings reference this entry */
69
		if (is_array($config['nat']['rule'])) {
70
			foreach ($config['nat']['rule'] as $rule) {
71 7c99b15c Scott Ullrich
				if($rule['external-address'] <> "") {
72
					if ($rule['external-address'] == $a_vip[$_GET['id']]['ipaddr']) {
73
						$input_errors[] = "This entry cannot be deleted because it is still referenced by at least one NAT mapping.";
74
						break;
75
					}
76 b0ae75c5 Bill Marquette
				}
77
			}
78
		}
79
80
		if (!$input_errors) {
81
			unset($a_vip[$_GET['id']]);
82
			write_config();
83
			touch($d_vipconfdirty_path);
84
			header("Location: firewall_virtual_ip.php");
85
			exit;
86
		}
87
	}
88
}
89
90
$pgtitle = "Firewall: Virtual IP Addresses";
91
include("head.inc");
92
93
?>
94
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
95
<?php include("fbegin.inc"); ?>
96
<p class="pgtitle"><?=$pgtitle?></p>
97
<form action="firewall_virtual_ip.php" method="post">
98
<?php if ($input_errors) print_input_errors($input_errors); ?>
99
<?php if ($savemsg) print_info_box($savemsg); ?>
100
<?php if (file_exists($d_vipconfdirty_path)): ?><p>
101
<?php print_info_box_np("The VIP configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
102
<?php endif; ?>
103 49424ec0 Bill Marquette
<table width="100%" border="0" cellpadding="0" cellspacing="0">
104
  <tr><td class="tabnavtbl">
105
  <?php
106
        /* active tabs */
107
        $tab_array = array();
108
        $tab_array[] = array("Virtual IPs", true, "firewall_virtual_ip.php");
109
        $tab_array[] = array("CARP Settings", false, "pkg_edit.php?xml=carp_settings.xml&id=0");
110
        display_top_tabs($tab_array);
111
  ?>
112 b0ae75c5 Bill Marquette
  </td></tr>
113
  <tr>
114
    <td>
115
	<div id="mainarea">
116
              <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
117
                <tr>
118
                  <td width="30%" class="listhdrr">Virtual IP address</td>
119 9f3103a9 Bill Marquette
                  <td width="10%" class="listhdrr">Type</td>
120 b0ae75c5 Bill Marquette
                  <td width="40%" class="listhdr">Description</td>
121
                  <td width="10%" class="list"></td>
122
				</tr>
123
			  <?php $i = 0; foreach ($a_vip as $vipent): ?>
124 21784301 Scott Ullrich
			  <?php if($vipent['subnet'] <> "" or $vipent['range'] <> "" or
125
			        $vipent['subnet_bits'] <> "" or $vipent['range']['from'] <> ""): ?>
126 b0ae75c5 Bill Marquette
                <tr>
127
                  <td class="listlr" ondblclick="document.location='firewall_virtual_ip_edit.php?id=<?=$i;?>';">
128
					<?php	if (($vipent['type'] == "single") || ($vipent['type'] == "network"))
129
								echo "{$vipent['subnet']}/{$vipent['subnet_bits']}";
130
							if ($vipent['type'] == "range")
131
								echo "{$vipent['range']['from']}-{$vipent['range']['to']}";
132
					?>
133
                  </td>
134
                  <td class="listlr" align="center" ondblclick="document.location='firewall_virtual_ip_edit.php?id=<?=$i;?>';">
135 68a5dcd8 Bill Marquette
                    <? if($vipent['mode'] == "proxyarp") echo "<img src='./themes/".$g['theme']."/images/icons/icon_parp.gif' title='Proxy ARP'>"; elseif($vipent['mode'] == "carp") 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'>";?>
136 b0ae75c5 Bill Marquette
                  </td>
137
                  <td class="listbg" ondblclick="document.location='firewall_virtual_ip_edit.php?id=<?=$i;?>';">
138
                    <font color="#FFFFFF"><?=htmlspecialchars($vipent['descr']);?>&nbsp;
139
                  </td>
140
                  <td class="list" nowrap>
141
                    <table border="0" cellspacing="0" cellpadding="1">
142
                      <tr>
143 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>
144
                        <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>
145 b0ae75c5 Bill Marquette
                      </tr>
146
                    </table>
147
                  </td>
148
                </tr>
149 21784301 Scott Ullrich
		<?php endif; ?>
150 b0ae75c5 Bill Marquette
                <?php $i++; endforeach; ?>
151
                <tr>
152 9f3103a9 Bill Marquette
                  <td class="list" colspan="3"></td>
153 b0ae75c5 Bill Marquette
                  <td class="list">
154
                    <table border="0" cellspacing="0" cellpadding="1">
155
                      <tr>
156 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>
157 b0ae75c5 Bill Marquette
                      </tr>
158
                    </table>
159
                  </td>
160
                </tr>
161
		<tr>
162
		  <td colspan="4">
163
		      <p><span class="vexpl"><span class="red"><strong>Note:<br>
164 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>
165
                      You can check the status of your CARP-Interfaces <a href="carp_status.php">here</a>.</span></p>
166 b0ae75c5 Bill Marquette
		  </td>
167
		</tr>
168
              </table>
169
	   </div>
170
	</table>
171
            </form>
172
<?php include("fend.inc"); ?>
173
</body>
174
</html>