LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Assigning dynamic IP addresses on aliases using macvlan? (https://www.linuxquestions.org/questions/linux-networking-3/assigning-dynamic-ip-addresses-on-aliases-using-macvlan-4175471268/)

magpiesally 07-28-2013 09:55 PM

Assigning dynamic IP addresses on aliases using macvlan?
 
This is new stuff for me, so I am learning and googling a lot.

My problem is, I want to be able to have interfaces named:

eth0:0

eth0:1

etc...

But I want them each to have a dynamic IP address. I know this works for static, and I know interface aliases can't use dynamic addresses because they share the same MAC address.

But I wondered if there is a way to trick the system using macvlan or some other way?

The reason I want to do this is because I have an application that looks for the ethernet interfaces eth0, eth0:1, eth0:2. I am trying to see if I can avoid using static IPs for these interfaces so there is no potential conflict with another system with the same IP. I have alternative solutions but I just want to know if I can hack this and make it work.

I tried to create macvlans, then ran dhclient on them so they each have their own IP, and then tried to rename them to the eth0:0, eth0:1 etc. But I'm really just hacking at this because I don't totally know what I'm doing yet.

Thanks for trying to help.

zhjim 07-29-2013 02:07 AM

Check this out
Not much of an explanation but seems complete.

magpiesally 07-29-2013 12:37 PM

Actually, turns out I just need to create virtual network interfaces, it doesn't matter if I use aliases.

So I ran the

sudo ip li add link eth0 mac1 address 56:61:33:7c:77:db type macvlan

sudo ip li add link eth0 mac2 address 56:61:33:44:44:db type macvlan

Then I ran dhclient on each mac1 and mac2 which assigned an IP address.


Do I need to do anything else? There is stuff going on with the route tables in that link but it is a little over my head.

What I am trying to do now is just setup two virtual ethernet interfaces that can be used separately.

Thanks for your time

zhjim 07-30-2013 01:24 AM

I have now clue why the routing gets setup on that link. I'd say as long as you can reach all the hosts behind those two nics you will be fine.

magpiesally 07-30-2013 01:35 AM

Yep it works as is. Macvlans solved my problem.

zhjim 07-30-2013 02:26 AM

Sounds good.

Please mark the thread as solved. See the "Thread Tools" at the top of the page.


All times are GMT -5. The time now is 08:20 AM.