0

I am trying to get two external ip addresses(both ip assigned by DHCP) on single NIC. I added one macvlan device vir1 with its own mac address bounded to the primary NIC eth0. Set eth0 to promiscuous mode.

Both vir1 and eth0 get its own ip address, I intend to use both of the ip address at the same time.

When I ping from an external host to eth0 ip address, I can get a ping response, but when I ping to vir1 ip address, there isnt any reply. tcpdump shows that both vir1 and eth0 get the ping request when I ping to vir1

I want both ip address can be used by client to access my web service, the computer is connected to the internet directly with ethernet cable from isp

Any help would be appreciated!

/etc/network/interfaces

# Primary interface
auto eth0
iface eth0 inet dhcp
    up ip link set dev eth0 promisc on

# Macvlan interfaces
auto vir1
iface vir1 inet dhcp
    pre-up ip link add link eth0 address 02:cd:ab:00:10:01 vir1 type macvlan
    post-down ip link delete vir1

ifconfig result:

eth0      Link encap:Ethernet  HWaddr 8c:73:6e:b7:c7:10  
          inet addr:120.201.123.143  Bcast:120.201.123.255  Mask:255.255.252.0
          inet6 addr: fe80::8e73:6eff:feb7:c710/64 Scope:Link
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1

vir1      Link encap:Ethernet  HWaddr 02:cd:ab:00:10:01  
          inet addr:120.201.120.227  Bcast:120.201.123.255  Mask:255.255.252.0
          inet6 addr: fe80::cd:abff:fe00:1001/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  • Can you explain why you want this unusual route? Why not use the same MAC address for both? This seems unnecessarily complex and, among other downsides, forces promiscuous mode. – David Schwartz Jul 26 '17 at 16:48
  • @DavidSchwartz Since DHCP assign ip address by mac address and I only have one NIC, I need to create a virtual one under the primary NIC in order to get two ip address from ISP and this required promoscuous mode – Isolet Chan Jul 27 '17 at 13:00
0

If you add a second IP to a virtual VLAN interface, the NIC will tag frames destined for that VLAN (802.1Q). If the VLAN isn't set up on the switch it'll just get dropped.

If you want to use the same segment you need to add the IP to the NIC directly:

auto eth0:1
iface eth0:1 inet static
address 120.201.120.227
gateway 120.201.120.001          <= insert correct gw address
netmask 255.255.252.0

DHCP with two IP addresses won't work, not even with Linux.

  • Don't forget to mark your question as answered if it is. – Zac67 Jul 27 '17 at 16:46
  • Sure! I will test this soon and come back to mark it. Sorry currently busy with my school project – Isolet Chan Jul 28 '17 at 3:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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