gre - encapsulating network device
device gre
Alternatively, to load the
device as a module at boot time, place the following line in
loader.conf5:
if_gre_load="YES"
interfaces are dynamically created and destroyed with the ifconfig(8) create and destroy subcommands.
This driver currently supports the following modes of operation:
The interfaces support a number of ioctl(2)Nss, such as:
to ifconfig(8).
The link1 flag is not used to choose encapsulation, but to modify the internal route search for the remote tunnel endpoint, see the Sx BUGS section below.
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 encapsulated), but need not be, as e.g. when encapsulating AppleTalk.
Host X-- Host A ----------------tunnel---------- Cisco D------Host E \ | \ / +------Host B----------Host C----------+
On host A (Fx : )
route add default B ifconfig greN create ifconfig greN A D netmask 0xffffffff linkX up ifconfig greN tunnel A D 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 <some interface and mask> ip route A mask C ip route X mask tunnelX
OR
On Host D (Fx : )
route add default C ifconfig greN create ifconfig greN D A ifconfig greN tunnel D A
If all goes well, you should see packets flowing ;-)
If you want to reach Host A over the tunnel (from Host D (Cisco)), then you have to have an alias on Host A for e.g. the Ethernet interface like:
"ifconfig <etherif> alias Y"
and on the Cisco:
"ip route Y mask tunnelX"
A similar setup can be used to create a link between two private networks (for example in the 192.168 subnet) over the Internet:
192.168.1.* --- Router A -------tunnel-------- Router B --- 192.168.2.* \ / \ / +------ the Internet ------+
Assuming router A has the (external) IP address A and the internal address 192.168.1.1, while router B has external address B and internal address 192.168.2.1, the following commands will configure the tunnel:
On router A:
ifconfig greN create ifconfig greN 192.168.1.1 192.168.2.1 link1 ifconfig greN tunnel A B route add -net 192.168.2 -netmask 255.255.255.0 192.168.2.1
On router B:
ifconfig greN create ifconfig greN 192.168.2.1 192.168.1.1 link1 ifconfig greN tunnel B A route add -net 192.168.1 -netmask 255.255.255.0 192.168.1.1
Note that this is a safe situation where the link1 flag (as discussed in the Sx BUGS section below) may (and probably should) be set.
For correct operation, the device needs a route to the destination that is less specific than the one over the tunnel. (Basically, there needs to be a route to the decapsulating host that does not run over the tunnel, as this would be a loop.) If the addresses are ambiguous, doing the ifconfig tunnel step before the ifconfig(8) call to set the IP addresses will help to find a route outside the tunnel.
In order to tell ifconfig(8) to actually mark the interface as ``up'' the keyword up must be given last on its command line.
The kernel must be set to forward datagrams by setting the net.inet.ip.forwarding sysctl(8) variable to non-zero.
A description of GRE encapsulation can be found in RFC 1701 and RFC 1702.
A description of MOBILE encapsulation can be found in RFC 2004.
To avoid the address munging described above, turn on the link1 flag on the ifconfig(8) command line. This implies that the GRE packet destination and the ifconfig remote host are not the same IP addresses, and that the GRE destination does not route over the interface itself.
The current implementation uses the key only for outgoing packets. Incomming packets with a different key or without a key will be treated as if they would belong to this interface.
RFC1701 is not fully supported, however all unsupported features have been deprecated in RFC2784.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |