Creating a virtual NIC that connects to the same network as physical NIC

8

5

How can I create a virtual interface, that connects to the same network as the physical interface? I tried searching around but all I found is loopback. I need the other end of the wire recognizes this as two interface, so loopback won't do it. Hypervisors like VMWare have an option to do exactly this (VM and host are recognized as two devices on router's arp table), but in my situation using a VM is pretty much overkill. I just want another connection, or maybe some apps that can behave as a "virtual switch".

I'm on Windows, and it should be like this.

Expected_Virtual_Network

Seems like I'm not the only one having this problem. Someone here and here have also asked but there's no acceptable answer. My apologize, but it is extremely hard to search for this problem.

tvc

Posted 2018-02-28T04:17:28.777

Reputation: 133

My OS is Windows 7. But I can move to windows 8.1 or 10 if needed. – tvc – 2018-02-28T04:32:49.750

?? https://technet.microsoft.com/en-us/library/bb740792.aspx

– Tony Stewart Sunnyskyguy EE75 – 2018-02-28T04:45:33.260

That kind of defeat the point since I'll need a hypervisor anyway. Or do I? – tvc – 2018-02-28T04:47:30.770

So apparently there are no separate app that can do this and I have to move everything to windows 10 but anyway, thank you. – tvc – 2018-02-28T05:10:18.357

The problem is a full-blown VM is overkill when all I need is just a virtual interface. – tvc – 2018-02-28T06:00:22.330

nvm. I got my job done using a spare linux box with a couple ip link adds. But if you can provide the procedure on Windows that's fine too, I'll mark it as answer since I'm originally asked for Windows. – tvc – 2018-03-01T09:21:00.337

Answers

9

Procedure:

  1. Enable Hyper-V feature in Windows from optionalfeatures.exe or with command prompt using the following command as administrator and restart PC.

    DISM.exe /Online /Enable-Feature /All /FeatureName:Microsoft-Hyper-V /NoRestart
    
  2. Open Hyper-V Manager from start menu or with run dialog box, type virtmgmt.msc. Go to Virtual Switch Manager > New Virtual Network Switch > Select External type > Create Virtual Switch > OK. It is important to select External type for that virtual network switch. See the article below for further details.

Hyper-V_External_Virtual_NIC

  1. Open Network Control Panel (ncpa.cpl) > Select Virtual Network Interface (with vEthernet name) > Change it's IP and MAC address. IP can be in same subnet of real NIC and of same default gateway.

Further Reading:

Biswapriyo

Posted 2018-02-28T04:17:28.777

Reputation: 6 640

Though this technically creates a virtual adapter, practically it is useless because it disables using the original physical adapter. All traffic is routed through the virtual adapter, and you are right back where you started. – cmenning – 2018-12-21T18:56:42.987

1@cmenning Yes you are right. But you can create two virtual interface under that same virtual switch -- one of which can be configured as same IP config of the physical one. – Biswapriyo – 2018-12-21T19:13:08.490

5

Procedure for Linux:

So originally I'm asked this to be done in Windows. But since the Windows-way will cost me another 2 hours I decided to do this on a linux box. Anyway here's how I did it, thanks to this answer. Hope this will solve someone's problem in the future. In short:

  1. Create a virtual link on your existing interface. You should get a Locally Administered Address (here) to pass in so it won't potentially mess things up (and also a recommended way to do):

    ip link add link eth0 address 56:8A:C0:DD:EE:FF eth0.1 type macvlan

  2. Bring the interface up:

    ifconfig eth0.1 up

  3. And acquire an address:

    dhclient -v eth0.1

Futher reading:

If you insist on a * real virtual * interface, there's a package named vde2 for the purpose of creating virtual switches on linux. Haven't tried that out, but maybe it can helps. It's annoying a little bit that such 'small' tool doesn't exist in Windows.

(Yes, I'm creating a link, not really an interface. But it did get my job done. I'm sorry if my question is misworded, you can edit it to clarify. But in the end of the day it shows up as an interface and traffic did goes thru that interface so probably it is solved?)

tvc

Posted 2018-02-28T04:17:28.777

Reputation: 133

What is macvlan? Does the virtual and real network interface both work simultaneously? Can I add more than one? Can disable the real one and enable only the virtual one? – Biswapriyo – 2018-03-02T09:23:33.707

3macvlan type link denotes a virtual interface based on link layer address (source). I needed another MAC address, not just another IP so macvlan is the appropriate virtual interface type. – tvc – 2018-03-02T10:09:39.610

1In my case, yea, it did work simultaneously. Never tried to add another one but i believe there can be several virtual interfaces inside one real interface. Because of that i also think disabling the real one will take down the rest virtual ones too. – tvc – 2018-03-02T10:13:42.577

0

netsh wlan set hostednetwork mode=allow ssid=randomwifiname key=12345678

netsh wlan start hostednetwork

Requires admin privileges, creates a virtual wireless network that has its own interface. You can enable internet sharing, DHCP automatically or static. By default its IP/subnet is completely separate from the usual 192.168.xxx.xxx local interfaces.

hello kitty tussins

Posted 2018-02-28T04:17:28.777

Reputation: 1