1

Is there any method (via CLI) of knowing if the server I'm at has IPv4 or IPv6?

EDIT: As for the reason why I'm asking this question (apologies if I wasn't specific enough), I'm referring to this guide by my host (Linode).

Specifically, they say (under the section about updating /etc/hosts) that:

"If you have IPv6 enabled on your Linode, you will also want to add an entry for your IPv6 address […]".

So, I'm simply wondering if and how you can figure this out via commandline. (My OS is Ubuntu 11.10 Oneiric.)

UPDATE: Apart from ifconfig, it seems the ping6 utility might prove useful, as hinted to in this article.

3
  • 5
    And your O/S is...?
    – tombull89
    Dec 16, 2011 at 10:42
  • 3
    Also define "has" -- a link-local address, local connectivity, some modicum of global connectivity, all of these are very different things with very different ways of determining their presence or absence.
    – womble
    Dec 16, 2011 at 11:00
  • 2
    Talk to your host! They are the only ones that can tell you if you have IPv6 connectivity. There's no way we (or you) can determine if the machine has it, but it's unconfigured.
    – devicenull
    Dec 18, 2011 at 5:35

3 Answers 3

5

It's not a "one or the other" option. You can query the network stack from the command line (see below) and this will return what IP addresses are assigned to each network interface, and you can then see from the format of these addresses which type they are.

ipconfig for windows

ifconfig for most *nix

Be aware that just because an address is there, it doesn't mean that it's in use. Many modern operating systems will assign a link-local address to any active network adapter by default these days.

4
  • 1
    +1. Chance hare you have both - windows for example has ipv6 autoamtically unless turned off even if no other machien is on the network. So, what you do then? It is both in most cases. And more than one 1ipv6 is common.
    – TomTom
    Dec 16, 2011 at 10:59
  • indeed @tomtom - most modern operating systems will configure a local ipV6 address these days by default (OSX 10.7 behaves the same as your windows example too, I think) so the OP needs to appreciate that just because it exists, it doesn't mean the OS is doing anything with it.
    – Rob Moir
    Dec 16, 2011 at 11:26
  • Thanks to both of you. Ipconfig pointed me in the right direction.
    – Henrik
    Dec 19, 2011 at 0:30
  • 1
    Aside: the ping6 utility seems to be suitable for testing IPv6 connectivity. E.g: $ ping6 ipv6.google.com -c 3
    – Henrik
    Dec 19, 2011 at 4:48
4

ifconfig will help you:

 stone@box ~ $ sudo ifconfig
 [sudo] password for stone: 
 eth1      Link encap:Ethernet  HWaddr aa:00:05:00:0a:02  
           inet addr:192.168.0.2  Bcast:192.168.0.255  Mask:255.255.255.0
           inet6 addr: fe80::a800:5ff:fe00:a02/64 Scope:Link
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:8931 errors:0 dropped:0 overruns:0 frame:0
           TX packets:8250 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1000 
           RX bytes:9244802 (8.8 MiB)  TX bytes:1593148 (1.5 MiB)
           Interrupt:42 Base address:0x4000 

You will see something like this, the ipv6 addr is what matters and Scope in the same line. If you see there Site then you have IPv6 routed address. (Link means only link local address.)

2

Your system will almost certainly have IPV4. You don't say which OS. You can use ifconfig in linux to get and look for an inet6 line

ifconfig | grep inet6 
inet6 addr: fe80::20c:29ff:fe5b:a5ea/64 Scope:Link

or you can use ipconfig under windows and look for IPv6 Address in the output.

1
  • I am also almost definite using ipv4 on linux, because your command did not return Scope:Link at the end of my output. I got two lines output where inet6 is red
    – bim
    Nov 9, 2022 at 17:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .