1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64[iyunv@centos6 ~]# ifconfig
eth1 Link encap:Ethernet HWaddr 00:0C:29:35:DD:AB
inet addr:10.1.253.95 Bcast:10.1.255.255 Mask:255.255.0.0
inet6 addr: fe80::20c:29ff:fe35:ddab/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:378023 errors:0 dropped:0 overruns:0 frame:0
TX packets:12444 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:46926222 (44.7 MiB) TX bytes:1240063 (1.1 MiB)
eth2 Link encap:Ethernet HWaddr 00:0C:29:35:DD:B5
inet addr:192.168.226.135 Bcast:192.168.226.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe35:ddb5/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2539 errors:0 dropped:0 overruns:0 frame:0
TX packets:225 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:281133 (274.5 KiB) TX bytes:39650 (38.7 KiB)
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:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
[iyunv@centos6 ~]# ifconfig |awk -F '[: ]+' 'NR==2{print $4}'
10.1.253.95
[iyunv@centos6 ~]# ifconfig
eth1 Link encap:Ethernet HWaddr 00:0C:29:35:DD:AB
inet addr:10.1.253.95 Bcast:10.1.255.255 Mask:255.255.0.0
inet6 addr: fe80::20c:29ff:fe35:ddab/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:379965 errors:0 dropped:0 overruns:0 frame:0
TX packets:12615 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:47097014 (44.9 MiB) TX bytes:1264173 (1.2 MiB)
eth2 Link encap:Ethernet HWaddr 00:0C:29:35:DD:B5
inet addr:192.168.226.135 Bcast:192.168.226.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe35:ddb5/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2541 errors:0 dropped:0 overruns:0 frame:0
TX packets:227 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:281535 (274.9 KiB) TX bytes:40052 (39.1 KiB)
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:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
[iyunv@centos6 ~]# ifconfig |head -2
eth1 Link encap:Ethernet HWaddr 00:0C:29:35:DD:AB
inet addr:10.1.253.95 Bcast:10.1.255.255 Mask:255.255.0.0
[iyunv@centos6 ~]# ifconfig |head -2 |sed -r 's/^.*addr:(.*) Bca.*$/\1/g'
eth1 Link encap:Ethernet HWaddr 00:0C:29:35:DD:AB
10.1.253.95
[iyunv@centos6 ~]# ifconfig |head -2|tail -1 |tr -s ' ' ':' |cut -d: -f4
10.1.253.95
[iyunv@centos6 ~]#