View previous topic :: View next topic |
Author |
Message |
WintermuteX n00b

Joined: 29 Apr 2006 Posts: 48 Location: Germany
|
Posted: Tue Aug 29, 2017 6:52 pm Post subject: [SOLVED] Two IPs and two MACs on one NIC |
|
|
Hello,
I searched on the net for an answer to this problem, but couldn't find one:
I have one NIC and I'm unable to add another one, but I need two different MACs on this NIC and two IPs, each one bound to the other MAC.
NIC1 -> MAC1 -> IP1
NIC1 -> MAC2 -> IP2
Both IPs are in the same subnet and should use the same router, I bound different services on each IP for various reasons.
Those settings must also be persistant to reboots.
If somebody could help me I would be very happy. 
Last edited by WintermuteX on Thu Aug 31, 2017 4:26 pm; edited 1 time in total |
|
Back to top |
|
 |
Zucca Veteran


Joined: 14 Jun 2007 Posts: 1873 Location: KUUSANKOSKI, Finland
|
Posted: Tue Aug 29, 2017 7:53 pm Post subject: |
|
|
Two ips per nic is possible, but I don't think two macs are possible unless you have two ports on your nic or if you use only one of the ips at the time (changing the mac dynamically upon each ethernet hotplug).
Either way. I'm also interested if this is possible. I might need that feature also in the future. _________________ ..: Zucca :..
Code: | ERROR: '--failure' is not an option. Aborting... |
|
|
Back to top |
|
 |
mike155 Advocate

Joined: 17 Sep 2010 Posts: 2568 Location: Frankfurt, Germany
|
Posted: Tue Aug 29, 2017 11:14 pm Post subject: |
|
|
You can achieve that using a bridge: create an internal bridge "br0", and connect it to NIC1. This will give you an interface "br0" with its own MAC address. You can assign IP1 to that interface. Now add a dummy or tap interface to the bridge. It will give you a second interface with its own MAC address. You can assign IP2 to it. You can add as many tap or dummy interfaces as you want, which will give you as many distinct MAC and IP addresses as you want. |
|
Back to top |
|
 |
jburns Veteran

Joined: 18 Jan 2007 Posts: 1102 Location: Massachusetts USA
|
|
Back to top |
|
 |
WintermuteX n00b

Joined: 29 Apr 2006 Posts: 48 Location: Germany
|
Posted: Wed Aug 30, 2017 5:36 am Post subject: |
|
|
I'm aware of that. However this doesn't answer my question.
bug_report wrote: | You can achieve that using a bridge: create an internal bridge "br0", and connect it to NIC1. This will give you an interface "br0" with its own MAC address. You can assign IP1 to that interface. Now add a dummy or tap interface to the bridge. It will give you a second interface with its own MAC address. You can assign IP2 to it. You can add as many tap or dummy interfaces as you want, which will give you as many distinct MAC and IP addresses as you want. |
This helped me looking in the right direction, but I solved it in another way at the end. Thanks for pointing me in the right direction. I simply used the wrong keywords at the searchengines and your answer helped me when I was looking deeper into your solution. I ended up with defining a MAC-VLAN.
My configuration in /etc/conf.d/net now looks something like that (for others looking for such a solution):
Code: | config_enp0s31f6="10.20.0.200/24"
routes_enp0s31f6="default via 10.20.0.1"
rc_net_macvlan0_need="net.enp0s31f6"
macvlan_macvlan0="enp0s31f6"
mode_macvlan0="private"
config_macvlan0="10.20.0.201/24"
mac_macvlan0="aa:bb:cc:dd:ee:f1" |
If you define more than one macvlan you might want to switch mode "private" to "bridge" if there is a lot of traffic between the macvlans, so they never leave the PHY only to be directed back by your switch.
In my use case this is not needed, therefor only one macvlan for now.
You need to compile MAC-VLAN support into the kernel for this to work (I hadn't it configured):
Code: | Device Drivers -> Network device support -> Network core driver support -> MAC-VLAN support |
Then simply start it like any other interface by linking the init script:
Code: | ln -s /etc/init.d/net.lo /etc/init.d/net.macvlan0 |
And add it to the default boot:
Code: | rc-update add net.macvlan0 default |
|
|
Back to top |
|
 |
SP2340 n00b


Joined: 01 Nov 2016 Posts: 50 Location: KeyStoneState
|
Posted: Thu Aug 31, 2017 12:48 pm Post subject: |
|
|
Glad to hear you found a way to make it work for you.
Please mark this thread as SOLVED. Thnx. _________________ --
Regards
Robert
Smile, it increases your face value. |
|
Back to top |
|
 |
WintermuteX n00b

Joined: 29 Apr 2006 Posts: 48 Location: Germany
|
Posted: Thu Aug 31, 2017 4:27 pm Post subject: |
|
|
SP2340 wrote: | Glad to hear you found a way to make it work for you.
Please mark this thread as SOLVED. Thnx. |
You are absolutely right, I forgot about it. Sorry.  |
|
Back to top |
|
 |
|