Created
October 19, 2017 19:04
-
-
Save kanazux/5e394bb019d39e30ef483889bbc3f363 to your computer and use it in GitHub Desktop.
get interface ip by the default gateway on pfsense
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once("interfaces.inc"); | |
require_once("gwlb.inc"); | |
$i = get_interfaces_with_gateway(); | |
$a = shell_exec("netstat -rn | grep -i default | sed -r 's/(.*\ )([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})(.*)/\\2/p' | sort -u"); | |
$gw_arr = return_gateways_array(); | |
foreach($gw_arr as $gw) | |
if($gw['gateway'] == trim($a)) | |
print get_interface_ip($gw['friendlyiface']); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment