Class: VagrantAutoDNS::Cap::GetIP
- Inherits:
-
Object
- Object
- VagrantAutoDNS::Cap::GetIP
- Extended by:
- Common
- Defined in:
- lib/vagrant-autodns/cap/get_ip.rb
Class Method Summary collapse
Methods included from Common
iptables_location, run_command
Class Method Details
.get_ip(machine) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vagrant-autodns/cap/get_ip.rb', line 16 def self.get_ip(machine) #Multi-lined and joined with pipes for readability command = [ '/sbin/ifconfig -a', #Prints ifconfig 'grep inet', #Get ip address lines only 'grep -v \'127.0.0.1\'', #Remove localhost 'grep -Eo \'[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}.*\'', #match IPv4 line 'awk \'{print $1}\'', 'tail -n1' #Pick last ].join(' | ') run_command(machine, command) end |