$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); } /** @var mixed|string $ip */ $ip = gethostbyname(gethostname()); if (is_string($ip)) { return $ip; } throw new RuntimeException('Can not get the internal IP.'); } }