fix:多条默认路由网卡自动识别问题

pull/1006/head
gjmzj 2021-04-17 10:49:39 +08:00
parent d2a83d06a0
commit e0b1c400df
2 changed files with 3 additions and 3 deletions

2
ezctl
View File

@ -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

4
ezdown
View File

@ -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