web-dev-qa-db-ja.com

QEMU Windowsゲスト、インターネットなし、共有フォルダーあり

Qemu/kvm仮想化スタックでWindows 7ゲストを実行しているDebianマシンをセットアップしています。 Windowsマシンは古いソフトウェアを実行しているので、インターネットにアクセスせずにVMに入れることにしました。ただし、VMにファイルを出し入れする必要があります。

ホストマシン以外のすべてのアクセスを禁止するために、ホストオンリーネットワークをセットアップし、ファイアウォールルールを変更することが可能だと聞きました。ただし、ホストには完全なインターネットアクセスが必要です。

Linuxでのファイアウォール設定の経験はありません。上記の目標をどのように達成できますか?

3
Kalsan

これはそれを行うはずです:

$ qemu-system-x86_64 -net nic -Net User,restrict=on,smb=/path/to/shared/folder ...

manpage から:

-netdev user,id=id[,option][,option][,...]
-Net User[,option][,option][,...]
    Use the user mode network stack which requires no administrator
    privilege to run. Valid options are:
    ...
    restrict=on|off
        If this option is enabled, the guest will be isolated, i.e. it
        will not be able to contact the Host and no guest IP packets
        will be routed over the Host to the outside. This option does
        not affect any explicitly set forwarding rules.
    ...              
    smb=dir[,smbserver=addr]
        When using the user mode network stack, activate a built-in SMB
        server so that Windows OSes can access to the Host files in dir
        transparently. The IP address of the SMB server can be set to
        addr. By default the 4th IP in the guest network is used, i.e.
        x.x.x.4.
        In the guest Windows OS, the line:
                10.0.2.4 smbserver
        must be added in the file C:\WINDOWS\LMHOSTS (for windows
        9x/Me) or C:\WINNT\SYSTEM32\DRIVERS\ETC\LMHOSTS (Windows
        NT/2000).
        Then dir can be accessed in \\smbserver\qemu.
        Note that a SAMBA server must be installed on the Host OS.
        QEMU was tested successfully with smbd versions from Red Hat 9,
        Fedora Core 3 and OpenSUSE 11.x.

これが機能するには、sambaがホストシステムにインストールされている必要があります。構成または実行する必要はなく、smbdバイナリのみが必要です。これは、アドホック構成で実行され、権限はありません。

Windows 7では、コンピューター->ネットワークロケーションの追加->カスタムネットワークロケーションの選択-> \\ 10.0.2.4\qemuから共有フォルダーに接続できます。

「インターネットへの接続」ウィザードを開くように要求されている場合は、単に閉じてください。 「ネットワークの場所の追加」ウィザードはまだ実行中であり、タスクバーアイコンをクリックすると、そのウィンドウを再び開くことができます。

3
mosvy

結局のところ、virt-managerを使用して隔離されたネットワークを作成し、samba(smbサーバー)を起動して、virbr1(隔離されたネットワーク)をリッスンするように構成できます。どうやら分離されたネットワークは外部との通信を禁止しますが、ホストに到達することを許可します。これはまさに私が探していたものです。

詳細な説明を編集:

0
Kalsan