From owner-freebsd-virtualization@freebsd.org Mon Feb 13 13:02:53 2017 Return-Path: Delivered-To: freebsd-virtualization@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9B4CFCDB6A1 for ; Mon, 13 Feb 2017 13:02:53 +0000 (UTC) (envelope-from contact@dann.ro) Received: from mail-lf0-x242.google.com (mail-lf0-x242.google.com [IPv6:2a00:1450:4010:c07::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 20992130F for ; Mon, 13 Feb 2017 13:02:53 +0000 (UTC) (envelope-from contact@dann.ro) Received: by mail-lf0-x242.google.com with SMTP id q89so8432117lfi.1 for ; Mon, 13 Feb 2017 05:02:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dann-ro.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=QHWITyVJmPEO/ia4Fz3h2RZD1s/E+JJDB3mhsIp0Lyk=; b=MjIp6GIoDC+9OKaM4hHlSuF+I+bWsEJAYyHU3bYxCwui9T1Bl/tT077L5HtwxkScms 65r5hNegfg8uSRf/g4ROS5WeTHZISIWTnab/4SnGz5z6IQzHUsjE1IAkmnlZdZ4WhDWa wLN4ZvNPgBXTL362pkMMDnYNeU5naHu0YzyFZzB6XgfYRWUaiKHK0kpNdsK1oQ1HnHwv p/P0JFidLonXl93PFVFZbyWTZnmAnRaisqJydWxda8+38yx5eM3SO+7fuSl6zVS3jcgK WsOj+4Y18AydavmH7PMuTOLsTLUrznlsCupzoYYBYOc0c7h5WnHLv9wRX5TOdIhTGyUI 2bBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=QHWITyVJmPEO/ia4Fz3h2RZD1s/E+JJDB3mhsIp0Lyk=; b=jYrZdQ1fl4+AaXy9+hfmJi1gVVji4mbvKgGTG3GyYuLbcqnsptPuws+KIcmGcEtnes jY5l9L0zbeUU1YRCAnaWOI5z1Ne99PCQyIup21r8FWmuCs5oErs+bxLQNbbf0iMw2/6J 1i8lAFi1JATJstLvBQaz3Fp71IRbguZX5hmrrUN0GE4+T3OwQ1AZyHUE1yAXXyAeZJSn 1B9510qfgQSZ7LHy5qWxsOhCSDA0onCONktj9FuC7PvokW1hmsVftF5uBPDYPIxoJkAZ BPwkObiJJZ1JcltKvgXTfNvOpmHF6y5tdq7hZWeZdeJyWZ0Z3Jn16QULFjQN+g0GMbnB iI5A== X-Gm-Message-State: AMke39kPpwat4incKsP73G896aKpRde+nqQi4P2S25+NU1RWA7W0SK1wVps8yYVHM3hDkg== X-Received: by 10.25.74.72 with SMTP id x69mr6233738lfa.66.1486990970884; Mon, 13 Feb 2017 05:02:50 -0800 (PST) Received: from [10.10.33.132] (mail.polystar.se. [213.238.208.200]) by smtp.gmail.com with ESMTPSA id g85sm2731061lji.21.2017.02.13.05.02.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Feb 2017 05:02:49 -0800 (PST) Subject: Re: tap interfaces disappears after bhyve guests shutdowns To: Miroslav Lachman <000.fbsd@quip.cz>, "C. L. Martinez" , freebsd-virtualization@freebsd.org References: <20170213120938.hr3zu7flnm33v3zn@scotland.uxdom.org> <58A1A8A3.3030603@quip.cz> From: Daniel Niculescu Message-ID: <8700dd14-cf15-20b9-38a6-e4181e4928ee@dann.ro> Date: Mon, 13 Feb 2017 14:02:48 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <58A1A8A3.3030603@quip.cz> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Feb 2017 13:02:53 -0000 On 02/13/17 13:37, Miroslav Lachman wrote: > C. L. Martinez wrote on 2017/02/13 13:09: > >> Why when a bhyve guest shutdowns or reboot tap interfaces goes down >> and lost IP assigned address?. I need to use same tap interface for >> several guests and assign an IP to this tap interface to act as a >> router for these guests. >> IP address is set on the guest, so as long as you have the network set up the IP address will be persistent. What you need is a bridge to which you add all your tap interfaces. Set the kernel state as advised by Martinez and make sure you have it also in /etc/sysctl.conf: #sysctl net.link.tap.up_on_open=1 #echo "net.link.tap.up_on_open=1" >> /etc/sysctl.conf Create a bridge interface: #ifconfig bridge0 create Add your host interface if you want external connectivity for your guests: #ifconfig bridge0 addm em0 Create the tap interfaces for the guests: #ifconfig tap0 create #ifconfig tap1 create Add them to the bridge: #ifconfig bridge0 addm tap0 addm tap1 After booting the guests, they will be both bridged with your physical interface em0 (replace em0 with your actual interface): #ifconfig bridge0 bridge0: flags=8843 metric 0 mtu 1500 description: vm-local ether 02:ed:0d:ca:74:00 nd6 options=1 groups: bridge id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15 maxage 20 holdcnt 6 proto rstp maxaddr 2000 timeout 1200 root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0 member: tap1 flags=143 ifmaxaddr 0 port 5 priority 128 path cost 2000000 member: tap0 flags=143 ifmaxaddr 0 port 4 priority 128 path cost 2000000 member: em0 flags=143 ifmaxaddr 0 port 1 priority 128 path cost 20000 Perhaps you could use an utility to manage the VMs, like vm-bhyve, iohyve, etc. >> How can I do a "persistent tap" interface?? > > I think you need this sysctl: > > # sysctl -d net.link.tap.up_on_open > net.link.tap.up_on_open: Bring interface up when /dev/tap is opened > _______________________________________________ > freebsd-virtualization@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization > To unsubscribe, send any mail to > "freebsd-virtualization-unsubscribe@freebsd.org"