---
title: "Linux下获取IP、MAC、网关、掩码的shell脚本"
author: "duyouhua1214"
date: "2012-07-05T13:45:51Z"
tags: []
categories: ["研发管理"]
slug: "linux-ip-mac-shell"
draft: true
lastmod: "2012-07-05T13:45:51Z"
id: 1577458
url: "https://duyouhua1214.iteye.com/blog/1577458"
---

Mask:ifconfig |grep inet| sed -n '1p'|awk '{print $4}'|awk -F ':' '{print $2}'  
IP:ifconfig |grep inet| sed -n '1p'|awk '{print $2}'|awk -F ':' '{print $2}'  
mac:ifconfig |grep eth0|awk '{print $5}'

 

cat /etc/resolv.conf | awk '{print $2}'  
route -n | grep eth0 | grep UG | awk '{print $2}'