Creating a virtual NIC that connects to the same network as physical NIC
Procedure:
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
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.
- Open Network Control Panel (
ncpa.cpl
) > Select Virtual Network Interface (withvEthernet
name) > Change it's IP and MAC address. IP can be in same subnet of real NIC and of same default gateway.
Further Reading:
- Microsoft Docs: Install Hyper-V on Windows 10
- Microsoft Docs: Create a virtual switch for Hyper-V virtual machines
- Hyper-V: What are the uses for different types of virtual networks?
- How-To Geek: How to change MAC address?
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:
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
Bring the interface up:
ifconfig eth0.1 up
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?)