# Практическая работа №2. GRE-туннелирование ###### tags: `2 сем` --- ![](https://i.imgur.com/KkPWtPD.png) --- ## GRE-tunnel на роутерах Cisco 1) Настройка на C-R-1 ``` C-R-1(config)#int Tunnel1 C-R-1(config-if)# ip address 172.16.100.1 255.255.255.252 C-R-1(config-if)# ip mtu 1400 C-R-1(config-if)# ip tcp adjust-mss 1360 C-R-1(config-if)# tunnel source Ethernet0/0 C-R-1(config-if)# tunnel destination 10.10.20.1 ``` 2) Настройка на C-R-2 ``` C-R-2(config)#int Tunnel1 C-R-2(config-if)# ip address 172.16.100.2 255.255.255.252 C-R-2(config-if)# ip mtu 1400 C-R-2(config-if)# ip tcp adjust-mss 1360 C-R-2(config-if)# tunnel source Ethernet0/0 C-R-2(config-if)# tunnel destination 10.10.10.1 ``` 3) Проверка работы GRE-тоннеля ``` C-R-1#trace 172.16.100.2 Type escape sequence to abort. Tracing the route to 172.16.100.2 VRF info: (vrf in name/id, vrf out name/id) 1 172.16.100.2 8 msec 8 msec * ``` 4) Static Для C-R-1 ``` C-R-1(config)# ip route 192.168.2.0 255.255.255.0 172.16.100.2 ``` Для C-R-2 ``` C-R-2(config)# ip route 192.168.1.0 255.255.255.0 172.16.100.1 ``` ## GRE-tunnel на роутерах Mikrotik 1) Настройка на M-3 ``` [admin@M-R-3] > interface gre add name=Tunnel-gre local-address=10.10.30.1 remote-address=10.10.40.1 mtu=1400 keepalive=3s,1 allow-fast-path-no [admin@M-R-3] > ip add add add=172.16.101.1/30 interface=Tunnel-gre [admin@M-R-3] > ip route add distance=1 dst-address=192.168.4.0/24 gateway=172.16.101.2 ``` 2) Настройка на М-4 ``` [admin@M-4] > interface gre add name=Tunnel-gre local-address=10.10.40.1 remote-address=10.10.30.1 mtu=1400 keepalive=3s,1 allow-fast-path-no [admin@M-4] > ip add add add=172.16.101.2/24 interface=Tunnel-gre [admin@M-4] > ip route add distance=1 dst-address=192.168.3.0/24 gateway=172.16.101.1 ``` 3) Проверка GRE-тоннеля ``` [admin@M-R-3] > tool traceroute 192.168.4.1 1 172.16.10.1 ``` ## GRE-tunnel на debian 1) Настройка на Debian-41 Файл `/etc/network/interfaces` ``` source /etc/network/interfaces.d/* auto lo iface lo inet loopback auto ens3 allow-hotplug ens3 iface ens3 intr static address 172.16.4.20 netmask 255.255.255.0 gateway 172.16.4.254 auto gre3 iface gre3 inet tunnel address 172.16.102.1 netmask 255.255.255.252 mode gre local 172.16.4.20 endpoint 192.168.2.20 ttl 255 ``` 2) Настройка на Debian-21 Файл `/etc/network/interfaces` ``` source /etc/network/interfaces.d/* auto lo iface lo inet loopback auto ens3 allow-hotplug ens3 iface ens3 intr static address 172.16.2.20 netmask 255.255.255.0 gateway 172.16.2.254 auto gre3 iface gre3 inet tunnel address 172.16.102.2 netmask 255.255.255.252 mode gre local 172.16.2.20 endpoint 192.168.4.20 ttl 255 ``` 3) Настройка на pfSense-FW-4 Firewall/NAT/Port Forward add -> WAN -> IPv4 -> ICMP ->Dest add (192.168.4.20) -> Redirect target IP (172.16.4.20) 4) Настройка на FW-Linux-2 ``` iptables -t nat -A PREROUTING -i ens3 -s 192.168.4.20 -j DNAT --to-destination 172.16.2.10 ``` Добавляем модуль в файл командой `nano /etc/modules-load.d/modules.conf`, дописывая в файл `ip_nat_pptp`