From owner-freebsd-emulation@FreeBSD.ORG Mon Aug 1 16:11:13 2005 Return-Path: X-Original-To: freebsd-emulation@freebsd.org Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4007816A41F for ; Mon, 1 Aug 2005 16:11:13 +0000 (GMT) (envelope-from bakul@bitblocks.com) Received: from gate.bitblocks.com (bitblocks.com [209.204.185.216]) by mx1.FreeBSD.org (Postfix) with ESMTP id EDD1043D4C for ; Mon, 1 Aug 2005 16:11:12 +0000 (GMT) (envelope-from bakul@bitblocks.com) Received: from bitblocks.com (localhost [127.0.0.1]) by gate.bitblocks.com (8.13.4/8.13.1) with ESMTP id j71GBBmr073203; Mon, 1 Aug 2005 09:11:12 -0700 (PDT) (envelope-from bakul@bitblocks.com) Message-Id: <200508011611.j71GBBmr073203@gate.bitblocks.com> To: "Andrey V. Elsukov" In-reply-to: Your message of "Mon, 01 Aug 2005 08:19:54 +0400." <42EDA2EA.4060206@yandex.ru> Date: Mon, 01 Aug 2005 09:11:11 -0700 From: Bakul Shah Cc: freebsd-emulation@freebsd.org Subject: Re: Howto configure virtual network via tap in qemu? X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Aug 2005 16:11:13 -0000 > Somebody know how to configure virtual network via tap interface in qemu? > I try to install FreeBSD 6.0-BETA1 in qemu. My system is 5.4-STABLE. I > try so: > 1. cat /dev/null > /dev/tap0 You don't need this. > 4. run qemu: > # qemu -cdrom 6.0-BETA1.iso -hda disk.img -boot d -serial pty -n /home/qemu/ifup.sh You don't need -serial > tap0 interface is up, i can ping it from my system. But i can't > configure installation via network. > When i use user mode network stack - it work. In the user mode networking qemu does stuff on behalf of the VM (the emulated system). This requires a lot less setup on your host (since it is qemu that does all networking). If you use tapN, the VM is an *external system* as far as your host's networking stack is concerned as it will send/rcv packets over a network interface. This is why you need to either bridge tapN with your external ethernet interface and give your VM an externally visible address or use your host as a router and set it up to do network address translation. For the latter do the following: - make sure IP forwarding works sysctl net.inet.ip.forwarding = 1 - set up NAT. Let us assume your external interface is fxp0. Then if you use ipfilter, /etc/ipnat.rules will look something like this: map fxp0 192.168.0.0/24 -> 0/32 portmap tcp/ucp 30000:39999 map fxp0 192.168.0.0/24 -> 0/32 if you use pf, /etc/pf.conf will look something like this: nat on fxp0 from 192.168.0.0/24 to any -> (fxp0) Don't forget to enable whichever NAT in /etc/rc.conf - During the installation give your VM an IP address like 192.168.0.2, chose 192.168.0.1 as your gateway and the DNS entries same as your host.