GRE(4) OpenBSD Programmer's Manual GRE(4) NAME gre - encapsulating network device SYNOPSIS pseudo-device gre [count] NOTE GRE and MobileIP are enabled with the following sysctl(3) variables re- spectively in /etc/sysctl.conf: net.inet.gre.allow Allow GRE packets in and out of the system. net.inet.mobileip.allow Allow MobileIP packets in and out of the system. DESCRIPTION The gre network interface allows tunnel construction using the Cisco GRE or the Mobile-IP (RFC 2004) encapsulation protocols. This driver currently supports the following modes of operation: GRE encapsulation (IP protocol number 47). Encapsulated datagrams are prepended by a outer datagram and a GRE header. The GRE header specifies the type of the encapsulated data- gram and thus allows for tunneling other protocols than IP like e.g. AppleTalk (not yet supported). GRE mode is the default tunnel mode on Cisco routers. This is also the default mode of operation of the greX interfaces. MOBILE encapsulation (IP protocol number 55). Datagrams are encapsulated into IP, but with a much smaller encapsu- lation header. This protocol only supports IP in IP encapsulation, and is intended for use with mobile IP. The network interfaces are named gre0, gre1, etc. The number of inter- faces is given by the corresponding pseudo-device line in the system con- fig file. gre(4) interfaces support the following ioctl(2)s: GRESADDRS: Set the IP address of the local tunnel end. GRESADDRD: Set the IP address of the remote tunnel end. GREGADDRS: Query the IP address that is set for the local tunnel end. GREGADDRD: Query the IP address that is set for the remote tunnel end. GRESPROTO: Set the operation mode to the specified IP protocol value. The pro- tocol is passed to the interface in (struct ifreq)->ifr_flags. The operation mode can also be given as link0 IPPROTO_GRE link2 IPPROTO_MOBILE to ifconfig(8). As the linkN flags are not mutually exclusive, modes must be set by applying positive and negative flags, e.g., ifcon- fig(8) link0 -link1 -link2 GREGPROTO: Query operation mode. Note that the IP addresses of the tunnel endpoints may be the same as the ones defined with ifconfig(8) for the interface (as if IP is encapsulat- ed), but need not be, as e.g. when encapsulating AppleTalk. EXAMPLE Configuration example: Host X-- Host A ----------------tunnel---------- cisco D------Host E \ | \ / +------Host B----------Host C----------+ On host A (OpenBSD): # route add default B # ifconfig greN A D netmask 0xffffffff linkX up # route add E D On Host D (Cisco): Interface TunnelX ip unnumbered D ! e.g. address from Ethernet interface tunnel source D ! e.g. address from Ethernet interface tunnel destination A ip route C ip route A mask C ip route X mask tunnelX OR On Host D (OpenBSD): # route add default C # ifconfig greN D A To reach Host A over the tunnel (from host D), there has to be an alias on Host A for the Ethernet interface: ifconfig alias Y and on the cisco ip route Y mask tunnelX NOTE For correct operation, the gre device needs a route to the destination, that is less specific than the one over the tunnel. (There needs to be a route to the decapsulating host that does not run over the tunnel, as this would create a loop.) In order for ifconfig(8) to actually mark the interface as up, the key- word ``up'' must be given last on its command line. The kernel must be set to forward datagrams by including option ``GATE- WAY'' in the kernel config file and issuing the appropriate option to sysctl(8). SEE ALSO netintro(4), ip(4), atalk(4), inet(4), ifconfig(8), options(4), protocols(5), sysctl(8) A description of GRE encapsulation can be found in RFC 1701, RFC 1702. A description of MOBILE encapsulation can be found in RFC 2004. BUGS The compute_route() code in net/if_gre.c toggles the last bit of the IP- address to provoke the search for a less specific route than the one di- rectly over the tunnel to prevent loops. This is possibly not the best solution. To avoid the address munging described above, turn on the link1 flag on the ifconfig command line. This implies that the GRE packet destination and the remote host are not the same IP addresses, and that the GRE des- tination does not route over the greX interface itself. GRE RFC not yet fully implemented (no GRE options), no other protocols yet than IP over IP. AUTHOR Heiko W.Rupp OpenBSD 2.8 13 September 1998 3