linux shell 获取本机ip

本机IP获取

/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"

k8s 获取容器所造node节点的ip

container_net=`ifconfig eth0 |grep "inet" |grep -v "inet6"| awk '{print $2}'|cut -d '.' -f 3`

node_ip=`etcdctl --endpoints=https://10.0.13.78:2379,https://10.0.13.80:2379,https://10.0.13.81:2379 --cert-file=/home/yanfa/cert/etcd.pem --key-file=/home/yanfa/cert/etcd-key.pem --ca-file=/home/yanfa/cert/etcd-root-ca.pem get /kube-centos/network/subnets/10.252.${container_net}.0-24 |sed 's/.*"PublicIP":"\([^"]\+\)".*/\1/' `

猜你喜欢

转载自blog.csdn.net/feifei3851/article/details/81113597
今日推荐