The interfaces plugin can be used to get information about interfaces and local IP-addresses on the system.
Follow the instructions in our manual to add our package repository and then run the below command.
apt-get install halon-extras-interfaces
yum install halon-extras-interfaces
These functions needs to be imported from the extras://interfaces module path.
Get all the interfaces.
Returns
An array of the interfaces.
Example
import { interfaces } from "extras://interfaces";
echo interfaces(); // [0=>["name"=>"lo"],1=>["name"=>"tunl0"],2=>["name"=>"ip6tnl0"],3=>["name"=>"eth0"]]
Get all the local IP-addresses or only those for a specific interface.
Params
- interface
string- The interface
Returns
An array of the local IP-addresses.
Example
import { local_ips } from "extras://interfaces";
echo local_ips(); // [0=>["address"=>"172.17.0.2"]]
echo local_ips("eth0"); // [0=>["address"=>"172.17.0.2"]]