Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #172095 > unrolled thread

Defining TAP interfaces in /etc/network/interfaces

Started byAndrew Wood <andrewjameswood@ymail.com>
First post2016-09-12 22:20 +0200
Last post2016-09-16 21:50 +0200
Articles 5 — 4 participants

Back to article view | Back to linux.debian.user


Contents

  Defining TAP interfaces in /etc/network/interfaces Andrew Wood <andrewjameswood@ymail.com> - 2016-09-12 22:20 +0200
    Re: Defining TAP interfaces in /etc/network/interfaces Nemeth Gyorgy <friczy@freemail.hu> - 2016-09-12 22:40 +0200
    Re: Defining TAP interfaces in /etc/network/interfaces Charlie Kravetz <cjk@teamcharliesangels.com> - 2016-09-12 23:40 +0200
    Re: Defining TAP interfaces in /etc/network/interfaces "Neal P. Murphy" <neal.p.murphy@alum.wpi.edu> - 2016-09-13 00:30 +0200
      Re: Defining TAP interfaces in /etc/network/interfaces Andrew Wood <andrewjameswood@ymail.com> - 2016-09-16 21:50 +0200

#172095 — Defining TAP interfaces in /etc/network/interfaces

FromAndrew Wood <andrewjameswood@ymail.com>
Date2016-09-12 22:20 +0200
SubjectDefining TAP interfaces in /etc/network/interfaces
Message-ID<sgFRU-8ja-23@gated-at.bofh.it>
Im (slowly) trying to setup bridging and TAP interfaces to use with QEMU 
so each VM can have a 'real' IP on the network rather than NAT.


I now have a bridge setup (br1) using eth1 which Ive done in 
/etc/network/interfaces with:

auto eth1
auto br1
iface br1 inet dhcp
         bridge_ports eth1
         bridge_stp off
         bridge_fd 0
         bridge_maxwait 0


However I cannot work out how to add TAP interfaces to this bridge using 
that file. Currently I have to do it with the tunctl & brctl commands in 
a separate script.


It is possible to do it in /etc/network/interfaces ?

Thanks
Andrew

[toc] | [next] | [standalone]


#172097

FromNemeth Gyorgy <friczy@freemail.hu>
Date2016-09-12 22:40 +0200
Message-ID<sgGbg-8rR-21@gated-at.bofh.it>
In reply to#172095
2016-09-12 22:14 keltezéssel, Andrew Wood írta:
> Im (slowly) trying to setup bridging and TAP interfaces to use with 
> QEMU so each VM can have a 'real' IP on the network rather than NAT.
>
>
> I now have a bridge setup (br1) using eth1 which Ive done in 
> /etc/network/interfaces with:
>
> auto eth1
> auto br1
> iface br1 inet dhcp
>         bridge_ports eth1
>         bridge_stp off
>         bridge_fd 0
>         bridge_maxwait 0
>
>
> However I cannot work out how to add TAP interfaces to this bridge 
> using that file. Currently I have to do it with the tunctl & brctl 
> commands in a separate script.
>
>
> It is possible to do it in /etc/network/interfaces ?
>
> Thanks
> Andrew
>
>
An example:

http://www.shakthimaan.com/installs/debian-tun-tap-setup.html

[toc] | [prev] | [next] | [standalone]


#172098

FromCharlie Kravetz <cjk@teamcharliesangels.com>
Date2016-09-12 23:40 +0200
Message-ID<sgH7j-FR-29@gated-at.bofh.it>
In reply to#172095
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On Mon, 12 Sep 2016 21:14:15 +0100
Andrew Wood <andrewjameswood@ymail.com> wrote:

>Im (slowly) trying to setup bridging and TAP interfaces to use with QEMU 
>so each VM can have a 'real' IP on the network rather than NAT.
>
>
>I now have a bridge setup (br1) using eth1 which Ive done in 
>/etc/network/interfaces with:
>
>auto eth1
>auto br1
>iface br1 inet dhcp
>         bridge_ports eth1
>         bridge_stp off
>         bridge_fd 0
>         bridge_maxwait 0
>
>
>However I cannot work out how to add TAP interfaces to this bridge using 
>that file. Currently I have to do it with the tunctl & brctl commands in 
>a separate script.
>
>
>It is possible to do it in /etc/network/interfaces ?
>
>Thanks
>Andrew
>

Change the bridge_ports to:
	bridge_ports eth1 tap0

then add the tap lines:
        auto tap0
             iface tap0 inet static
             address 192.168.??.?
             netmask 255.255.255.0
             tunctl_user vboxusers

Change these as needed for your own setup. This works for me using
virtual box.

- -- 
Charlie Kravetz
Linux Registered User Number 425914
[http://linuxcounter.net/user/425914.html]
Never let anyone steal your DREAM.   [http://keepingdreams.com]
-----BEGIN PGP SIGNATURE-----

iQEcBAEBCAAGBQJX1xNUAAoJEIqui46mydCAgsIH/1fsOHvnc+Aj7aRLxqwyiclg
abcpmpKKWm3/hkottLNBa1BrKpTUzfeqD/Am8xt8/uPdwkhP8czTiOWDNGq78FD5
hlNPIakTp0jp4UQJ7TZXybUt+toUDP0bZWcMBD7tI0VMKuXjvUNsxIcA3P+LI+Q5
cD0Drq2RC+SZK6oXowkb23M9PKnzgaJJH2TzNoFYFQX4MMSqAyCCCbtd0LYCihaw
WO7k8k6/q7XIw99ruH4ApB0jfm5X8jDfm8LVqo5EUhv76+9BaTUh3JebefP3iRQC
Km21mgLAZH0oFmKoajkm4RP8LoRy2Xn3SbRA0ztMWRxAfiedtr+WnAGSQH/T1xA=
=zffI
-----END PGP SIGNATURE-----

[toc] | [prev] | [next] | [standalone]


#172099

From"Neal P. Murphy" <neal.p.murphy@alum.wpi.edu>
Date2016-09-13 00:30 +0200
Message-ID<sgHTH-1ge-3@gated-at.bofh.it>
In reply to#172095
On Mon, 12 Sep 2016 21:14:15 +0100
Andrew Wood <andrewjameswood@ymail.com> wrote:

> Im (slowly) trying to setup bridging and TAP interfaces to use with QEMU 
> so each VM can have a 'real' IP on the network rather than NAT.
> 
> 
> I now have a bridge setup (br1) using eth1 which Ive done in 
> /etc/network/interfaces with:
> 
> auto eth1
> auto br1
> iface br1 inet dhcp
>          bridge_ports eth1
>          bridge_stp off
>          bridge_fd 0
>          bridge_maxwait 0
> 
> 
> However I cannot work out how to add TAP interfaces to this bridge using 
> that file. Currently I have to do it with the tunctl & brctl commands in 
> a separate script.
> 
> 
> It is possible to do it in /etc/network/interfaces ?
> 
> Thanks
> Andrew
> 

You might find something in here useful. How I did it with my 500-line script, kvm-go.:

-----auto GREEN
allow-hotplug GREEN
iface GREEN inet manual
  bridge_ports eth1 regex tapGN.*
  bridge_maxwait 0
  post-up brctl setfd GREEN 0-----

The salient part is 'regex tapGN.*', etc.

(I actually use four bridges--GREEN/ORANGE/PURPLE/RED--because I build and test the Smoothwall Express firewall. One of them has no connection to the outside world (no slave NIC). In my case, taps for each bridge have unique and identifiable names (my script does this automatically). This is required if you should 'ifdown RED; ifup RED'; you want the tap devices reconnected.)

If you have only one bridge, you mightn't need to give the taps unique names and can use 'regex tap.*' to reconnect all taps to the bridge if it is bounced. But your mileage may vary depending on any VPNs you may use.

I also have a set of scripts in /etc/network that handle the up-down bits. Examples for my GREEN bridge:

Up:
-----
#! /bin/bash

chgrp netdev /dev/net/tun
/sbin/brctl addif GREEN $1
ip link set dev $1 up
-----

Down:
-----
#! /bin/bash

ip link set dev $1 down
/sbin/brctl delif GREEN $1
-----

(Yeah, yeah, I know. I should use ip() for bridge control. But debian's ip() hasn't been quite new enough.)

And a GREEN example of qemu options for those scripts:
-----
# netIF is either virtio or e1000
# tapGREEN is 'tapGN$tapID'
# tapID is the MAC addr (sans colons) that the script generated for that VM's GREEN NIC

NIC1="-net nic,vlan=1,macaddr=$macGREEN,model=${netIF} -net tap,vlan=1,ifname=$tapGREEN,script=/etc/network/qemuGREENup,downscript=/etc/network/qemuGREENdown"
-----

I also assign explicitly coded MAC addresses to the virtual NICs so I know which VM is being addressed in any particular packet.

I can't find it now, but I also have an init script that starts VMs marked 'AUTOSTART' and stops them, if running, on shutdown.

[toc] | [prev] | [next] | [standalone]


#172318

FromAndrew Wood <andrewjameswood@ymail.com>
Date2016-09-16 21:50 +0200
Message-ID<si7j4-FB-29@gated-at.bofh.it>
In reply to#172099

On 12/09/16 23:23, Neal P. Murphy wrote:
>
> You might find something in here useful.

On 12/09/16 21:43, Charlie Kravetz wrote:
> Change the bridge_ports to:
> 	bridge_ports eth1 tap0
>
> then add the tap lines:
>          auto tap0
>               iface tap0 inet static
>               address 192.168.??.?
>               netmask 255.255.255.0
>               tunctl_user vboxusers

On 12/09/16 21:33, Nemeth Gyorgy wrote:
> An example:
>
> http://www.shakthimaan.com/installs/debian-tun-tap-setup.html
>

Thanks all, very useful

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web