$value) { foreach ($value['unicast'] as $item) { if (! isset($item['address'])) { continue; } if (! Str::contains($item['address'], ':') && $item['address'] !== '127.0.0.1') { $ips[$name] = $item['address']; } } } } if (is_array($ips) && ! empty($ips)) { return current($ips); } $name = gethostname(); if ($name === false) { throw new RuntimeException('Can not get the internal IP.'); } return gethostbyname($name); } }