Project

General

Profile

« Previous | Next » 

Revision 18d4d360

Added by Jim Pingle over 13 years ago

Change SNMP binding option to work on any eligible interface/VIP. Fixes #2158

View differences:

etc/inc/services.inc
771 771

  
772 772
EOD;
773 773

  
774
		if(isset($config['snmpd']['bindlan'])) {
775
			$bind_to_ip = get_interface_ip("lan");
776
		} else {
777
			$bind_to_ip = "0.0.0.0";
774
		$bind_to_ip = "0.0.0.0";
775
		if(isset($config['snmpd']['bindip'])) {
776
			if (is_ipaddr($config['snmpd']['bindip'])) {
777
				$bind_to_ip = $config['snmpd']['bindip'];
778
			} else {
779
				$if = get_real_interface($config['snmpd']['bindip']);
780
				if (does_interface_exist($if))
781
					$bind_to_ip = find_interface_ip($if);
782
			}
778 783
		}
779 784

  
780 785
		if(is_port( $config['snmpd']['pollport'] )) {
etc/inc/system.inc
1451 1451
	return file_get_contents("{$g['varlog_path']}/dmesg.boot");
1452 1452
}
1453 1453

  
1454
function openntpd_get_listen_ips() {
1454
function get_possible_listen_ips() {
1455 1455
	$interfaces = get_configured_interface_with_descr();
1456 1456
	$carplist = get_configured_carp_interface_list();
1457 1457
	$listenips = array();
usr/local/pkg/openntpd.xml
17 17
			<default_value>lan</default_value>
18 18
			<multiple/>
19 19
			<type>select_source</type>
20
			<source><![CDATA[openntpd_get_listen_ips()]]></source>
20
			<source><![CDATA[get_possible_listen_ips()]]></source>
21 21
			<source_name>name</source_name>
22 22
			<source_value>value</source_value>
23 23

  
usr/local/www/services_snmp.php
75 75
$pconfig['pf'] = isset($config['snmpd']['modules']['pf']);
76 76
$pconfig['hostres'] = isset($config['snmpd']['modules']['hostres']);
77 77
$pconfig['bridge'] = isset($config['snmpd']['modules']['bridge']);
78
$pconfig['bindlan'] = isset($config['snmpd']['bindlan']);
78
$pconfig['bindip'] = isset($config['snmpd']['bindip']);
79 79

  
80 80
if ($_POST) {
81 81

  
......
146 146
		$config['snmpd']['modules']['pf'] = $_POST['pf'] ? true : false;
147 147
		$config['snmpd']['modules']['hostres'] = $_POST['hostres'] ? true : false;
148 148
		$config['snmpd']['modules']['bridge'] = $_POST['bridge'] ? true : false;
149
		$config['snmpd']['bindlan'] = $_POST['bindlan'] ? true : false;
149
		$config['snmpd']['bindip'] = $_POST['bindip'];
150 150
			
151 151
		write_config();
152 152
		
......
207 207
	    document.iform.syscontact.disabled = false;
208 208
	    document.iform.rocommunity.disabled = false;
209 209
	    document.iform.trapenable.disabled = false;
210
	    //document.iform.bindlan.disabled = false;
211 210
	    /* disabled until some docs show up on what this does.
212 211
	    document.iform.rwenable.disabled = false;
213 212
	    if( document.iform.rwenable.checked == true )
......
257 256
            document.iform.pf.disabled = true;
258 257
            document.iform.hostres.disabled = true;
259 258
            //document.iform.bridge.disabled = true;
260
	    //document.iform.bindlan.disabled = true;
261 259
	}
262 260
}
263 261
//-->
......
384 382
		    <input name="hostres" type="checkbox" id="hostres" value="yes" onClick="check_deps()" <?php if ($pconfig['hostres']) echo "checked"; ?> ><?=gettext("Host Resources (Requires MibII)");?>
385 383
		  </td>
386 384
		</tr>
387
<?php if($config['interfaces']['lan']): ?>
388
		 <tr> 
389
		   <td width="22%" valign="top" class="vtable"></td>
390
		   <td width="78%" class="vtable"> 
391
		     <input name="bindlan" type="checkbox" value="yes" <?php if ($pconfig['bindlan']) echo "checked"; ?>> <strong><?=gettext("Bind to LAN interface only");?></strong>
392
		     <br>
393
		     <?=gettext("This option can be useful when trying to access the SNMP agent".
394
            	    " by the LAN interface's IP address through a VPN tunnel terminated on the WAN interface.");?></td>
395
		 </tr>
396
<?php endif; ?>
385

  
386
		<tr><td>&nbsp;</td></tr>
387

  
388
		<tr>
389
			<td colspan="2" valign="top" class="optsect_t">
390
			<table border="0" cellspacing="0" cellpadding="0" width="100%">
391
				<tr><td class="optsect_s"><strong><?=gettext("Interface Binding");?></strong></td>
392
				<td align="right" class="optsect_s">&nbsp;</td></tr>
393
			</table></td>
394
		</tr>
395
		<tr>
396
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Bind Interface"); ?></td>
397
			<td width="78%" class="vtable">
398
				<select name="bindip" class="formselect">
399
					<option value="">All</option>
400
				<?php  $listenips = get_possible_listen_ips();
401
					foreach ($listenips as $lip):
402
						$selected = "";
403
						if ($lip['value'] == $pconfig['bindip'])
404
							$selected = "selected";
405
				?>
406
					<option value="<?=$lip['value'];?>" <?=$selected;?>>
407
						<?=htmlspecialchars($lip['name']);?>
408
					</option>
409
				<?php endforeach; ?>
410
		</tr>
397 411
		 <tr> 
398 412
		   <td width="22%" valign="top">&nbsp;</td>
399 413
		   <td width="78%"> 

Also available in: Unified diff