1 .\" $NetBSD: tun.4,v 1.1 1996/06/25 22:17:37 pk Exp $
10 .Nd tunnel software network interface
16 interface is a software loopback mechanism that can be loosely
17 described as the network interface analog of the
21 does for network interfaces what the
23 driver does for terminals.
29 driver, provides two interfaces: an interface like the usual facility
31 (a network interface in the case of
35 and a character-special device
39 The network interfaces are named
42 etc., one for each control device that has been opened.
43 These network interfaces persist until the
45 module is unloaded (if
47 is built into your kernel, the network interfaces cannot be removed).
52 permits opens on the special control device
54 When this device is opened,
56 will return a handle for the lowest unused
61 Control devices (once successfully opened) persist until
63 is unloaded in the same way that network interfaces persist (see above).
65 Each interface supports the usual network-interface
69 and thus can be used with
71 like any other interface.
72 At boot time, they are
74 interfaces, but this can be changed; see the description of the control
76 When the system chooses to transmit a packet on the
77 network interface, the packet can be read from the control device
81 writing a packet to the control device generates an input
82 packet on the network interface, as if the (non-existent)
83 hardware had just received it.
86 .Pq Pa /dev/tun Ns Ar N
88 (it cannot be opened if it is already open).
91 call will return an error
93 if the interface is not
95 (which means that the control device is open and the interface's
96 address has been set).
98 Once the interface is ready,
100 will return a packet if one is available; if not, it will either block
101 until one is or return
103 depending on whether non-blocking I/O has been enabled.
104 If the packet is longer than is allowed for in the buffer passed to
106 the extra data will be silently dropped.
110 ioctl has been set, packets read from the control device will be prepended
111 with the destination address as presented to the network interface output
114 The destination address is in
117 The actual length of the prepended address is in the member
121 ioctl has been set, packets will be prepended with a four byte address
122 family in network byte order.
126 are mutually exclusive.
127 In any case, the packet data follows immediately.
131 call passes a packet in to be
133 on the pseudo-interface.
136 ioctl has been set, the address family must be prepended, otherwise the
137 packet is assumed to be of type
141 call supplies exactly one packet; the packet length is taken from the
142 amount of data provided to
144 (minus any supplied address family).
145 Writes will not block; if the packet cannot be accepted for a
147 (e.g., no buffer space available),
148 it is silently dropped; if the reason is not transient
149 (e.g., packet too large),
150 an error is returned.
157 .Bl -tag -width ".Dv TUNSIFMODE"
159 The argument should be a pointer to an
161 this sets the internal debugging variable to that value.
162 What, if anything, this variable controls is not documented here; see
165 The argument should be a pointer to an
167 this stores the internal debugging variable's value into it.
169 The argument should be a pointer to an
171 and allows setting the MTU, the type, and the baudrate of the tunnel
178 The use of this ioctl is restricted to the super-user.
180 The argument should be a pointer to an
182 where the current MTU, type, and baudrate will be stored.
184 The argument should be a pointer to an
186 its value must be either
192 OR'd into the value if multicast support is required.
193 The type of the corresponding
195 interface is set to the supplied type.
196 If the value is outside the above range, an
199 The interface must be down at the time; if it is up, an
203 The argument should be a pointer to an
205 a non-zero value turns off
209 mode, causing packets read from the tunnel device to be prepended with
210 the network destination address (see above).
212 Will set the pid owning the tunnel device to the current process's pid.
214 The argument should be a pointer to an
216 a non-zero value turns off
220 mode, where every packet is preceded with a four byte address family.
222 The argument should be a pointer to an
224 the ioctl sets the value to one if the device is in
226 mode, and zero otherwise.
228 Turn non-blocking I/O for reads off or on, according as the argument
230 value is or is not zero.
231 (Writes are always non-blocking.)
233 Turn asynchronous I/O for reads
236 when data is available to be read)
237 off or on, according as the argument
239 value is or is not zero.
241 If any packets are queued to be read, store the size of the first one
244 otherwise, store zero.
246 Set the process group to receive
248 signals, when asynchronous I/O is enabled, to the argument
252 Retrieve the process group value for
254 signals into the argument
259 The control device also supports
261 for read; selecting for write is pointless, and always succeeds, since
262 writes are always non-blocking.
264 On the last close of the data device, by default, the interface is
267 .Nm ifconfig Ar tunN Cm down ) .
268 All queued packets are thrown away.
269 If the interface is up when the data device is not open
270 output packets are always thrown away rather than letting
283 This manual page was originally obtained from