7
7
Given: A computer running Linux (CentOS 5.x), one network card connected to LAN switch, a second one to cable modem via crossover cable. This computer acts as a router/firewall/traffic shaper for the local network.
Computer gets its public IP address from an ISP via DHCP. I know my ISP can supply 2 IP addresses to clients (when cable modem is connected directly to a hub, etc.). I would like to get 2 IP addresses on one computer that is connected to the ISP. It will simplify traffic segregation, NAT and shaping.
I know I can probably "fake" DHCP requests and bang together some scripts that will do this, but I wonder if somebody knows an easier and proper way.
Question: How can I make a Linux computer request two IP addresses via DHCP and assign both of them to one network card?
2re: DHCP reply is based on the MAC address - Actually it is BOOTP (the predecessor of DHCP) that is strictly based on the MAC. DHCP has a Client ID option field that is supposed to be used instead. If the Client ID is not present, then DHCP uses the MAC by itself. So, in theory one could craft DHCP requests with the same MAC but different Client ID to get 2 IP from the same DHCP server. -- I have not actually tried this, just reading the DHCP spec. – Jesse Chisholm – 2015-04-09T19:41:54.227
@JesseChisholm: yes, it work to use the Client id. I can get two IP address using DHCP for my eth0. Example for OpenWRT: # udhcpc -i eth0:1 -x 0x3d:0100BEEFC0FFEE (-x 0x3d:0100BEEFC0FFEE - option 61 (client id)) – Peter Senna – 2016-06-03T21:41:38.667
I can confirm that you can get two addresses, one with MAC address and one with Client ID. Too bad that is not what I wanted ... – Brenda J. Butler – 2019-07-25T01:37:58.570
Thanks for your answer. Nothing prevents me putting an interface into promiscuous mode and sending a DHCP request with "fake" MAC address. I'll get a reply back because interface is in promiscuous mode, and assign an IP it to a subinterface. But it is fragile and a lot of work, I was hoping for something more robust and simple and standard (subinterface with its own MAC? "Virtual" network card?) – haimg – 2011-10-09T21:31:24.013
1Yes, I hve added a possible solution to my original answer – Paul – 2011-10-10T23:56:13.167
Thanks! This is what I've looking for. Although it is not working on CentOS 5.5, it should work on CentOS 6.x (time to upgrade). – haimg – 2011-10-11T00:27:06.327