How-To: Manually Set IPv6 Address in Mac OS X

How-To: Manually Set IPv6 Address in Mac OS X

Since i began using ipv6, I have never set a routable static ipv6 address yet. I have a Linksys (w/ dd-wrt firmware) router serving as DHCP server, so i reckon there’s no use for that.

UPDATE: On second thought, there must be that ONE time. I must have configured statically when testing the tunnelbroker via wired connection. I’m not too sure.

Anyway, today – as we are testing our network for native ipv6 – i had to configure my machine and assign manual ip address. It’s only now that I discovered the problem (a bug?) in the GUI. Luckily, I am not alone, and a few searches yield helpful infos.

Using the GUI, the basic step is typically same as v4 (we all know this):
SystemPreferences -> Network->Advanced
Under Configure IPv6, select Manually and input your static ipv6 address.

However, it is likely that although settings are saved in the gui, the network config does not update at the same time.

So do some checks with any of the ff. commands:
ifconfig | grep inet6
ifconfig en0 | grep inet6
ifconfig | awk ‘/inet6 / {print $2}’
ifconfig en1 | grep inet6 | grep -m 1 -v ‘%’

If it wasn’t updated from gui, then do manual config via Terminal:
sudo ifconfig en0 inet6 2100:abcd:4321::2/48 (to add new ip – also called ‘alias’ to the interface)
sudo route add -inet6 -prefixlen 0 default 2100:abcd:4321::1 (to add route or gateway)

Some sort of checking, to confirm if it was added to the config:
ifconfig en0 | grep inet6
netstat -r -f inet6

If you have assigned wrong ip address and needs to change, here’s how to remove it.
sudo ifconfig en1 inet6 -alias 2100:abcd::2

Simple.

  • Clark Matthews

    This didn’t solve it for me between boots, however it did work until I rebooted.

    It did lead me in the correct direction for the final solution however. The ‘man’ page for ‘ifconfig’ lead me to ‘networksetup’ and this made it permanent between boots (adjusted to your sample addresses):

    $ sudo networksetup -setv6manual “Ethernet” 2100:abcd:4321::2 48 2100:abcd:4321::1

  • Interesting, thanks for the brilliant idea Clark. I’ll try it on my machine later. I’ll also update the guide.

    Honestly, i didn’t know this command exists. What i previously did as a workaround is to create a simple script that adds the config at every start-up. I’ll adopt your method since it seems to be the best way to do it. Thanks.

  • Akshay

    But if you set it using ifconfig it does not reflect in Network preferences pane.Is there a way by which it can be setup in such a way that it reflects there??

Comments are closed.