您的位置:首页 > 其它

三层交换机不同vlan口二层互联测试

2012-07-22 12:31 239 查看
1.拓扑图:





2.接口配置:

①R1、R2:

int f1/0

switchport mode trunk

int f1/1

switchport mode access

switchport access

switchport access vlan 10

int f1/15

switchport mode access

switchport access vlan 30

②R3、R4:

int f1/0

switchport mode trunk

int f1/1

switchport mode access

switchport access

switchport access vlan 20

int f1/15

switchport mode access

switchport access vlan 30

2.HSRP配置:

①R1:

int vlan 10

ip add 10.1.1.1 255.255.255.248

standby 10 ip 10.1.1.5

standby 10 priority 20

standby 10 preempt

standby 10 track fastEthernet 1/1 15

standby 10 authentication md5 key-string cisco

int vlan 30

ip add 192.168.1.1 255.255.255.0

standby 30 ip 192.168.1.254

standby 30 priority 20

standby 30 preempt

standby 30 track fastEthernet 1/1 15

standby 30 authentication md5 key-string cisco

②R2:

int vlan 10

ip add 10.1.1.2 255.255.255.248

standby 10 ip 10.1.1.5

standby 10 priority 10

standby 10 preempt

standby 10 track fastEthernet 1/1 15

standby 10 authentication md5 key-string cisco

int vlan 30

ip add 192.168.1.2 255.255.255.0

standby 30 ip 192.168.1.254

standby 30 priority 10

standby 30 preempt

standby 30 track fastEthernet 1/1 15

standby 30 authentication md5 key-string cisco

③R3:

int vlan 20

ip add 10.1.1.3 255.255.255.248

standby 20 ip 10.1.1.6

standby 20 priority 20

standby 20 preempt

standby 20 track fastEthernet 1/1 15

standby 20 authentication md5 key-string ciscocisco

int vlan 30

ip add 192.168.2.1 255.255.255.0

standby 30 ip 192.168.2.254

standby 30 priority 20

standby 30 preempt

standby 30 track fastEthernet 1/1 15

standby 30 authentication md5 key-string cisco

④R4:

int vlan 20

ip add 10.1.1.4 255.255.255.248

standby 20 ip 10.1.1.6

standby 20 priority 10

standby 20 preempt

standby 20 track fastEthernet 1/1 15

standby 20 authentication md5 key-string ciscocisco

int vlan 30

ip add 192.168.2.2 255.255.255.0

standby 30 ip 192.168.2.254

standby 30 priority 10

standby 30 preempt

standby 30 track fastEthernet 1/1 15

standby 30 authentication md5 key-string cisco

⑤验证HSRP状态

R1#show standby

Vlan10 - Group 10

State is Active

2 state changes, last state change 00:21:00

Virtual IP address is 10.1.1.5

Active virtual MAC address is 0000.0c07.ac0a

Local virtual MAC address is 0000.0c07.ac0a (v1 default)

Hello time 3 sec, hold time 10 sec

Next hello sent in 2.592 secs

Authentication MD5, key-string "cisco"

Preemption enabled

Active router is local

Standby router is 10.1.1.2, priority 10 (expires in 8.728 sec)

Priority 20 (configured 20)

IP redundancy name is "hsrp-Vl10-10" (default)

Vlan30 - Group 30

State is Active

2 state changes, last state change 00:10:58

Virtual IP address is 192.168.1.254

Active virtual MAC address is 0000.0c07.ac1e

Local virtual MAC address is 0000.0c07.ac1e (v1 default)

Hello time 3 sec, hold time 10 sec

Next hello sent in 1.060 secs

Authentication MD5, key-string "cisco"

Preemption enabled

Active router is local

Standby router is 192.168.1.2, priority 10 (expires in 7.740 sec)

Priority 20 (configured 20)

Track interface FastEthernet1/1 state Up decrement 10

IP redundancy name is "hsrp-Vl30-30" (default)

R1#

R2#show standby

Vlan10 - Group 10

State is Standby

1 state change, last state change 00:17:14

Virtual IP address is 10.1.1.5

Active virtual MAC address is 0000.0c07.ac0a

Local virtual MAC address is 0000.0c07.ac0a (v1 default)

Hello time 3 sec, hold time 10 sec

Next hello sent in 1.044 secs

Authentication MD5, key-string "cisco"

Preemption enabled

Active router is 10.1.1.1, priority 20 (expires in 9.924 sec)

Standby router is local

Priority 10 (configured 10)

IP redundancy name is "hsrp-Vl10-10" (default)

Vlan30 - Group 30

State is Standby

1 state change, last state change 00:11:01

Virtual IP address is 192.168.1.254

Active virtual MAC address is 0000.0c07.ac1e

Local virtual MAC address is 0000.0c07.ac1e (v1 default)

Hello time 3 sec, hold time 10 sec

Next hello sent in 1.992 secs

Authentication MD5, key-string "cisco"

Preemption enabled

Active router is 192.168.1.1, priority 20 (expires in 9.156 sec)

Standby router is local

Priority 10 (configured 10)

Track interface FastEthernet1/1 state Up decrement 10

IP redundancy name is "hsrp-Vl30-30" (default)

R2#

R3#show standby

Vlan20 - Group 20

State is Active

2 state changes, last state change 00:06:54

Virtual IP address is 10.1.1.6

Active virtual MAC address is 0000.0c07.ac14

Local virtual MAC address is 0000.0c07.ac14 (v1 default)

Hello time 3 sec, hold time 10 sec

Next hello sent in 2.064 secs

Authentication MD5, key-string "ciscocisco"

Preemption enabled

Active router is local

Standby router is 10.1.1.4, priority 10 (expires in 7.072 sec)

Priority 20 (configured 20)

IP redundancy name is "hsrp-Vl20-20" (default)

Vlan30 - Group 30

State is Active

2 state changes, last state change 00:06:54

Virtual IP address is 192.168.2.254

Active virtual MAC address is 0000.0c07.ac1e

Local virtual MAC address is 0000.0c07.ac1e (v1 default)

Hello time 3 sec, hold time 10 sec

Next hello sent in 2.372 secs

Authentication MD5, key-string "cisco"

Preemption enabled

Active router is local

Standby router is 192.168.2.2, priority 10 (expires in 8.684 sec)

Priority 20 (configured 20)

Track interface FastEthernet1/1 state Up decrement 10

IP redundancy name is "hsrp-Vl30-30" (default)

R3#

R4#show standby

Vlan20 - Group 20

State is Standby

1 state change, last state change 00:06:22

Virtual IP address is 10.1.1.6

Active virtual MAC address is 0000.0c07.ac14

Local virtual MAC address is 0000.0c07.ac14 (v1 default)

Hello time 3 sec, hold time 10 sec

Next hello sent in 1.740 secs

Authentication MD5, key-string "ciscocisco"

Preemption enabled

Active router is 10.1.1.3, priority 20 (expires in 7.792 sec)

Standby router is local

Priority 10 (configured 10)

IP redundancy name is "hsrp-Vl20-20" (default)

Vlan30 - Group 30

State is Standby

1 state change, last state change 00:06:21

Virtual IP address is 192.168.2.254

Active virtual MAC address is 0000.0c07.ac1e

Local virtual MAC address is 0000.0c07.ac1e (v1 default)

Hello time 3 sec, hold time 10 sec

Next hello sent in 2.084 secs

Authentication MD5, key-string "cisco"

Preemption enabled

Active router is 192.168.2.1, priority 20 (expires in 9.268 sec)

Standby router is local

Priority 10 (configured 10)

Track interface FastEthernet1/1 state Up decrement 10

IP redundancy name is "hsrp-Vl30-30" (default)

R4#

3.静态路由配置:

①R1、R2:

ip route 192.168.2.0 255.255.255.0 10.1.1.6

②R3、R4:

ip route 192.168.1.0 255.255.255.0 10.1.1.5

③测试

R1#ping 192.168.2.254 source 192.168.1.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.2.254, timeout is 2 seconds:

Packet sent with a source address of 192.168.1.1

.!!!!

Success rate is 80 percent (4/5), round-trip min/avg/max = 20/32/44 ms

R1#

R1#traceroute 192.168.2.254 source 192.168.1.1

Type escape sequence to abort.

Tracing the route to 192.168.2.254

1 10.1.1.3 56 msec * 40 msec

4.LINUX主机双网卡bonding配置:

参考:http://candon123.blog.51cto.com/704299/402677

①LINUX1:

A.编辑虚拟网卡band0的配置文件ifcfg-bond0,加入以下内容:

[root@Linux1~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0

# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]

DEVICE=bond0

ONBOOT=yes

BOOTPROTO=none

IPADDR=192.168.1.8

BROADCAST=192.168.1.255

NETMASK=255.255.255.0

NETWORK=192.168.1.0

GATEWAY=192.168.1.254

USERCTL=no

B、编辑eth0和eth1网卡的配置文件

[root@Linux1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0

# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]

DEVICE=eth0

ONBOOT=yes

BOOTPROTO=none

HWADDR=00:0c:29:e4:65:78

TYPE=Ethernet

MASTER=bond0

SLAVE=yes

PEERDNS=yes

USERCTL=no

IPV6INIT=no

[root@Linux1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1

# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]

DEVICE=eth1

ONBOOT=yes

BOOTPROTO=none

HWADDR=00:0c:29:e4:65:82

TYPE=Ethernet

MASTER=bond0

SLAVE=yes

USERCTL=no

IPV6INIT=no

PEERDNS=yes

C、修改/etc/modprobe.conf 文件,加入以下内容:

alias bond0 bonding

options bond0 miimon=100 mode=1

注:

(1)、miimon 是链路监测的时间间隔单位是毫秒,miimon=100的意思就是,每100毫秒检测网卡和交换机之间是否连通,如不通则使用另外的链路。

(2)、mode=0 表示负载均衡方式,两块网卡都工作,需要交换机作支持。

mode=1 表示冗余方式,网卡只有一个工作,一个出问题启用另外的。

mode=6 表示负载均衡方式,两块网卡都工作,不需要交换机作支持。

D、重启网络:

# service network restart

E、查看bond0的工作状态:

[root@Linux1~]# more /proc/net/bonding/bond0

Ethernet Channel Bonding Driver: v2.6.3-rh (June 8, 2005)

Bonding Mode: fault-tolerance (active-backup)

Primary Slave: None

Currently Active Slave: eth0

MII Status: up

MII Polling Interval (ms): 100

Up Delay (ms): 0

Down Delay (ms): 0

Slave Interface: eth0

MII Status: up

Link Failure Count: 0

Permanent HW addr: 00:0c:29:e4:65:78

Slave Interface: eth1

MII Status: up

Link Failure Count: 0

Permanent HW addr: 00:0c:29:e4:65:82

F、查看绑定后的结果:

[root@Linux1~]# ifconfig -a

bond0 Link encap:Ethernet HWaddr 00:0C:29:E4:65:78

inet addr:192.168.1.8 Bcast:192.168.1.255 Mask:255.255.255.0

inet6 addr: fe80::20c:29ff:fee4:6578/64 Scope:Link

UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1

RX packets:874 errors:0 dropped:0 overruns:0 frame:0

TX packets:685 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:74567 (72.8 KiB) TX bytes:62797 (61.3 KiB)

eth0 Link encap:Ethernet HWaddr 00:0C:29:E4:65:78

UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1

RX packets:805 errors:0 dropped:0 overruns:0 frame:0

TX packets:694 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:67571 (65.9 KiB) TX bytes:64199 (62.6 KiB)

Interrupt:185 Base address:0x2024

eth1 Link encap:Ethernet HWaddr 00:0C:29:E4:65:78

UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1

RX packets:74 errors:0 dropped:0 overruns:0 frame:0

TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:7296 (7.1 KiB) TX bytes:0 (0.0 b)

Interrupt:177 Base address:0x20a4

lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

inet6 addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:10 errors:0 dropped:0 overruns:0 frame:0

TX packets:10 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:760 (760.0 b) TX bytes:760 (760.0 b)

sit0 Link encap:IPv6-in-IPv4

NOARP MTU:1480 Metric:1

RX packets:0 errors:0 dropped:0 overruns:0 frame:0

TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

[root@AMS ~]#

②LINUX2

A.编辑虚拟网卡band0的配置文件ifcfg-bond0,加入以下内容:

[root@Linux2 ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0

# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]

DEVICE=bond0

BOOTPROTO=none

ONBOOT=yes

NETMASK=255.255.255.0

IPADDR=192.168.2.8

BROADCAST=192.168.2.255

GATEWAY=192.168.2.254

NETWORK=192.168.2.0

USERCTL=no

B、编辑eth0和eth1网卡的配置文件

[root@Linux2 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0

# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]

DEVICE=eth0

BOOTPROTO=none

ONBOOT=yes

HWADDR=00:0c:29:08:48:63

TYPE=Ethernet

USERCTL=no

MASTER=bond0

SLAVE=yes

[root@Linux2 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1

# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]

DEVICE=eth1

BOOTPROTO=none

ONBOOT=yes

HWADDR=00:0c:29:08:48:6d

MASTER=bond0

SLAVE=yes

C、修改/etc/modprobe.conf 文件,加入以下内容:

alias bond0 bonding

options bond0 miimon=100 mode=1

D、重启网络:

# service network restart

E、查看bond0的工作状态:

[root@Linux2 ~]# more /proc/net/bonding/bond0

Ethernet Channel Bonding Driver: v3.4.0 (October 7, 2008)

Bonding Mode: fault-tolerance (active-backup)

Primary Slave: None

Currently Active Slave: eth0

MII Status: up

MII Polling Interval (ms): 100

Up Delay (ms): 0

Down Delay (ms): 0

Slave Interface: eth0

MII Status: up

Link Failure Count: 0

Permanent HW addr: 00:0c:29:08:48:63

Slave Interface: eth1

MII Status: up

Link Failure Count: 0

Permanent HW addr: 00:0c:29:08:48:6d

F、查看绑定后的结果:

Permanent HW addr: 00:0c:29:08:48:6d

[root@Linux2 ~]# ifconfig -a

bond0 Link encap:Ethernet HWaddr 00:0C:29:08:48:63

inet addr:192.168.2.8 Bcast:192.168.2.255 Mask:255.255.255.0

inet6 addr: fe80::20c:29ff:fe08:4863/64 Scope:Link

UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1

RX packets:233 errors:0 dropped:0 overruns:0 frame:0

TX packets:217 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:18827 (18.3 KiB) TX bytes:25194 (24.6 KiB)

eth0 Link encap:Ethernet HWaddr 00:0C:29:08:48:63

UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1

RX packets:165 errors:0 dropped:0 overruns:0 frame:0

TX packets:226 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:14171 (13.8 KiB) TX bytes:26596 (25.9 KiB)

Interrupt:75 Base address:0x2000

eth1 Link encap:Ethernet HWaddr 00:0C:29:08:48:63

UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1

RX packets:73 errors:0 dropped:0 overruns:0 frame:0

TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:4956 (4.8 KiB) TX bytes:0 (0.0 b)

Interrupt:59 Base address:0x2080

lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

inet6 addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:104 errors:0 dropped:0 overruns:0 frame:0

TX packets:104 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:13740 (13.4 KiB) TX bytes:13740 (13.4 KiB)

sit0 Link encap:IPv6-in-IPv4

NOARP MTU:1480 Metric:1

RX packets:0 errors:0 dropped:0 overruns:0 frame:0

TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

6.测试配置:

①正常状态

[root@Linux1 ~]# ping 192.168.2.8

PING 192.168.2.8 (192.168.2.8) 56(84) bytes of data.

64 bytes from 192.168.2.8: icmp_seq=1 ttl=62 time=55.1 ms

64 bytes from 192.168.2.8: icmp_seq=2 ttl=62 time=43.0 ms

--- 192.168.2.8 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1599ms

rtt min/avg/max/mdev = 43.047/49.103/55.160/6.060 ms

[root@Linux1 ~]# traceroute 192.168.2.8

traceroute to 192.168.2.8 (192.168.2.8), 30 hops max, 40 byte packets

1 (192.168.1.1) 176.939 ms 184.770 ms 194.904 ms

2 (10.1.1.3) 215.089 ms 226.090 ms 235.590 ms

3 (192.168.2.8) 246.020 ms 256.903 ms 270.429 ms

[root@Linux2 ~]# ping 192.168.1.8

PING 192.168.1.8 (192.168.1.8) 56(84) bytes of data.

64 bytes from 192.168.1.8: icmp_seq=0 ttl=62 time=41.0 ms

--- 192.168.1.8 ping statistics ---

2 packets transmitted, 1 received, 50% packet loss, time 1002ms

rtt min/avg/max/mdev = 41.081/41.081/41.081/0.000 ms, pipe 2

[root@Linux2 ~]# traceroute 192.168.1.8

traceroute to 192.168.1.8 (192.168.1.8), 30 hops max, 38 byte packets

1 192.168.2.1 (192.168.2.1) 17.759 ms 27.659 ms 11.916 ms

2 10.1.1.1 (10.1.1.1) 84.242 ms 46.798 ms 41.362 ms

3 192.168.1.8 (192.168.1.8) 65.179 ms 45.004 ms 46.726 ms

②删除R1和R3互联的线路,并且关闭接口,从日志中可以看出交换机主备发生了切换:

R1(config-if)#

*Mar 1 02:36:22.991: %HSRP-5-STATECHANGE: Vlan10 Grp 10 state Active -> Speak

R1(config-if)#int vlan 20

R1(config-if)#t

*Mar 1 02:36:32.987: %HSRP-5-STATECHANGE: Vlan10 Grp 10 state Speak -> Standby

R1(config-if)#

*Mar 1 02:37:34.891: %HSRP-5-STATECHANGE: Vlan30 Grp 30 state Active -> Speak

R1(config-if)#

*Mar 1 02:37:44.891: %HSRP-5-STATECHANGE: Vlan30 Grp 30 state Speak -> Standby

R1(config-if)#

R2#

*Mar 1 00:29:40.651: %HSRP-5-STATECHANGE: Vlan10 Grp 10 state Speak -> Standby

R2(config-if)#

*Mar 1 00:35:53.687: %HSRP-5-STATECHANGE: Vlan30 Grp 30 state Speak -> Standby

R2#

*Mar 1 02:33:53.935: %HSRP-5-STATECHANGE: Vlan10 Grp 10 state Standby -> Active

R2#

*Mar 1 02:35:05.835: %HSRP-5-STATECHANGE: Vlan30 Grp 30 state Standby -> Active

R2#

R3(config-if)#

*Mar 1 02:36:00.499: %HSRP-5-STATECHANGE: Vlan20 Grp 20 state Active -> Speak

R3(config-if)#int vlan 30

R3(config-if)#st

R3(config-if)#standby

*Mar 1 02:36:10.499: %HSRP-5-STATECHANGE: Vlan20 Grp 20 state Speak -> Standby

R3(config-if)#standby 30 t

R3(config-if)#standby 30 tr

R3(config-if)#standby 30 track f

R3(config-if)#standby 30 track fastEthernet 1/1 15

R3(config-if)#

*Mar 1 02:36:20.255: %HSRP-5-STATECHANGE: Vlan30 Grp 30 state Active -> Speak

R3(config-if)#

*Mar 1 02:36:30.255: %HSRP-5-STATECHANGE: Vlan30 Grp 30 state Speak -> Standby

R4#

*Mar 1 02:18:42.407: %HSRP-5-STATECHANGE: Vlan20 Grp 20 state Standby -> Active

R4#

*Mar 1 02:19:20.379: %HSRP-5-STATECHANGE: Vlan20 Grp 20 state Active -> Speak

R4#

*Mar 1 02:19:30.375: %HSRP-5-STATECHANGE: Vlan20 Grp 20 state Speak -> Standby

R4#

R4#

R4#

*Mar 1 02:34:16.159: %HSRP-5-STATECHANGE: Vlan20 Grp 20 state Standby -> Active

R4#

*Mar 1 02:34:35.899: %HSRP-5-STATECHANGE: Vlan30 Grp 30 state Standby -> Active

③再次traceroute,确认路径也发生了变化:

[root@Linux1 ~]# traceroute 192.168.2.8

traceroute to 192.168.2.8 (192.168.2.8), 30 hops max, 40 byte packets

1 (192.168.1.2) 196.404 ms 204.818 ms 213.794 ms

2 (10.1.1.4) 228.587 ms 272.285 ms 278.259 ms

3 (192.168.2.1) 251.404 ms (192.168.2.8) 305.621 ms 328.609 ms

[root@Linux1 ~]#

[root@Linux2 ~]# traceroute 192.168.1.8

traceroute to 192.168.1.8 (192.168.1.8), 30 hops max, 38 byte packets

1 192.168.2.2 (192.168.2.2) 64.399 ms 51.977 ms 10.650 ms

2 10.1.1.2 (10.1.1.2) 68.322 ms 42.056 ms 64.082 ms

3 192.168.1.1 (192.168.1.1) 69.768 ms 192.168.1.8 (192.168.1.8) 72.562 ms 61.597 ms

[root@Linux2 ~]#

附件:http://down.51cto.com/data/2361062
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  vlan switch