Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Making TUN/TAP Permanent

  1. #1
    Join Date
    Feb 2005
    Location
    Newcastle, England
    Beans
    54
    Distro
    Ubuntu 13.10 Saucy Salamander

    Making TUN/TAP Permanent

    I recently setup a TUN/TAP connection for a WinXP VM within VirtualBox as per the instructions here: https://help.ubuntu.com/community/Vi...3c109de1143a03

    It worked perfectly and was fairly easy to do.

    However, unsurprisingly, when I came to restart the connection was 'forgotten' and I was back to plain old eth0 - no br0, no tap1, etc.

    I can understand why these would be forgotten (not written into /etc/network/interfaces), but my question is how do I go about making it permanent?

    So I have an idea as to what I need to do, I'm just not entirely sure how to do it. Do I need to add a command to rc.local to create the bridge first? How about for creating tap1?
    And how would the notation look within /etc/network/interfaces to set eth0 to promiscuous?
    Code:
    iface eth0 inet 0.0.0.0 promisc
    ??

    Pretty sure these will be obvious answers that I've failed to spot, but any pointers would be appreciated!

    Thanks
    TD

  2. #2
    Join Date
    Apr 2007
    Location
    Germany
    Beans
    952
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Making TUN/TAP Permanent

    i am not sure if this answeres your question, but check out part2, step 3 on this tutorial. It shows how to permanently add bridges via the /etc/network/interfaces. The tun is only when the openvpn is loaded tho...

    hope it helps
    Calvin: I'm being educated against my will! My rights are being trampled!
    Hobbes: Is it a right to remain ignorant?
    Calvin: I don't know, but I refuse to find out!

  3. #3
    Join Date
    Feb 2005
    Location
    Newcastle, England
    Beans
    54
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Making TUN/TAP Permanent

    Thanks for that, that certainly helps a good way along the road.

    Does your final comment mean that creating the tap1 connection isn't possible automatically? Or just not through /etc/network/interfaces?

    Would there be a way to run this, perhaps via /etc/rc.local ?

    I'm throwing theories out here - I would try them out more readily, but it's a work desktop and I want to try to avoid breaking it as much as possible!

    Cheers,

    TD
    TD

  4. #4
    Join Date
    Apr 2007
    Location
    Germany
    Beans
    952
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Making TUN/TAP Permanent

    you can add the tap device via the rc.local. Since that is ran AFTER the network has been initialized, you can just create the tap there and then add it to the bridge...

    my comment was for adding it via the /etc/network/interfaces... but i am getting an idea now and will google it for a while...
    [searching...]

    right-o. This is not the most elegant way i can think of, but i found a way to add tap devices to your /etc/network/interfaces. Check this page to see examples (and where i got mine )

    Code:
    iface tap0 inet manual
            pre-up tunctl -t tap0
            up ifconfig tap0 up
            down ifconfig tap0 down
    if you add this to your /etc/network/interfaces (and add it BEFORE the br0 device) you should have the tap0 ready when the bridge is configured. So you should be able to add the tap0 to the bridge via the normal network config.
    As i said, this is not elegant, as this really only runs commands and DOES NOT use the actual logic behind real network cards. But it is better than nothing...

    tell me how it works
    Calvin: I'm being educated against my will! My rights are being trampled!
    Hobbes: Is it a right to remain ignorant?
    Calvin: I don't know, but I refuse to find out!

  5. #5
    Join Date
    Feb 2005
    Location
    Newcastle, England
    Beans
    54
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Making TUN/TAP Permanent

    No joy unfortunately, but thanks for the recommendation!

    I tried adding it as per your recommendation (which, judging by the output on the link, was correct), but no joy. After startup:

    Code:
    MyUser@Desktop:~$ sudo ifconfig tap1 up
    tap1: ERROR while getting interface flags: No such device
    /me sighs.

    Any ideas as to a way to add everything in to create the TAP before the bridge, then bring it up after the bridge?

    As I understand from the first guide I was following, the commands I need to run are:
    Code:
    ~$ sudo tunctl -t tap1 -u MyUser
    ~$ sudo brctl addif br0 tap1 
    ~$ sudo ifconfig tap1 up
    Of course, it's not the end of the world manually running those commands each time I start up the machine (would a simple shell script handle this easier?), but if I can get it automated it would be slick

    At least the Bridge is created fine...

    Thanks again,

    TD
    TD

  6. #6
    Join Date
    Apr 2007
    Location
    Germany
    Beans
    952
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Making TUN/TAP Permanent

    i take you changed tap0 into tap1 ??? the little snipped did work here on my ubuntu 8.04 server (vm - fresh install) - i am a little surprised about this...

    anyway, good look hunting the solution
    Calvin: I'm being educated against my will! My rights are being trampled!
    Hobbes: Is it a right to remain ignorant?
    Calvin: I don't know, but I refuse to find out!

  7. #7
    Join Date
    Feb 2005
    Location
    Newcastle, England
    Beans
    54
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Making TUN/TAP Permanent

    Yep, sorry, just have specified that.

    The snippet from my /etc/network/interfaces is as follows:

    Code:
    iface tap1 inet manual
            pre-up tunctl -t tap1
            up ifconfig tap1 up
            down ifconfig tap1 down
    Hmmm... looking at it again, does it need an auto tap1 line ? I would have thought that wouldn't make any difference though, seeing as manually trying to up tap1 failed without first running through the tunctl and brctl bits.

    Running 8.04 here as well.

    Is all a tad confusing and, like I said, not really the end of the world in and of itself. Adding the bridge was the one part that was nice to get automated, it would just be nicer if I could find some convenient way to add the tap as well, seeing as I'm going to need to be opening it and running through it every time I startup.

    Would the Shell Script idea work? Alas my knowledge of shell scripts sucks (read: I'll spend the afternoon googling how to do it right) but if I got on that works then forcing it to run on startup should be a simple matter, right?

    Thanks again for your help on this, it is appreciated
    TD

  8. #8
    Join Date
    Feb 2005
    Location
    Newcastle, England
    Beans
    54
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Making TUN/TAP Permanent

    Finally bit the bullet and went for the /etc/rc.local approach.

    Added the following lines to it:
    Code:
    tunctl -t tap1 -u MyUser
    brctl addif br0 tap1
    ifconfig tap1 up
    And it seems (on the first reboot at least...) to have worked!

    Thanks for your help on this SpaceTeddy. I'm still at a loss as to work out why we had different results using /etc/network/interfaces and we tried some variations here, but, for now, it works!
    TD

  9. #9
    Join Date
    Nov 2005
    Beans
    6

    Re: Making TUN/TAP Permanent

    The "right way"

    cat /etc/network/interfaces:

    blablabla....

    auto tap30
    iface tap30 inet static
    address 10.10.30.1
    netmask 255.255.255.0
    pre-up /usr/sbin/tunctl -t tap30

  10. #10
    Join Date
    Aug 2009
    Beans
    2

    Re: Making TUN/TAP Permanent

    I for whatever reason was not able to get this to work using /etc/network/interfaces. I, however, was able to get it to work with rc.local. I was trying to bridge tap interfaces to vmnet interfaces, so that I could both access my GNS3 lab and my VM network. If I wanted it to work without the VM network, I would just leave out the VMnet interfaces in the configuration. This works across reboots.

    rc.local:

    tunctl -t tap1 -u user
    brctl addbr br1
    brctl addif br1 tap1
    brctl addif br1 vmnet1
    ifconfig tap1 0.0.0.0 promisc up
    ifconfig vmnet1 0.0.0.0 promisc up
    ifconfig br1 5.5.5.1/24 up
    Last edited by xiphos45; August 22nd, 2009 at 02:34 AM.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •