mirror, mirror on the wall

mirror, mirror on the wall

network access with GRE tunneling

Posted on .

Case: Network A 192.168.102.0/24, network B 192.168.103.0/24 and Internet. Network A has access to Internet. Network B does NOT have access to Internet. Network B has access to network A. Need to start application in network B which uses service from Internet. Lets say the service is available on 78.128.27.117. Will use two servers CentOS release 6.3.

Configuration:

  • IP: 192.168.102.63
  • Mask: 255.255.255.0
  • Gateway: 192.168.102.254
  • IP: 192.168.103.133
  • Mask: 255.255.255.0
  • Gateway: 192.168.103.254

On 192.168.102.63:

# cat /etc/sysconfig/network-scripts/ifcfg-tun0

DEVICE=tun0
BOOTPROTO=none
ONBOOT=no
TYPE=GRE
PEER_OUTER_IPADDR=192.168.103.133
PEER_INNER_IPADDR=172.23.0.1
MY_INNER_IPADDR=172.23.0.2

# ifup tun0
# sysctl net.ipv4.conf.all.forwarding=1
# iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE

On 192.168.103.133:

# cat /etc/sysconfig/network-scripts/ifcfg-tun0

DEVICE=tun0
BOOTPROTO=none
ONBOOT=no
TYPE=GRE
PEER_OUTER_IPADDR=192.168.102.63
PEER_INNER_IPADDR=172.23.0.2
MY_INNER_IPADDR=172.23.0.1

# ifup tun0
# route add 78.128.27.117 gw 172.23.0.2
Nice ;)

About

github

Creative Commons

RSS