'Ghost' tunnel interfaces

kauedg

Cadet
Joined
Jan 13, 2021
Messages
7
While trying to setup an OpenVPN client in a Jail a strange bug appeared. In the process of starting the openvpn service I started getting this strange behaviour:

Code:
# ifconfig tun2
ifconfig: interface tun2 does not exist

# ifconfig tun2 destroy
ifconfig: interface tun2 does not exist

# ifconfig tun2 create
ifconfig: SIOCIFCREATE2: File exists


I noticed that, even though no tunnel interface was being shown in the ifconfig output, the respective block devices still existed in /dev/. So I removed them manually. That didn't help at all.

After restarting the jail, recreating it and all sorts of trial, error and documentation searching I noticed that:
1. There were no tun* interfaces in /dev inside the jail;
2. There were no tun* interfaces in /dev on the host;

BUT, only when the jail was running, there was a lot of tun devices in the jail's directory on the host filesystem:
Code:
# ls /mnt/Pool_raidz/iocage/jails/openvpn-1/root/dev/
bpf     stdin   tun104  tun112  tun120  tun129  tun137  tun145  tun153  tun161  tun17   tun178  tun186  tun194  tun201  tun21   tun218  tun226  tun234  tun242  tun250  tun26   tun34   tun42   tun50   tun59   tun67   tun75   tun83   tun91   urandom
bpf0 stdout tun105 tun113 tun121 tun13 tun138 tun146 tun154 tun162 tun170 tun179 tun187 tun195 tun202 tun210 tun219 tun227 tun235 tun243 tun251 tun27 tun35 tun43 tun51 tun6 tun68 tun76 tun84 tun92 zero
crypto tun0 tun106 tun114 tun122 tun130 tun139 tun147 tun155 tun163 tun171 tun18 tun188 tun196 tun203 tun211 tun22 tun228 tun236 tun244 tun252 tun28 tun36 tun44 tun52 tun60 tun69 tun77 tun85 tun93 zfs
fd tun1 tun107 tun115 tun123 tun131 tun14 tun148 tun156 tun164 tun172 tun180 tun189 tun197 tun204 tun212 tun220 tun229 tun237 tun245 tun253 tun29 tun37 tun45 tun53 tun61 tun7 tun78 tun86 tun94
null tun10 tun108 tun116 tun124 tun132 tun140 tun149 tun157 tun165 tun173 tun181 tun19 tun198 tun205 tun213 tun221 tun23 tun238 tun246 tun254 tun3 tun38 tun46 tun54 tun62 tun70 tun79 tun87 tun95
ptmx tun100 tun109 tun117 tun125 tun133 tun141 tun15 tun158 tun166 tun174 tun182 tun190 tun199 tun206 tun214 tun222 tun230 tun239 tun247 tun255 tun30 tun39 tun47 tun55 tun63 tun71 tun8 tun88 tun96
pts tun101 tun11 tun118 tun126 tun134 tun142 tun150 tun159 tun167 tun175 tun183 tun191 tun2 tun207 tun215 tun223 tun231 tun24 tun248 tun256 tun31 tun4 tun48 tun56 tun64 tun72 tun80 tun89 tun97
random tun102 tun110 tun119 tun127 tun135 tun143 tun151 tun16 tun168 tun176 tun184 tun192 tun20 tun208 tun216 tun224 tun232 tun240 tun249 tun257 tun32 tun40 tun49 tun57 tun65 tun73 tun81 tun9 tun98
stderr tun103 tun111 tun12 tun128 tun136 tun144 tun152 tun160 tun169 tun177 tun185 tun193 tun200 tun209 tun217 tun225 tun233 tun241 tun25 tun33 tun41 tun5 tun58 tun66 tun74 tun82 tun90 tun99


So far I believe this is a host system problem because the command ifconfig tun create has the same behaviour inside and outside the jail: it creates the next tun interface (tun258) but I can't mess around with tun[0-257]:

Code:
# ifconfig tun257 destroy
ifconfig: interface tun257 does not exist

# ifconfig tun257 create
ifconfig: SIOCIFCREATE2: File exists

# ifconfig tun258 create
#

# ifconfig tun258 destroy
#

# ifconfig tun create
tun258


When the jail startes it gets the tun[0-257] devices from somewhere but I still don't know from where.

The workaround solution I've found online so far is to reboot the host but I want to find the source of this problem and solve it. As I'm new to FreeBSD and I was hoping some experienced user could help me understand where are these tun interfaces coming from.
 

kauedg

Cadet
Joined
Jan 13, 2021
Messages
7
Forgot:

Code:
kern.ostype: FreeBSD
kern.osrelease: 12.2-RELEASE-p2
kern.osrevision: 199506
kern.version: FreeBSD 12.2-RELEASE-p2 663e6b09467(HEAD) TRUENAS
 

Saigot

Cadet
Joined
Oct 17, 2023
Messages
1
Did you ever solve this, I seem to be facing a similar issue with TrueNAS-13.0-U3.1
 
Top