If I run /sbin/ifconfig eth0
I get the following output:
Link encap:Ethernet HWaddr <address hidden for privacy>
inet addr:<address hidden for privacy> Bcast:<address hidden for privacy> Mask:255.255.255.0
inet6 addr: <address hidden for privacy> Scope:Link
inet6 addr: <address hidden for privacy> Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5891 errors:0 dropped:0 overruns:0 frame:0
TX packets:4933 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:23922030 (22.8 MiB) TX bytes:455152 (444.4 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)
How do I get the ipv6 address where the scope is global ?
So far, If I do:
/sbin/ifconfig eth0 | awk '/inet6 / { print $3 }'
I get both the addresses (from scopes "link" AND "global"), but I want only the scope for "Global"
Also, this seems like a very messy way to get it, since I am relying on ifconfig outputting the data in a certain order / format. I would rather use commands to get exactly what I want.