Original works, allow reprint, please be sure to use hyperlinks in the form of the original source of the article, author information and this statement. Otherwise, the legal liability will be investigated. http://333234.blog.51cto.com/323234/931805
1. Topology diagram:
Note: For application reasons, a public address needs to be added to the linux2, and Linux1 can access the public address on the LINUX2 if the intermediate routing device is not controlled.
2. Basic Interface Configuration:
linux1:192.168.10.1/24
linux2:192.168.20.2/24
R1:
Interface fastethernet0/0
IP address 192.168.10.10 255.255.255.0
No shutdown
!
Interface FASTETHERNET0/1
IP address 192.168.20.10 255.255.255.0
No shutdown
3. Routing configuration:
LINUX1 Gateway: 192.168.10.10
LINUX2 Gateway: 192.168.20.10
R1: only Direct Connect routing
4.linux2 Single-NIC multi-address configuration:
[Email protected] ~]# cp/etc/sysconfig/network-scripts/ifcfg-eth0/etc/sysconfig/network-scripts/ifcfg-eth0:0
[Email protected] ~]# vi/etc/sysconfig/network-scripts/ifcfg-eth0:0
# advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
device=eth0:0
Bootproto=none
Onboot=yes
hwaddr=00:0c:29:08:48:63
netmask=255.255.255.252
ipaddr=202.100.2.2
Type=ethernet
Userctl=no
Ipv6init=no
Peerdns=yes
[Email protected] ~]# service network restart
[[email protected] ~]# Ping 202.100.2.2
PING 202.100.2.2 (202.100.2.2) bytes of data.
Bytes from 202.100.2.2:icmp_seq=1 ttl=64 time=0.124 ms
---202.100.2.2 ping statistics---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
RTT Min/avg/max/mdev = 0.124/0.124/0.124/0.000 ms
[[email protected] ~]# Ping 192.168.10.10
PING 192.168.10.10 (192.168.10.10) bytes of data.
Bytes from 192.168.10.10:icmp_seq=1 ttl=255 time=70.6 ms
---192.168.10.10 ping statistics---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
RTT Min/avg/max/mdev = 70.629/70.629/70.629/0.000 ms
5.GRE Tunnel Configuration:
A. Determine if the GRE module is loaded
[Email protected] ~]# lsmod |grep ip_gre
[Email protected] ~]# lsmod |grep ip_gre
B. Loading the GRE module
[Email protected] ~]# Uname-an
Linux linux1 2.6.9-78.el #1 Wed Jul 9 15:27:01 EDT-i686 i686 i386 Gnu/linux
[Email protected] ~]# insmod/lib/modules/2.6.9-78.el/kernel/net/ipv4/ip_gre.ko
[Email protected] ~]# Uname-an
Linux linux2 2.6.18-164.el5 #1 SMP Thu Sep 3 03:33:56 EDT i686 i686 i386 gnu/linux
[Email protected] ~]# Insmod/lib/modules/2.6.18-164.el5/kernel/net/ipv4/ip_gre.ko
C.gre Tunnel Interface Configuration
Linux1:
IP tunnel Add tunnel0 mode GRE remote 192.168.20.2 local 192.168.10.1 TTL 255
IP link set tunnel0 up MTU 1400
IP addr Add 172.16.1.1/30 dev tunnel0
IP addr Add 172.16.1.1/30 peer 172.16.1.2/30 Dev tunnel0
IP route add 202.100.2.2/32 Dev tunnel0
Linux2:
IP tunnel Add tunnel0 mode GRE remote 192.168.10.1 local 192.168.20.2 TTL 255
IP link set tunnel0 up MTU 1400
IP addr Add 172.16.1.2/30 dev tunnel0
IP addr Add 172.16.1.2/30 peer 172.16.1.1/30 Dev tunnel0
D. Run the tunnel configuration on:
linux1:
vi/etc/init.d/gre.sh # #内容如下:
Insmod/lib/modules/2.6.9-78.el/kernel/net/ipv4/ip_gre.ko
IP tunnel Add tunnel0 mode GRE remote 192.168.20.2 local 192.168.10.1 TTL 255
IP link set tunnel0 up MTU 1400
IP addr Add 172.16.1.1/30 dev tunnel0
IP Addr del 172.16.1.1/30 peer 172.16.1.2/30 Dev tunnel0
IP addr Add 172.16.1.1/30 peer 172.16.1.2/30 Dev tunnel0
IP route add 202.100.2.2/32 Dev tunnel0
chmod +x/etc/init.d/gre.sh
echo "/etc/init.d/gre.sh" >>/etc/rc.d/rc.local
linux2:
vi/etc/init.d/gre.sh # #内容如下:
Insmod/lib/modules/2.6.18-164.el5/kernel/net/ipv4/ip_gre.ko
IP tunnel Add tunnel0 mode GRE remote 192.168.10.1 local 192.168.20.2 TTL 255
IP link set tunnel0 up MTU 1400
IP addr Add 172.16.1.2/30 dev tunnel0
IP Addr del 172.16.1.2/30 peer 172.16.1.1/30 Dev tunnel0
IP addr Add 172.16.1.2/30 peer 172.16.1.1/30 Dev tunnel0
chmod +x/etc/init.d/gre.sh
echo "/etc/init.d/gre.sh" >>/etc/rc.d/rc.local
D. Verifying the GRE interface
[[Email protected] ~]# IP addr Show
1:lo: <LOOPBACK,UP> MTU 16436 Qdisc noqueue
Link/loopback 00:00:00:00:00:00 BRD 00:00:00:00:00:00
inet 127.0.0.1/8 BRD 127.255.255.255 Scope host Lo
INET6:: 1/128 Scope Host
Valid_lft Forever Preferred_lft Forever
2:eth0: <BROADCAST,MULTICAST,UP> MTU Qdisc pfifo_fast Qlen 1000
Link/ether 00:0c:29:e4:65:78 BRD FF:FF:FF:FF:FF:FF
inet 192.168.10.1/24 BRD 192.168.10.255 Scope Global eth0
Inet6 FE80::20C:29FF:FEE4:6578/64 Scope link
Valid_lft Forever Preferred_lft Forever
3:sit0: <NOARP> MTU 1480 Qdisc NoOp
Link/sit 0.0.0.0 BRD 0.0.0.0
4:GRE0: <NOARP> MTU 1476 Qdisc NoOp
Link/gre 0.0.0.0 BRD 0.0.0.0
5: [Email protected]: <POINTOPOINT,NOARP,UP> MTU 1400 Qdisc noqueue
Link/gre 192.168.10.1 Peer 192.168.20.2
inet 172.16.1.1 Peer 172.16.1.2/30 Scope Global Tunnel0
[[Email protected] ~]# IP addr Show
1:lo: <LOOPBACK,UP,LOWER_UP> MTU 16436 Qdisc noqueue
Link/loopback 00:00:00:00:00:00 BRD 00:00:00:00:00:00
inet 127.0.0.1/8 Scope host Lo
INET6:: 1/128 Scope Host
Valid_lft Forever Preferred_lft Forever
2:eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU Qdisc pfifo_fast Qlen 1000
Link/ether 00:0c:29:08:48:63 BRD FF:FF:FF:FF:FF:FF
inet 192.168.20.2/24 BRD 192.168.20.255 Scope Global eth0
inet 202.100.2.2/30 BRD 202.100.2.3 Scope Global eth0:0
Inet6 FE80::20C:29FF:FE08:4863/64 Scope link
Valid_lft Forever Preferred_lft Forever
3:sit0: <NOARP> MTU 1480 Qdisc NoOp
Link/sit 0.0.0.0 BRD 0.0.0.0
4:GRE0: <NOARP> MTU 1476 Qdisc NoOp
Link/gre 0.0.0.0 BRD 0.0.0.0
5: [Email protected]: <POINTOPOINT,NOARP,UP,LOWER_UP> MTU 1400 Qdisc noqueue
Link/gre 192.168.20.2 Peer 192.168.10.1
inet 172.16.1.2 Peer 172.16.1.1/30 Scope Global Tunnel0
5. Effect test:
[[email protected] ~]# Ping 202.100.2.2
PING 202.100.2.2 (202.100.2.2) bytes of data.
Bytes from 202.100.2.2:icmp_seq=0 ttl=64 time=82.4 ms
Bytes from 202.100.2.2:icmp_seq=1 ttl=64 time=48.7 ms
---202.100.2.2 ping statistics---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
RTT Min/avg/max/mdev = 48.784/65.633/82.482/16.849 ms, pipe 2
This article is from the "Httpyuntianjxxll.spac.." Blog, make sure to keep this source http://333234.blog.51cto.com/323234/931805