How to set up NAT for Qemu with TAP backend? (Windows 10)
up vote
0
down vote
favorite
I want to use the TAP network backend instead of the default SLIRP that Qemu provides.
This is the batch file I use to create the VM (inspired by this):
@echo off
set "QEMUIMG=D:userVMsQemuqemuqemu-img.exe"
set "IMAGE=disk.img"
set "ISOFILE=D:userVMsisosisofile.iso"
set "QEMUBIN=D:userVMsQemuqemuqemu-system-x86_64.exe"
rem ==================================
rem Safety net
rem ==================================
if not exist %IMAGE% (
rem CREATE a virtual hard disk
%QEMUIMG% create -f qcow2 %IMAGE% 32G
) else (
echo file %IMAGE% already exist. Delete or move and try again.
goto:eof
)
rem ==================================
rem Run the virtual machine
rem ==================================>
start "QEMU" %QEMUBIN% -k us -usb -device usb-tablet -drive ^
file=%IMAGE%,index=0,media=disk,format=qcow2 -cdrom %ISOFILE% -m 2048M ^
-boot order=d -smp cpus=2 -rtc base=localtime,clock=host -parallel none ^
-serial none -name vm -no-acpi -no-hpet -no-reboot -show-cursor ^
-netdev tap,id=tap0,ifname=mytap,script=no,downscript=no -device netdev=tap0
Then:
- I download OpenVPN and install only the TAP-Win32 Virtual Ethernet Adapter.
- Now in Network Connections it appears a new interface: TAP-Windows Adapter V9 (which I rename to "mytap").
The next step is creating a bridge between the TAP adapter and the interface I use to connect to the Internet. But since I use Wi-Fi, it doesn't work, and bridging is less secure than NAT.
However, the instructions I've found to set up NAT are specific to OpenVPN or Hyper-V, and I don't know how to apply them to this case.
Any tips on how to proceed?
networking windows-10 nat qemu
add a comment |
up vote
0
down vote
favorite
I want to use the TAP network backend instead of the default SLIRP that Qemu provides.
This is the batch file I use to create the VM (inspired by this):
@echo off
set "QEMUIMG=D:userVMsQemuqemuqemu-img.exe"
set "IMAGE=disk.img"
set "ISOFILE=D:userVMsisosisofile.iso"
set "QEMUBIN=D:userVMsQemuqemuqemu-system-x86_64.exe"
rem ==================================
rem Safety net
rem ==================================
if not exist %IMAGE% (
rem CREATE a virtual hard disk
%QEMUIMG% create -f qcow2 %IMAGE% 32G
) else (
echo file %IMAGE% already exist. Delete or move and try again.
goto:eof
)
rem ==================================
rem Run the virtual machine
rem ==================================>
start "QEMU" %QEMUBIN% -k us -usb -device usb-tablet -drive ^
file=%IMAGE%,index=0,media=disk,format=qcow2 -cdrom %ISOFILE% -m 2048M ^
-boot order=d -smp cpus=2 -rtc base=localtime,clock=host -parallel none ^
-serial none -name vm -no-acpi -no-hpet -no-reboot -show-cursor ^
-netdev tap,id=tap0,ifname=mytap,script=no,downscript=no -device netdev=tap0
Then:
- I download OpenVPN and install only the TAP-Win32 Virtual Ethernet Adapter.
- Now in Network Connections it appears a new interface: TAP-Windows Adapter V9 (which I rename to "mytap").
The next step is creating a bridge between the TAP adapter and the interface I use to connect to the Internet. But since I use Wi-Fi, it doesn't work, and bridging is less secure than NAT.
However, the instructions I've found to set up NAT are specific to OpenVPN or Hyper-V, and I don't know how to apply them to this case.
Any tips on how to proceed?
networking windows-10 nat qemu
Ah... is this just the issue of MAC spoofing on the wireless network since you're not running WDS or similar? You could run Internet Connection Sharing (i.e. NAT) on the WiFi device rather than bridging to it, although that might defeat whatever it is you're trying to do with TAP.
– rakslice
Jul 21 at 12:18
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want to use the TAP network backend instead of the default SLIRP that Qemu provides.
This is the batch file I use to create the VM (inspired by this):
@echo off
set "QEMUIMG=D:userVMsQemuqemuqemu-img.exe"
set "IMAGE=disk.img"
set "ISOFILE=D:userVMsisosisofile.iso"
set "QEMUBIN=D:userVMsQemuqemuqemu-system-x86_64.exe"
rem ==================================
rem Safety net
rem ==================================
if not exist %IMAGE% (
rem CREATE a virtual hard disk
%QEMUIMG% create -f qcow2 %IMAGE% 32G
) else (
echo file %IMAGE% already exist. Delete or move and try again.
goto:eof
)
rem ==================================
rem Run the virtual machine
rem ==================================>
start "QEMU" %QEMUBIN% -k us -usb -device usb-tablet -drive ^
file=%IMAGE%,index=0,media=disk,format=qcow2 -cdrom %ISOFILE% -m 2048M ^
-boot order=d -smp cpus=2 -rtc base=localtime,clock=host -parallel none ^
-serial none -name vm -no-acpi -no-hpet -no-reboot -show-cursor ^
-netdev tap,id=tap0,ifname=mytap,script=no,downscript=no -device netdev=tap0
Then:
- I download OpenVPN and install only the TAP-Win32 Virtual Ethernet Adapter.
- Now in Network Connections it appears a new interface: TAP-Windows Adapter V9 (which I rename to "mytap").
The next step is creating a bridge between the TAP adapter and the interface I use to connect to the Internet. But since I use Wi-Fi, it doesn't work, and bridging is less secure than NAT.
However, the instructions I've found to set up NAT are specific to OpenVPN or Hyper-V, and I don't know how to apply them to this case.
Any tips on how to proceed?
networking windows-10 nat qemu
I want to use the TAP network backend instead of the default SLIRP that Qemu provides.
This is the batch file I use to create the VM (inspired by this):
@echo off
set "QEMUIMG=D:userVMsQemuqemuqemu-img.exe"
set "IMAGE=disk.img"
set "ISOFILE=D:userVMsisosisofile.iso"
set "QEMUBIN=D:userVMsQemuqemuqemu-system-x86_64.exe"
rem ==================================
rem Safety net
rem ==================================
if not exist %IMAGE% (
rem CREATE a virtual hard disk
%QEMUIMG% create -f qcow2 %IMAGE% 32G
) else (
echo file %IMAGE% already exist. Delete or move and try again.
goto:eof
)
rem ==================================
rem Run the virtual machine
rem ==================================>
start "QEMU" %QEMUBIN% -k us -usb -device usb-tablet -drive ^
file=%IMAGE%,index=0,media=disk,format=qcow2 -cdrom %ISOFILE% -m 2048M ^
-boot order=d -smp cpus=2 -rtc base=localtime,clock=host -parallel none ^
-serial none -name vm -no-acpi -no-hpet -no-reboot -show-cursor ^
-netdev tap,id=tap0,ifname=mytap,script=no,downscript=no -device netdev=tap0
Then:
- I download OpenVPN and install only the TAP-Win32 Virtual Ethernet Adapter.
- Now in Network Connections it appears a new interface: TAP-Windows Adapter V9 (which I rename to "mytap").
The next step is creating a bridge between the TAP adapter and the interface I use to connect to the Internet. But since I use Wi-Fi, it doesn't work, and bridging is less secure than NAT.
However, the instructions I've found to set up NAT are specific to OpenVPN or Hyper-V, and I don't know how to apply them to this case.
Any tips on how to proceed?
networking windows-10 nat qemu
networking windows-10 nat qemu
asked Apr 27 at 7:56
Clara Sánchez
13
13
Ah... is this just the issue of MAC spoofing on the wireless network since you're not running WDS or similar? You could run Internet Connection Sharing (i.e. NAT) on the WiFi device rather than bridging to it, although that might defeat whatever it is you're trying to do with TAP.
– rakslice
Jul 21 at 12:18
add a comment |
Ah... is this just the issue of MAC spoofing on the wireless network since you're not running WDS or similar? You could run Internet Connection Sharing (i.e. NAT) on the WiFi device rather than bridging to it, although that might defeat whatever it is you're trying to do with TAP.
– rakslice
Jul 21 at 12:18
Ah... is this just the issue of MAC spoofing on the wireless network since you're not running WDS or similar? You could run Internet Connection Sharing (i.e. NAT) on the WiFi device rather than bridging to it, although that might defeat whatever it is you're trying to do with TAP.
– rakslice
Jul 21 at 12:18
Ah... is this just the issue of MAC spoofing on the wireless network since you're not running WDS or similar? You could run Internet Connection Sharing (i.e. NAT) on the WiFi device rather than bridging to it, although that might defeat whatever it is you're trying to do with TAP.
– rakslice
Jul 21 at 12:18
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
Once you have the TAP software installed, and an instance of the TAP Adapter created, go to Network Connections and find its name there. You can rename it from there if you want.
For instance my TAP Adapter instance is called Ethernet
:
Use the name of the TAP Adapter in the ifname=
parameter of the -netdev tap
.
Set the id=
of the netdev
to whatever you like; typical examples use mynet0
. This is a name for the virtual network internal to the Qemu instance that connects some combination of the emulated network interfaces and TAP adapter connections.
Then you refer to this netdev
to connect it to a virtual NIC. The mechanics of doing this vary depending on what's being emulated.
For something like a PC, where you're specifying the NIC as a separate -device
option, you put the netdev=
in the device
option:
-netdev tap,id=mynet0,ifname=Ethernet -device e1000,netdev=mynet0
For a system that has a default network device that you can't specify in a -device
option, for instance the lance.0
in an SS-20
, adding an extra -net nic
section like this seems to be what's required:
-netdev tap,id=mynet0,ifname=Ethernet -net nic,model=lance,netdev=mynet0
When you launch Qemu you should note that the TAP Adapter loses its "network cable unplugged" indication.
Now you can go ahead and configure the TAP Adapter on the Windows side however you like, giving it local settings for host-only use, or bridging it to another network adapter if desired.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1317652%2fhow-to-set-up-nat-for-qemu-with-tap-backend-windows-10%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Once you have the TAP software installed, and an instance of the TAP Adapter created, go to Network Connections and find its name there. You can rename it from there if you want.
For instance my TAP Adapter instance is called Ethernet
:
Use the name of the TAP Adapter in the ifname=
parameter of the -netdev tap
.
Set the id=
of the netdev
to whatever you like; typical examples use mynet0
. This is a name for the virtual network internal to the Qemu instance that connects some combination of the emulated network interfaces and TAP adapter connections.
Then you refer to this netdev
to connect it to a virtual NIC. The mechanics of doing this vary depending on what's being emulated.
For something like a PC, where you're specifying the NIC as a separate -device
option, you put the netdev=
in the device
option:
-netdev tap,id=mynet0,ifname=Ethernet -device e1000,netdev=mynet0
For a system that has a default network device that you can't specify in a -device
option, for instance the lance.0
in an SS-20
, adding an extra -net nic
section like this seems to be what's required:
-netdev tap,id=mynet0,ifname=Ethernet -net nic,model=lance,netdev=mynet0
When you launch Qemu you should note that the TAP Adapter loses its "network cable unplugged" indication.
Now you can go ahead and configure the TAP Adapter on the Windows side however you like, giving it local settings for host-only use, or bridging it to another network adapter if desired.
add a comment |
up vote
1
down vote
Once you have the TAP software installed, and an instance of the TAP Adapter created, go to Network Connections and find its name there. You can rename it from there if you want.
For instance my TAP Adapter instance is called Ethernet
:
Use the name of the TAP Adapter in the ifname=
parameter of the -netdev tap
.
Set the id=
of the netdev
to whatever you like; typical examples use mynet0
. This is a name for the virtual network internal to the Qemu instance that connects some combination of the emulated network interfaces and TAP adapter connections.
Then you refer to this netdev
to connect it to a virtual NIC. The mechanics of doing this vary depending on what's being emulated.
For something like a PC, where you're specifying the NIC as a separate -device
option, you put the netdev=
in the device
option:
-netdev tap,id=mynet0,ifname=Ethernet -device e1000,netdev=mynet0
For a system that has a default network device that you can't specify in a -device
option, for instance the lance.0
in an SS-20
, adding an extra -net nic
section like this seems to be what's required:
-netdev tap,id=mynet0,ifname=Ethernet -net nic,model=lance,netdev=mynet0
When you launch Qemu you should note that the TAP Adapter loses its "network cable unplugged" indication.
Now you can go ahead and configure the TAP Adapter on the Windows side however you like, giving it local settings for host-only use, or bridging it to another network adapter if desired.
add a comment |
up vote
1
down vote
up vote
1
down vote
Once you have the TAP software installed, and an instance of the TAP Adapter created, go to Network Connections and find its name there. You can rename it from there if you want.
For instance my TAP Adapter instance is called Ethernet
:
Use the name of the TAP Adapter in the ifname=
parameter of the -netdev tap
.
Set the id=
of the netdev
to whatever you like; typical examples use mynet0
. This is a name for the virtual network internal to the Qemu instance that connects some combination of the emulated network interfaces and TAP adapter connections.
Then you refer to this netdev
to connect it to a virtual NIC. The mechanics of doing this vary depending on what's being emulated.
For something like a PC, where you're specifying the NIC as a separate -device
option, you put the netdev=
in the device
option:
-netdev tap,id=mynet0,ifname=Ethernet -device e1000,netdev=mynet0
For a system that has a default network device that you can't specify in a -device
option, for instance the lance.0
in an SS-20
, adding an extra -net nic
section like this seems to be what's required:
-netdev tap,id=mynet0,ifname=Ethernet -net nic,model=lance,netdev=mynet0
When you launch Qemu you should note that the TAP Adapter loses its "network cable unplugged" indication.
Now you can go ahead and configure the TAP Adapter on the Windows side however you like, giving it local settings for host-only use, or bridging it to another network adapter if desired.
Once you have the TAP software installed, and an instance of the TAP Adapter created, go to Network Connections and find its name there. You can rename it from there if you want.
For instance my TAP Adapter instance is called Ethernet
:
Use the name of the TAP Adapter in the ifname=
parameter of the -netdev tap
.
Set the id=
of the netdev
to whatever you like; typical examples use mynet0
. This is a name for the virtual network internal to the Qemu instance that connects some combination of the emulated network interfaces and TAP adapter connections.
Then you refer to this netdev
to connect it to a virtual NIC. The mechanics of doing this vary depending on what's being emulated.
For something like a PC, where you're specifying the NIC as a separate -device
option, you put the netdev=
in the device
option:
-netdev tap,id=mynet0,ifname=Ethernet -device e1000,netdev=mynet0
For a system that has a default network device that you can't specify in a -device
option, for instance the lance.0
in an SS-20
, adding an extra -net nic
section like this seems to be what's required:
-netdev tap,id=mynet0,ifname=Ethernet -net nic,model=lance,netdev=mynet0
When you launch Qemu you should note that the TAP Adapter loses its "network cable unplugged" indication.
Now you can go ahead and configure the TAP Adapter on the Windows side however you like, giving it local settings for host-only use, or bridging it to another network adapter if desired.
edited Dec 5 at 21:15
answered Jul 21 at 11:35
rakslice
2,01311324
2,01311324
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1317652%2fhow-to-set-up-nat-for-qemu-with-tap-backend-windows-10%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Ah... is this just the issue of MAC spoofing on the wireless network since you're not running WDS or similar? You could run Internet Connection Sharing (i.e. NAT) on the WiFi device rather than bridging to it, although that might defeat whatever it is you're trying to do with TAP.
– rakslice
Jul 21 at 12:18