The ability to use your wireless adapter with Virtualbox bridge mode is a problem that at least a few geeks on the web are asking, yet no one seems to have a convincing answer as to how to configure it.
The solution is in fact fairly simple, and also quite obvious too, once you understand the problem. However I’m still going to make you read an entire article to get the solution. Don’t worry, you will actually get some good insight into the troubleshooting process by reading it, so your time is well spent be reading the whole article
So the background is I’ve been setting up a penetration testing lab using Virtualbox. One of the virtual machines I have created is the firewall/router pfsense. In order for this to be able to connect other devices to the outside world, it needs to connect to my internet router.
Since I don’t have a wired connection to the router, nor do I want to be stuck in the same room as the router, I needed to be able to connect a bridged connection via my wifi.
However, when I tried this, I couldn’t get connectivity to happen. At first I was stumped by this. What was going on, And how could I fix it? First step, as always, a Google search. Unfortunately this didn’t work. As usually, clueless script kiddies on forums with no real idea but an inflated sense of self worth. No luck there.
OK, so where to next? Well why not find out if the bridged adapter was in fact sending out DHCP requests? Time to download an app called Wireshark. What this does for those don’t know is it capture every single network packet sent by your computer. Packet capture tools are invaluable when it comes to troubleshooting network problems. It allows you to check who is do what. Which device is sending, which is receiving, which is responding.
I implement a packet capture using wireshark and I find out that sure enough pfsense is sending out DHCP requests. Problem is, the internet router isn’t responding. Why is that I wonder? Well the obvious answer is that you need a password to connect to my wifi.
So the next question is, how can I get the bridged network to send the password to the internet router? Well I never did find a way. However, I did find a workaround. It helps to have a very indepth understanding of network architecture at times.
The bridged network adapter has its own MAC address (the hardware address of the card), although physically the bridged adapter is on the same card. The thing about network adapters is that they are not limited to a single IP address.
Also, a thing I wasn’t aware of is that the wifi authentication is in fact tied to the MAC address of the network card.
So once I figured this out, the solution at the outset I said it was fairly simple. Set the bridge network address to the mac address of the wireless adapter, then assign the Pfsense interface an ip address. And hey presto.. it works. Not a bad little bit of troubleshooting if I do say so myself.
For those who are newbies to IT, this image may help. This is the result of the ifconfig command in linux. The MAC address is highlighted. The same command can be used in Windows, although it is called ipconfig, and to see the MAC address, you have to use the command ipconfig /all.
As I have said, you take the highlighted address and put in in the virtual machine settings. Which are found under settings, which you can see in the next image. It’s a simple cut and paste, and you’re done.
admin
Latest posts by admin (see all)
- Password Security (Part 2) - November 18, 2021
- Online Store Case Study: Resin Workshops - November 17, 2021
- Blank Editor In WordPress Fix - November 17, 2021
Very Nice work around. Thanks for sharing
No worries. Glad it worked for you.
You just need to change the “connect to” to NAT, and that is. However, thanks for your contribution.
Well clearly you’re so clever that you didn’t even need to read this article, so I’m wondering why you looked for it in the first place. Are you one of those condescending geeks who thinks they’re so much smarter than everyone else and wants to show everyone how clever you are? In fact I mentioned you in the article – script kiddies with no idea and an inflated sense of self worth.
This was a solution that was worked out when bridge mode wasn’t connecting for me. Clearly NAT was not applicable in this case. For whatever reason I can’t remember. Most likely because I wanted the virtual machine to be able to connect to both the host machine, other virtual machines AND the Internet. Try that with NAT and see how you go.
Hey man, ran through the same issue with Windows 10 host and Ubuntu Server as guest. I want the VM to have its own IP so I could learn how to configure and use an FTP server and deploy my website too.
All I can say is you are the man! Jonathan Sarabia… you are not….
Thanks Ben. Glad it helped you out.
Omg you solved in 5 minutes something i’ve been trying to solve during hours… Your are my god.
But now, I’m connected, I have my own IP, but my internet is not working. Do you know what could be happening?
I’d have to have more details on your situation to be able to troubleshoot it. I’m assuming that you have an internet connection on your host machine that is working? First thing I would check is that you can ping the router.
bro can you help me when i use my kali linux on virtual box on NAT the connection is fine but when i change NAT to Bridge adapter the kali lost the connections plzz help.
It’s hard to say without more details. I can definitely help if I have the details. Have you done as the article suggests and used wireshark? Wireshark is brilliant. It really shows everything you need to know about traffic.
bro when i start my kali linux in virtual box with NAT options in networking then the internet connection is available but when i change NAT to bridge adapter it doesn’t have internet connections means when we open firefox in kali nothing is opening and after 2 min its showing check your internet connections and stuff.
OK, I assume you know how to network troubleshoot. You’re going to need to start from the beginning with ifconfig, to make sure you actually have an ip address. Next you need to be able to ping your router. When I had the problem I describe in the article, it became pretty apparent as I went through the troubleshooting steps where the problem lay. I didn’t have an IP address, and the reason I didn’t have an IP address is because when the network stack did a DHCP request, it was getting rejected by the router (which was acting as the DHCP server). If you are using Kali, you should be fairly knowledgeable about networking. If not, you shouldn’t be using Kali, because you haven’t got the requisite foundation needed to be a pen-tester. Use those skills to troubleshoot and see this as a pen testing exercise. If, after you have done all troubleshooting and still got nothing, let me know and perhaps I could help on teamviewer or something like that.
Dude you are a genius!
Ok, good news – my Ubuntu guest VM has replicated its host’s IP address. The bad news, the Ubuntu guest VM is unable to reach out. If I ping 8.8.8.8 or anything even 192.168.1.1 (DG).. I get no response back from the prompt. Its just hung.
Any ideas?
Ok, update for you.
I put a packet capture as you said as well. I’m seeing my Ubuntu guest VM send out a request to the DG (192.168.1.1) but it doesnt ACK the ping with a reply. In Wireshark, I just see request, request, request being sent out.
I did double check to make sure the right MAC is being used — Yes it is.
Sorry dude still unable to reach out.
OK.. Send me your ifconfig from your VM, as well as the from the host and I’ll see what I can see.
Hey thanks man.
You know what I’m kinda in a time crunch to get this demo going for a client .. I did get it to work eventually but not this method you outlined! On the physical host, I added a 2nd ethernet line (line 1- WIFI and now line 2- real eth 1Gig line copper) and then bridge host mapped this to the Ubuntu guests. Worked like a charm on both machines! Benchmark around 866 Mbps.
I should probably mention, host #1 is a mac book running Catalina and VirtualBox 6.x and the other host (#2) is a windows 10 pro machine .. with VirtualBox likely 6.x. Anyway long story short, the demo is good now and I’m OK to proceed.
Thanks again and I’m really not sure why your method didnt work. I may revisit this issue later when I have free cycles.
-H
Hey that’s cool. As long as you got a solution. It’s the way it is with IT. If one method doesn’t work, try another.
Changing to NAT and replacing the MAC worked for me….
Just changing the MAC did not allow me to connect to the internet.
I also got a same IP as my laptop for the VM…
You have to set up a different MAC adddress than the laptop. DHCP assigns IP addresses on the basis of MAC addresses. It won’t assign the same IP address to two different MAC addresses.
I ran into the same problem. However it was a bit different.
I set up my VBox with Bridged Network, at first everything worked.
My VB runs on a different MAC (than my Wifi MAC) – it then got a different IP address, which I could ping to and from my host.
After a few days, or a few restarts, it stopped working.
I tried replacing the VB MAC with the actual MAC from my host and it did work, however, now both my guest and host have the same IP address, and that’s not ideal.
How can I fix this and get them to have different IP addresses, and still work on Wifi, bridged?
You will have the same IP address because the DHCP server associates IP addresses with MAC addresses. You will need to define a static IP address for the virtual host.
For me It does not work 🙁 My network device on the guest system is DOWN and ifup eth0 doesn’t work, any idea why ??
In Network Settings in Virtualbox, go to Advanced on the adapter you’re using, and make sure cable connected is ticked.
Thanks – this was bothering me and now I’m less bothered
Thank you very much. This worked for me. I’ve been stuck on Ethernet port based bridged connections for ages, and needed the flexibility to do this from WiFi.
Very well analysed and explained.
For other users that encounter this problem, don’t forgot you need to give your VM client (inside the client OS) a static IP address for this to work. If you don’t, you’ll be stuck on the same IP as the host WiFi adaptor and nothing will get through to the VM.
Thx a lot!