Project

General

Profile

Download (2.82 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
#!/usr/local/bin/php -f
2
<?php
3 1b8df11b Bill Marquette
/* $Id$ */
4 5b237745 Scott Ullrich
/*
5
	rc.newwanip
6
	part of m0n0wall (http://m0n0.ch/wall)
7 961a0889 Scott Ullrich
8 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
9
	All rights reserved.
10 961a0889 Scott Ullrich
11 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13 961a0889 Scott Ullrich
14 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16 961a0889 Scott Ullrich
17 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
18
	   notice, this list of conditions and the following disclaimer in the
19
	   documentation and/or other materials provided with the distribution.
20 961a0889 Scott Ullrich
21 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
25
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
	POSSIBILITY OF SUCH DAMAGE.
31
*/
32
33
	/* parse the configuration and include all functions used below */
34
	require_once("config.inc");
35
	require_once("functions.inc");
36 961a0889 Scott Ullrich
37 5b237745 Scott Ullrich
	/* WAN IP address has changed */
38 961a0889 Scott Ullrich
39
	/* make sure to wait until the boot scripts have finished
40 5b237745 Scott Ullrich
	while (file_exists("{$g['varrun_path']}/booting")) {
41
		sleep(1);
42
	}
43
        */
44 961a0889 Scott Ullrich
45 5b237745 Scott Ullrich
	$curwanip = get_current_wan_address();
46 961a0889 Scott Ullrich
47 5b237745 Scott Ullrich
	/*	dhclient or MPD told us that the IP address has changed;
48
		let's see if that's really true to avoid reloading things
49
		when it's not really necessary (dhclient likes to
50
		execute its dhclient-exit-hooks also on renewals)
51 961a0889 Scott Ullrich
	*/
52 5b237745 Scott Ullrich
	if (file_exists("{$g['vardb_path']}/wanip")) {
53
		$oldwanip = chop(file_get_contents("{$g['vardb_path']}/wanip"));
54 961a0889 Scott Ullrich
55 5b237745 Scott Ullrich
		if ($curwanip == $oldwanip)
56
			return 0;	/* nothing to do */
57
	}
58 961a0889 Scott Ullrich
59 602d9466 Scott Ullrich
	/* relaunch pftpx */
60
	system_start_ftp_helpers();
61
62 5b237745 Scott Ullrich
	/* resync ipfilter */
63
	filter_resync();
64 961a0889 Scott Ullrich
65 5b237745 Scott Ullrich
	/* flush NAT table */
66 961a0889 Scott Ullrich
	//filter_flush_nat_table();
67
68 5b237745 Scott Ullrich
	/* reconfigure IPsec tunnels */
69
	vpn_ipsec_configure(true);
70 961a0889 Scott Ullrich
71 5b237745 Scott Ullrich
	/* regenerate resolv.conf if DNS overrides are allowed or the BigPond
72
	   client is enabled */
73
	if (isset($config['system']['dnsallowoverride']) ||
74
			($config['interfaces']['wan']['ipaddr'] == "bigpond"))
75
		system_resolvconf_generate(true);
76 961a0889 Scott Ullrich
77 5b237745 Scott Ullrich
	/* fire up the BigPond client, if necessary */
78
	if ($config['interfaces']['wan']['ipaddr'] == "bigpond")
79
		interfaces_wan_bigpond_configure($curwanip);
80 961a0889 Scott Ullrich
81 5b237745 Scott Ullrich
	/* write current WAN IP to file */
82
	$fd = @fopen("{$g['vardb_path']}/wanip", "w");
83
	if ($fd) {
84
		fwrite($fd, $curwanip);
85
		fclose($fd);
86
	}
87 961a0889 Scott Ullrich
?>