You are here

Setup GRE Tunnel

lsmod

modprobe ip_gre
Now set it to start at boot.

echo "/sbin/modprobe ip_gre > /dev/null 2>&1" > /etc/sysconfig/modules/ip_gre.modules && chmod 755 /etc/sysconfig/modules/ip_gre.modules
Create ifcfg-tun0 Configuration Files
We need to create the configuration files for the GRE tunnel. These files live alongside your CentOS network device files in /etc/sysconfig/network-scripts/

grebos.centoshowtos.org

Create ifcfg-tun0 file. Please note, the internal and external interfaces must already be configured and plugged into the correct ports for each network.

vi /etc/sysconfig/network-scripts/ifcfg-tun0
The file should look like this (except your IPs will be different)

DEVICE=tun0
BOOTPROTO=none
ONBOOT=no
TYPE=GRE
PEER_OUTER_IPADDR=216.52.2.41
PEER_INNER_IPADDR=192.168.77.253
MY_INNER_IPADDR=192.168.77.254
gresea.centoshowtos.org

Create ifcfg-tun0 file where the network interface scripts are.

vi /etc/sysconfig/network-scripts/ifcfg-tun0
The file should look like this (except your IPs will be different)

DEVICE=tun0
BOOTPROTO=none
ONBOOT=no
TYPE=GRE
PEER_OUTER_IPADDR=141.136.108.122
PEER_INNER_IPADDR=192.168.77.254
MY_INNER_IPADDR=192.168.77.253
Bring tun0 interfaces online and verify
Now that we have the configuration files setup, we will need to bring up the tunnel interfaces and verify that they came online properly.

grebos.centoshowtos.org

We’ll just use the ifup command to bring up the interfaces.

ifup tun0
Now we can verify with the ifconfig command.

ifconfig tun0
gresea.centoshowtos.org

We’ll just use the ifup command to bring up the interfaces.

ifup tun0
Now we can verify with the ifconfig command.

ifconfig tun0
Test the connection
At this point the tunnel should be online, and the machines should be able to reach one another via internal IP addresses. Lets ping each other and make sure everything looks ok – make sure your firewall isn’t dropping ICMP packets if it doesn’t work.

grebos.centoshowtos.org

Ping gresea.centoshowtos.org internal address

ping 192.168.77.253
gresea.centoshowtos.org

Ping grebos.centoshowtos.org internal address

ping 192.168.77.254

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.