# 获取网卡
ip addr | grep "2: " | awk '{print substr($2, 1, length($2)-1)}' > ipaddr.txt
# 获取网卡MAC地址
ip addr | grep link/ether | awk '{print $2}' >> ipaddr.txt
# 获取IPV4地址
ip -4 addr | grep global | awk '{print $2}' >> ipaddr.txt
# 获取IPV4网关
ip -4 route | grep default | awk '{print $3}' >> ipaddr.txt
# 获取IPV6地址
ip -6 addr | grep global | awk '{print $2}' >> ipaddr.txt
# 获取IPV6网关
ip -6 route | grep default | awk '{print $3}' >> ipaddr.txt
# 打印ipaddr.txt
cat ipaddr.txt
2、环环相扣
根据查出来的网卡名再去反查就得了