I'm trying to write an application that can change the IP address of the local machine. When doing some experimentation, I've noticed that if I freshly connect to a wireless network, I am assigned an IPv6 address that is a function of the MAC address. Consider the following sequence of commands:
<disconnect wireless and reconnect>
$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:0c:29:7d:7c:42
inet addr:192.168.2.98 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe7d:7c42/64 Scope:Link
UP BROADCAST RUNNING MULTICAST...
$ sudo ip addr flush dev eth0
$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:0c:29:7d:7c:42
UP BROADCAST RUNNING MULTICAST...
$ sudo dhclient eth0
$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:0c:29:7d:7c:42
inet addr:192.168.2.98 Bcast:192.168.2.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST
Note that after flushing, I lose both the IPv4 and IPv6 addresses, but after renewing with dhclient
, I only reinitialize my IPv4 address. Why is this? What can I do to be reassigned my IPv6 address automatically?