# Tunnel by GRE (Generic Routing Encapsulation)



## komeylian (Dec 6, 2008)

hi, 

I would like to explain gre in two BSD machine, just in 2 Steps

host A information :

interface ip address 10.1.1.1/24 (em0 : intel 1000) 
tunnel ip address 192.168.1.1/24



host B information :

interface ip address 10.1.1.2/24  (em0 : intel 1000) 
tunnel ip address 192.168.1.2/24




configuration in host A:


```
BSD # ifconfig gre0 create
BSD # ifconfig gre0 tunnel 10.1.1.1 10.1.1.2
BSD # ifconfig gre0 192.168.1.1 192.168.1.2 netmask 255.255.255.0
```

configuration in host B:


```
BSD # ifconfig gre0 create
BSD # ifconfig gre0 tunnel 10.1.1.2 10.1.1.1
BSD # ifconfig gre0 192.168.1.2 192.168.1.1 netmask 255.255.255.0
```



check tunnel in host A:


```
BSD # ifconfig gre0
gre0: flags=9051<UP,POINTOPOINT,RUNNING,LINK0,MULTICAST> metric
0 mtu 1476
tunnel inet 10.1.1.1 --> 10.1.1.2
inet 192.168.1.1 --> 192.168.1.2 netmask 0xffffff00
```



```
BSD # ping -c3 -S 192.168.1.1 192.168.1.2
PING 192.168.1.2 (192.168.1.2): 56 data bytes
64 bytes from 192.168.1.2: icmp_seq=0 ttl=128 time=0.359 ms
64 bytes from 192.168.1.2: icmp_seq=1 ttl=128 time=2.512 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=128 time=0.196 ms
--- 192.168.10.2 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.196/1.022/2.512/1.055 ms
```

:e


----------

