After a little bit of research, apparently you can't do that.
The sub-interface cannot request another IP address because it is using the same MAC address as the physical interface, and since DHCP requests are by MAC address, you can't get two IPs for the same interface.
An answer from SuperUser suggests the following two methods:
Method 1
Create a script that will do something like this (with a subinterface
defined on the primary):
- Primary interface issues DHCP and gets IP address,
- macchanger changes MAC address of interface,
- Sub interface issues DHCP and gets IP address,
- Revert mac address with macchanger.
- Kill the DHCP client so that it doesn't automatically run later.
Work out the lease time of the IP address you are given, and schedule
this script to run again before the lease expires.
Method 2
For this you will need iproute2
installed. The following command
adds a virtual interface bound to an existing eth0 interface:
ip link add link eth0 address 00:11:22:33:44:55 virtual0 type macvlan
Replace the mac and "virtual0" name of the interface to whatever you
like. Turn it on:
ip link set virtual0 up
Then configure using dhcpd or dhclient or ifconfig as needed. I have
tested this on Debian squeeze - your distro may not have everything
needed enabled in the kernel (macvlan particularly).
Source: SuperUser: Getting 2 IP addresses on one network card, using DHCP
Other sources: