Project

General

Profile

Download (8.33 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
##|+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
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
		$retval = services_proxyarp_configure();
61
		/* Bring up any configured CARP interfaces */
62
		reset_carp();
63
		$retval |= filter_configure();
64
		interfaces_ipalias_configure();
65
		/* reset carp states */
66
		reset_carp();
67
		interfaces_carp_configure();
68
		
69
		$savemsg = get_std_save_message($retval);
70
		clear_subsystem_dirty('vip');
71
	}
72
}
73

    
74
if ($_GET['act'] == "del") {
75
	if ($a_vip[$_GET['id']]) {
76
		/* make sure no inbound NAT mappings reference this entry */
77
		if (is_array($config['nat']['rule'])) {
78
			foreach ($config['nat']['rule'] as $rule) {
79
				if($rule['external-address'] <> "") {
80
					if ($rule['external-address'] == $a_vip[$_GET['id']]['ipaddr']) {
81
						$input_errors[] = "This entry cannot be deleted because it is still referenced by at least one NAT mapping.";
82
						break;
83
					}
84
				}
85
			}
86
		}
87

    
88
		if (!$input_errors) {
89
			if ($a_vip[$_GET['id']]['type'] == "ipalias")
90
				mwexec("/sbin/ifconfig " . get_real_interface($a_vip[$_GET['id']]['interface']) . " delete {$a_vip[$_GET['id']]['subnet']}");
91
			unset($a_vip[$_GET['id']]);
92
			write_config();
93
			mark_subsystem_dirty('vip');
94
			header("Location: firewall_virtual_ip.php");
95
			exit;
96
		}
97
	}
98
}
99

    
100
$pgtitle = array("Firewall","Virtual IP Addresses");
101
include("head.inc");
102

    
103
?>
104
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
105
<?php include("fbegin.inc"); ?>
106
<form action="firewall_virtual_ip.php" method="post">
107
<?php 
108
	if ($input_errors) 
109
		print_input_errors($input_errors);
110
	else
111
	if ($savemsg) 
112
		print_info_box($savemsg); 
113
	else
114
	if (is_subsystem_dirty('vip'))
115
		print_info_box_np("The VIP configuration has been changed.<br>You must apply the changes in order for them to take effect.");
116
?>
117
<br>
118
<table width="100%" border="0" cellpadding="0" cellspacing="0">
119
  <tr><td class="tabnavtbl">
120
  <?php
121
        /* active tabs */
122
        $tab_array = array();
123
        $tab_array[] = array("Virtual IPs", true, "firewall_virtual_ip.php");
124
        $tab_array[] = array("CARP Settings", false, "pkg_edit.php?xml=carp_settings.xml&id=0");
125
        display_top_tabs($tab_array);
126
  ?>
127
  </td></tr>
128
  <tr>
129
    <td>
130
	<div id="mainarea">
131
              <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
132
                <tr>
133
                  <td width="30%" class="listhdrr">Virtual IP address</td>
134
                  <td width="10%" class="listhdrr">Type</td>
135
                  <td width="40%" class="listhdr">Description</td>
136
                  <td width="10%" class="list">
137
                    <table border="0" cellspacing="0" cellpadding="1">
138
                      <tr>
139
			<td width="17"></td>
140
                        <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>
141
                      </tr>
142
                    </table>
143
		  </td>
144
		</tr>
145
			  <?php $i = 0; foreach ($a_vip as $vipent): ?>
146
			  <?php if($vipent['subnet'] <> "" or $vipent['range'] <> "" or
147
			        $vipent['subnet_bits'] <> "" or (isset($vipent['range']['from']) && $vipent['range']['from'] <> "") or $vipent['mode'] == "carpdev-dhcp"): ?>
148
                <tr>
149
                  <td class="listlr" ondblclick="document.location='firewall_virtual_ip_edit.php?id=<?=$i;?>';">
150
					<?php	if (($vipent['type'] == "single") || ($vipent['type'] == "network"))
151
								if($vipent['subnet_bits'])
152
									echo "{$vipent['subnet']}/{$vipent['subnet_bits']}";
153
							if ($vipent['type'] == "range")
154
								echo "{$vipent['range']['from']}-{$vipent['range']['to']}";
155
					?>
156
					<?php if($vipent['mode'] == "carpdev-dhcp") echo "DHCP"; ?>
157
					<?php if($vipent['mode'] == "carp" or $vipent['mode'] == "carpdev-dhcp") echo " (vhid {$vipent['vhid']})"; ?>
158
                  </td>
159
                  <td class="listr" align="center" ondblclick="document.location='firewall_virtual_ip_edit.php?id=<?=$i;?>';">
160
                    <? 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'>";?>
161
                  </td>
162
                  <td class="listbg" ondblclick="document.location='firewall_virtual_ip_edit.php?id=<?=$i;?>';">
163
                    <?=htmlspecialchars($vipent['descr']);?>&nbsp;
164
                  </td>
165
                  <td class="list" nowrap>
166
                    <table border="0" cellspacing="0" cellpadding="1">
167
                      <tr>
168
                        <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>
169
                        <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>
170
                      </tr>
171
                    </table>
172
                  </td>
173
                </tr>
174
		<?php endif; ?>
175
                <?php $i++; endforeach; ?>
176
                <tr>
177
                  <td class="list" colspan="3"></td>
178
                  <td class="list">
179
                    <table border="0" cellspacing="0" cellpadding="1">
180
                      <tr>
181
			<td width="17"></td>
182
                        <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>
183
                      </tr>
184
                    </table>
185
                  </td>
186
                </tr>
187
		<tr>
188
		  <td colspan="4">
189
		      <p><span class="vexpl"><span class="red"><strong>Note:<br>
190
                      </strong></span>The virtual IP addresses defined on this page may be used in <a href="firewall_nat.php">NAT</a> mappings.<br>
191
                      You can check the status of your CARP Virtual IPs and interfaces <a href="carp_status.php">here</a>.</span></p>
192
		  </td>
193
		</tr>
194
              </table>
195
	   </div>
196
	</table>
197
            </form>
198
<?php include("fend.inc"); ?>
199
</body>
200
</html>
(66-66/217)