Class: ServiceObjects::NetworkInformation

Inherits:
Object
  • Object
show all
Defined in:
lib/ownlan/service_objects/network_information.rb

Class Method Summary collapse

Class Method Details

.gateway_ipObject



7
8
9
# File 'lib/ownlan/service_objects/network_information.rb', line 7

def self.gateway_ip
  @gateway_ip ||= `netstat -rn | grep 0.0.0.0 | awk '{print $2}' | grep -v "0.0.0.0"`.strip
end

.self_ip(interface) ⇒ Object



11
12
13
# File 'lib/ownlan/service_objects/network_information.rb', line 11

def self.self_ip(interface)
  @self_ip ||= `ip addr ls "#{interface}" | awk '/inet / {print $2}' | cut -d"/" -f1`.strip
end

.self_mac(interface) ⇒ Object



3
4
5
# File 'lib/ownlan/service_objects/network_information.rb', line 3

def self.self_mac(interface)
  @self_mac ||= `ifconfig "#{interface}" | head -n1 | tr -s ' ' | cut -d' ' -f5`.strip
end