linux命令取ip,Linux通过命令仅获取IP地址

1

[root@archsitdb203 ~]# ip a

1: lo: mtu 16436 qdisc noqueue state UNKNOWN

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

inet 10.27.139.185/32 scope global lo

inet6 ::1/128 scope host

valid_lft forever preferred_lft forever

2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000

link/ether fa:16:3e:fd:41:4a brd ff:ff:ff:ff:ff:ff

inet 10.27.139.187/27 brd 10.27.139.191 scope global eth0

inet 10.27.139.184/32 scope global eth0

inet6 fe80::f816:3eff:fefd:414a/64 scope link

valid_lft forever preferred_lft forever

[root@archsitdb203 ~]# ip add show eth0 | grep "scope global" |grep "brd" | awk '{ print $2}'|cut -d "/" -f1

10.27.139.187

2

[root@archsitdb203 ~]# ifconfig

eth0 Link encap:Ethernet HWaddr FA:16:3E:FD:41:4A

inet addr:10.27.139.187 Bcast:10.27.139.191 Mask:255.255.255.224

inet6 addr: fe80::f816:3eff:fefd:414a/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:449473649 errors:0 dropped:0 overruns:0 frame:0

TX packets:716237658 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:66727718736 (62.1 GiB) TX bytes:106335603852 (99.0 GiB)

lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

inet6 addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:209168451 errors:0 dropped:0 overruns:0 frame:0

TX packets:209168451 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:50858540919 (47.3 GiB) TX bytes:50858540919 (47.3 GiB)

[root@archsitdb203 ~]# ifconfig eth0 | grep "inet addr" | awk '{ print $2}' | awk -F: '{print $2}'

10.27.139.187

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值