diff --git a/ezctl b/ezctl index 1b89bf4..08714b7 100755 --- a/ezctl +++ b/ezctl @@ -411,7 +411,7 @@ function start-aio(){ # Check ENV 'HOST_IP', exists if the CMD 'ezctl' running in a docker container if [[ -z $HOST_IP ]];then # ezctl runs in a host machine, get host's ip - HOST_IF=$(ip route|grep default|cut -d' ' -f5) + HOST_IF=$(ip route|grep default|head -n1|cut -d' ' -f5) HOST_IP=$(ip a|grep "$HOST_IF$"|head -n1|awk '{print $2}'|cut -d'/' -f1) fi set -u diff --git a/ezdown b/ezdown index a962987..1a7b484 100755 --- a/ezdown +++ b/ezdown @@ -327,8 +327,8 @@ function start_kubeasz_docker() { logger info "try to run kubeasz in a container" # get host's IP - host_if=$(ip route|grep default|cut -d' ' -f5) - host_ip=$(ip a|grep "$host_if$"|awk '{print $2}'|cut -d'/' -f1) + host_if=$(ip route|grep default|head -n1|cut -d' ' -f5) + host_ip=$(ip a|grep "$host_if$"|head -n1|awk '{print $2}'|cut -d'/' -f1) logger debug "get host IP: $host_ip" # allow ssh login using key locally