How to create bridge on physical network adapter

Questions about virtualization software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Post Reply
AhtunG
Level 1
Level 1
Posts: 2
Joined: Tue Mar 19, 2024 6:22 am

How to create bridge on physical network adapter

Post by AhtunG »

Hello guys, need some help with network adapter on Kali Linux or any Unix like environments
I need to bridge physical interface of the network card so that on a virtual machine I can see the Wi-Fi networks available nearby, not just be able to add a “wireless network”, but use my network card in the same way as on the host machine . Perhaps someone knows solutions other way than set bridges, I would be grateful.
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: How to create bridge on physical network adapter

Post by powerhouse »

Wifi uses network layer 3 protocols (routing), whereas a bridge is a layer 2 (Ethernet) construct. Normally you can't have a L2 connection over a L3 connection. There are ways to tunnel L2 connections over L3, but it's complicated and I myself gave up.

If your Linux host uses a wireless network adapter to connect to the Wifi hotspot or router, you can use a simple NAT configuration in your VM to connect to the Wifi hotspot. However, if you need bridging, have a look at the following post as a starting point: https://serverfault.com/questions/27302 ... -over-wifi.

Another way is to pass through the network card to the VM using PCI passthrough. This way your VM will see the wireless network adapter as a hardware device. The VM will use its own driver to access that network adapter, and you will be able to see all the wireless networks from within the VM.

Bear in mind that when passing through a network adapter as a PCI device, your host will no longer have access to that device! In addition, to pass through any device, that device must reside in its own IOMMU group (with the exception of some host PCI bridges). See my post on IOMMU here: https://www.heiko-sieger.info/iommu-gro ... -consider/

Setting up a network bridge in any Linux distribution is easy. I use Network Manager for that, here is my tutorial: https://www.heiko-sieger.info/define-a- ... plication/. But my PCs are connected via a wired network to a router that serves as my gateway to the Internet and also provides the IP addresses via DHCP.

In short: If you want your network card to have the same functionality as on the host, you can PCI passthrough it to the VM. Perhaps that is overkill or not practical (IOMMU groups no good). But worth a thought.

EDIT: Before you change any network settings, back up your current configuration. In my case using Network Manager, the settings are under

Code: Select all

/etc/NetworkManager/system-connections/
.
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
AhtunG
Level 1
Level 1
Posts: 2
Joined: Tue Mar 19, 2024 6:22 am

Re: How to create bridge on physical network adapter

Post by AhtunG »

I forgot to say that when I will check an ifconfig, my connection must be visible as wlan0-…, not like eth or ens. So, NAT isn’t the possible way to do this
As u said I need to PCI pass through my network card, but I rly can’t find on any forums how to do that, even on DarkNet
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: How to create bridge on physical network adapter

Post by powerhouse »

AhtunG wrote: Wed Mar 20, 2024 6:48 am I forgot to say that when I will check an ifconfig, my connection must be visible as wlan0-…, not like eth or ens. So, NAT isn’t the possible way to do this
As u said I need to PCI pass through my network card, but I rly can’t find on any forums how to do that, even on DarkNet
You definitely don't need Darknet. Anyway, let's start with what you have. Please let us know which method you used to create the VM? Did you use Virtual Machine Manager with kvm/QEMU or VirtualBox? Or another virtualization method?

What is your hardware?
Which operating system do you run on the host?
Which operating system runs in the VM?

What I suggested works with kvm/QEMU. The easiest tool for that is Virtual Machine Manager (virt-manager), but before you install anything, let's have the facts.
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
Post Reply

Return to “Virtual Machines”