2

Brief:

Is there an accepted way to request two IP addresses and reserve them for use by one machine?

I don't believe that I am allowed to get two IPs from a DHCP server with one interface and one MAC address (correct me if I am wrong).

If I choose a static IP, I can't stop the IP being allocated to someone else (correct me if I am wrong).

Details:

I would like multiple IP addresses. Is there some polite way I can request them without risking their being allocated to other people? I could forge a DHCP DORA handshake, but that doesn't seem like the right thing to do. Aside from the issue generating a MAC address, it doesn't seem like there should be a need to provide a MAC address; I only need the DHCP sever to NOT lease out an IP, it doesn't need to manage the IP and manage any associated MAC addresses. I'm happy to manage renewals, NACK and any other nuances.

I could randomly pick static IPs and potentially interfere with some other network user. Static virtual interfaces like this or this or this will work for the purposes of attaining multiple IPs, but DHCP won't be in control of issuing them. I cannot guarantee that they will be free.

I don't believe that virtual DHCP interfaces will work, as DHCP allocations require unique MAC addresses.

You may assume that I am on a work network. I am allowed to connect an arbitrary number of different devices to the network (and hence get any number of IPs allocated with the full consent of the company). However, I only require two, but I only have one network interface (a Raspberry Pi). I understand that I have phrased this as a general networking problem; I only seek to find a solution relevant to the latest Rasberry Pi build (buster).

1 Answer 1

3

create a file in /etc/network/interfaces.d - lets call it eth0 - doesn't matter what the name is.

In this file add the following

auto eth0
iface eth0 inet manual
  up ip link add link eth0 name eth01 address 02:00:00:00:00:01 type macvlan
  up ip link add link eth0 name eth02 address 02:00:00:00:00:02 type macvlan

Now restart networking

sudo systemctl restart networking

or just reboot

et voila

The value of the mac addresses can be virtually anything, as long as the first 'digit' is either a 2, 6, A or E.

You can name the interfaces anything you like too.

18
  • 1
    I type "systemctl restart networking" followed by ifconfig and can now see eth01 and eth02 listed in the interface list. After a short wait they now have IPs associated. Commented Feb 5, 2021 at 9:32
  • Oh, yeah, I forgot to mention you need to restart networking (or reboot) Commented Feb 5, 2021 at 9:46
  • Just tested and it also works for wlan0 (same steps but replace "eth" with "wlan"). Can you recommend a good textbook (or such) that I can gain an understanding about how this works? Commented Feb 5, 2021 at 9:52
  • 2
    MAC addresses with 2,6,A,E in the second position are reserved for such use - see Local MAC ranges at en.wikipedia.org/wiki/MAC_address#Universal_vs._local_(U/L_bit) Commented Feb 5, 2021 at 10:11
  • 1
    Textbooks?... we don't need no stinkin' textbooks
    – Seamus
    Commented Feb 5, 2021 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.