Home > How-To > Manually adding a temporary static IPv6 alias to an Ethernet interface

Manually adding a temporary static IPv6 alias to an Ethernet interface

Assume you want to assign a static IPv6 address 2100:xxxx:xxxx::2/48 to make your Mac an easily-reached server via IPv6. First, create the static IPv6 alias (substitute your own IPv6 prefix for xxxx:xxxx):
sudo ifconfig en0 inet6 2100:xxxx:xxxx::2/48
Then verify this worked:
ifconfig en0 | grep inet6
inet6 fe80::217:f2ff:fec6:62ec%en0 prefixlen 64 scopeid 0×4
inet6 2001:xxxx:xxxx::2 prefixlen 64 autoconf
Second, set the default gateway:
sudo route add -inet6 -prefixlen 0 default 2100:xxxx:xxxx::1
Note that if you have a link-local gateway to the IPv6 router to the global Internet, you don’t have to do this second step. To see if you do, type:
netstat -rn | grep default
default       10.10.10.1        UGSc       16       17    en1
default       fe80::200:ff:fe01:0%en1         UGSc        en1
If you’re dual-stacked, you’ll also see an IPv4 gateway.
Should you want to remove the IPv6 alias without rebooting, just type:
sudo ifconfig en1 inet6 -alias 2100:xxxx:xxxx::2
NOTE: As implied in the tip’s title, this method of IPv6 static assignment is temporary, only lasting until you reboot!
To make a permanent assignment, use the GUI interface Network panel in System Preferences. Alternatively, you can use the networksetup utility to create the alias and the gateway all at once, which will persist across boots:
sudo networksetup -setv6manual Ethernet 2001:xxxx:xxxx::2 48 2001:xxxx:xxxx::1
As far as I can tell, the only way to remove an alias created via networksetup is through the GUI.

Assume you want to assign a static IPv6 address 2100:xxxx:xxxx::2/48 to make your Mac an easily-reached server via IPv6. First, create the static IPv6 alias (substitute your own IPv6 prefix for xxxx:xxxx):

$ sudo ifconfig en0 inet6 2100:xxxx:xxxx::2/48

Then verify this worked:

$ ifconfig en0 | grep inet6
	inet6 fe80::217:f2ff:fec6:62ec%en0 prefixlen 64 scopeid 0x4
	inet6 2001:xxxx:xxxx::2 prefixlen 64 autoconf

Second, set the default gateway:

$ sudo route add -inet6 -prefixlen 0 default 2100:xxxx:xxxx::1

Note that if you have a link-local gateway to the IPv6 router to the global Internet, you don’t have to do this second step. To see if you do, type:

$ netstat -rn | grep default
default       10.10.10.1        UGSc       16       17    en1
default       fe80::200:ff:fe01:0%en1         UGSc        en1

If you’re dual-stacked, you’ll also see an IPv4 gateway.

Should you want to remove the IPv6 alias without rebooting, just type:

$ sudo ifconfig en1 inet6 -alias 2100:xxxx:xxxx::2

NOTE: As implied in the tip’s title, this method of IPv6 static assignment is temporary, only lasting until you reboot!

To make a permanent assignment, use the GUI interface Network panel in System Preferences. Alternatively, you can use the networksetup utility to create the alias and the gateway all at once, which will persist across boots:

$ sudo networksetup -setv6manual Ethernet 2001:xxxx:xxxx::2 48 2001:xxxx:xxxx::1

As far as I can tell, the only way to remove an alias created via networksetup is through the GUI.

Categories: How-To Tags:
  1. No comments yet.
  1. May 28th, 2013 at 11:44 | #1
  2. June 6th, 2013 at 16:28 | #2
  3. May 9th, 2014 at 10:53 | #3
You must be logged in to post a comment.