# Diffrence between tunctl and /etc/conf.d/net

## betlor5

Hi,

I wanted to ask about the diffrence of the execution of tunctl and same command over /etc/conf.d/net. Because I noticed some diffrences in the working of my network. For example if I run

```

tunctl -u root-t tap0

ifconfig tap0 192.168.100.11

```

and afterwards associate a qemu maschine with it I am able to ping the tap device, but if I write down

```

tuntap_tap1="tap"

config_tap1="192.168.100.11"

```

in /etc/conf.d/net and symlinke net.tap0 with net.lo and put it in rc-update, I am not able to link my qemu with the tap0 device. This means that if I try to ping my tap0 inside the qemu I do not get any replay. Therefore I wanted to ask what am I missing or what is the diffrence between the two tap0 devices?

Thanks,

betlor5

----------

## Logicien

According with what you want, you need to write in /etc/conf.d/net

```
config_tap0="192.168.100.11"

tunctl_tap0="-u root"

tuntap_tap0="tap"
```

and symlink net.tap0 to net.lo. Create tap1 in /etc/conf.d/net and symlink net.tap0 to net.lo should not work.

Note that the access to this network virtual device by non root users depend on the permissions of the device file /dev/net/tun. It user and group can be root and non root users will access it if the permissions are 0666. It depend of what Udev do.

For the users is in the users group for example, you can just configure

```
tunctl_tap0="-g users"
```

in /etc/conf.d/net and all of them should access tap0. In my Gentoo installation tunctl is not install and Openrc create tap0 at boot time. It probably use the ip command. Here is a manual example that should work for you

```
modprobe tun

ip tuntap add tap0 mode tap group users

ip addr flush dev tap0

ip addr add 192.168.100.11/24 brd 192.168.100.255 dev tap0

ip link set dev tap0 up
```

To delete tap0

```
ip link set dev tap0 down

ip link del tap0
```

Those network virtual devices are often use with virtual machines. I prefer to not give any IP address to tap0 and put it in a bridge that will have an IP address and than give tap0 as the virtual network device to VirtualBox and Qemu.

----------

## betlor5

Hi,

I tried adding the option 

```

tunctl_tap0="-u root" 

```

but I am still getting a diffrent result. I can't ping the tap defice from within the qemu device while I can do it with the tunctl option. 

And in my post beforehand I made a misstake. The tap0 should also be tap1.

----------

## Hu

Please post the output of cat -n /etc/conf.d/net, the boot messages showing the net.tap0 script starting, and the qemu command line.

----------

## betlor5

As I have already posted my /etc/conf.d/net looks now like this:

```

tuntap_tap1="tap"

tunctl_tap1="-u betlor -g qemu"

config_tap1="192.168.100.11"

```

For qemu I have tried it with all thinkable combinations, the current one is:

```

qemu-system-x86_64 \

        -smp 1\

        -hda Mail.img\

        -enable-kvm\

        -m 2G \

        -vnc :1\

        -net nic\

        -net tap,ifname=tap1,script=no\

        -name "Mail VM" \

```

But the error should be undependent from qemu. I could have asked the same question with openvpn and tun devices. Regarding the net.tap1 device:

```

[    8.104628] IPv6: ADDRCONF(NETDEV_UP): tap1: link is not ready

[   43.531949] IPv6: ADDRCONF(NETDEV_CHANGE): tap1: link becomes ready

```

For further connection I am using

```

ifconfig iptables route

```

with the same syntax in both cases.

----------

