Project

General

Profile

Download (1.37 KB) Statistics
| Branch: | Tag: | Revision:
1
/*
2
 * restartallwans
3
 *
4
 * This script looks for all WAN interfaces by checking which of them has gateways
5
 * and then it simply disable / enable them
6
 * useful for testing configuration
7
 *
8
 */
9

    
10
global $config;
11
$config = parse_config(true);
12

    
13
$a_gateways = return_gateways_array(true, false, true, true);
14

    
15
// find gw interfaces os names (em0, vtnet1, etc):
16
$restartifs = array();
17
for ($id=0; $id<count($a_gateways); $id++) {
18
	array_push($restartifs,$a_gateways[$id]['interface']);
19
}
20
$restartifs = array_unique($restartifs);
21

    
22
// find gw interfaces pfsense names (wan, opt1, etc):
23
$names_restart = array();
24
while ($int = current($config['interfaces'])) {
25
	if (in_array($int['if'], $restartifs)) {
26
		array_push($names_restart,key($config['interfaces']));
27
	}
28
	next($config['interfaces']);
29
}
30

    
31
foreach ($names_restart as $id) {
32
	interface_bring_down($id, true, $config['interfaces'][$id]);
33
if (isset($config['dhcpd'][$id]['enable']) || 
34
	isset($config['dhcpdv6'][$id]['enable'])) {
35
		services_dhcpd_configure();
36
	}
37
	printf("Interface %s is disabled\n", $id);
38
}
39

    
40
sleep (1);
41

    
42
foreach ($names_restart as $id) {
43
	interface_bring_down($id, false, $config['interfaces'][$id]);
44
	interface_configure($id, true);
45
	if ($config['interfaces'][$id]['ipaddrv6'] == 'track6') {
46
		$wancfg = $config['interfaces'][$id];
47
		interface_track6_configure($id, $wancfg, true);
48
	}
49
	printf("Interface %s is enabled\n", $id);
50
}
51
echo "\n";
(21-21/25)