Date: Fri, 1 Nov 1996 09:47:32 -0600 (CST) From: Joe Greco <jgreco@brasil.moneng.mei.com> To: fenner@parc.xerox.com (Bill Fenner) Cc: bruno@cs.ucla.edu, freebsd-hackers@FreeBSD.ORG Subject: Re: FreeBSD and IP tunneling Message-ID: <199611011547.JAA00306@brasil.moneng.mei.com> In-Reply-To: <96Oct30.100232pst.177480@crevenia.parc.xerox.com> from "Bill Fenner" at Oct 30, 96 10:02:20 am
next in thread | previous in thread | raw e-mail | index | archive | help
> Packets sent on the tun* interfaces show up as data to be read on /dev/tun*. > Data written on /dev/tun* shows up as input packets on the tun* interfaces. > So, if you want to do UDP encapsulated tunnelling, you should do something like > > open(/dev/tun0) > socket(...,SOCK_DGRAM,...); > bind(); > connect(); > while(1) { > select on the file and the socket > if data is available from the file, write it to the socket > if data is available from the socket, write it to the file > } Here this is in code... do not be deceived by the name, it is literally a VERY simple set of bare bones functions to play with this stuff right now. I hope to develop it into a useful set of tools. begin 644 tunneltools.tar.gz M'XL("`S#-#("`W1U;FYE;'1O;VQS+G1A<@#M&6MOVS;07^U?P6:8(R>N+3_3 MQDV!H&F&8%T")"W6+0L,6J)L+K)DD)33;,A_WQTIR9*EI"VV-%AA`K&H.]Z; MNCLR*@H"YJLP]&6[\DB#].V]P8!4"!G:_:Y^]OI]?";#!E"W,^CT.[UACY!. MMS_H5<B@\@U&)!45A%3^G`KFA/>OD[=2L7GE>QLJ$W^8MYQ'D-&Q[:&)=VG\ MNX`W\;<[P[WN`.+?&W2&%6)OXO_HXP<>.'[DLN1+?"65R\/6['6M@/&<0/E9 M3/45$R((\R#P4ULRGSFJ".>AL\XA8*K-O3+8&+<CP/5H[]3(#@D7+""4F#U+ M>*"8\*C#6HCC'@D(ER0(`3FEBB]9DP@FE>".(F$D0*DEDT2%1,VH0B9K'$(U M8^*&2T:D0P/BA8+`@RXI]^G$9YG5X(V/'S\2-V0H3\$$>'*)3!942C*ASC5` MF%:8N2M*F)'M8%N+$TOJH\*O(/N%`0%7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:VC#X33#'JU,2.OU>&,>D'Z9N9F=L_V'O5VT M=Q6]7"*B*N160KM+.HW2ECDV`XX[1AW\O&(W8421'DXCP!;.&%0GQW4[GI&, M)8D\F*:.RROQ)":>AC=XO$K#LHJ;V;'WQ*9,UY4J^?2-96B<9*Y&T01/,'8/ M*M.JEVI_)E!C.F=%UUN8Y4#ZE"F<36YQF193ZN@'E'@@D^28/Y10DMG$"1>W M6K7GKV?:*6.?2W5I7T&-,3FN42]U9%IJ2K'9^):84G[D<?`H[ZCU.B_30F*V M@#FNI-7_Z:I^L12:&ASKF:F_9:4\MO;?5/."O_83'W[]21.8Y+U=.!BBTI*9 M_B,Y%$)G\\DN42WE"2T-^TR#89><4[]`&URZI'[:@NG[E0,@=Y9%#4M43.3L M:Y('-4361LGOZOPWI_Q1+H`_=_]K#]/SWUYG;XCGO^&@LSG_/?GY[X'#GN)S MEH=&`10*-W=.PPVE/ULJIDZ:M<5T>7F5?K.P`5VVA`]5MP0:V;UJC%(DWF+J MN<^#:_WBN6/)\,H*SWB:)WS;'A.7+SHONU>C;"I(KP!!6TP':AFCS?5?]^4P M31>&/0"+A\N7T`-F,P;[!,U12>K.TAAV3:(-ZD#UU$P>X&%I6^.+U?1FMV[< M\SGI:Y>DFE63='M-<S/:>]&_5WBM>C/#"V=XU[CCH_'O;\_/K#KX5^=``%R\ M?9_P7`<G=J9PM6RI)00(._"AO8)$!J0AV?QL_E=@];J&1Y.<?GCW+OFMJYSI M::XV1"9'WQ'F2V;PR!@4.[E8USBF7ZL,\05HO-#LHK3(FM=&3GZU"DV=RZ5# MA8LM'4*R\JO55?%,/).PC8N&)JDE/SF%<[Z\5^,RWO^!RB6.*-/X#O?,YMIW 8,S9C,S9C,S9C,S;C?SO^`=M(_3``*``` ` end I have been playing with tunnel devices for a little while now, and the concept is very very powerful... Note the MTU in this code is tuned way down, you will want to reset it to a higher number. It works as-is.... let's assume you have tun0 on both ends. box1# ./a.out box2.some.com 0 & box1# ifconfig tun0 10.1.1.1 10.1.1.2 box2# ./a.out box1.some.com 0 & box2# ifconfig tun0 10.1.1.2 10.1.1.1 You can now ping/etc from box1 to box2 or vice versa using the 10.1.1.X addresses. .. JG
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199611011547.JAA00306>