ospf+lvs+fullnat 配置部署纪要
拓扑图如下::实验需求及目的:
通过ospf路由自动宣告功能来宣布LVS的VIP地址:192.168.0.111 使C1计算机能够通过网络不间断的访问192.168.0.111提供的WEB 访问服务。
实验结果:
在C1段的计算机节点ping VIP地址192.168.0.111 重启C2或者C3 这时候发现VIP不会断。
实验工具:
用gns3来模拟网络,用c7200模拟路由器R1和R2, 用C3600来模拟三层交换r3.
用VMware虚拟机来实现LVS 的loadblance调度 LVS1和LVS2
实验配置过程:
GNS3配置
1.加载镜像,点击edit-->ios IMAGES and hypervisors
加载镜像完成.
下面配置草C1其他PC的配置类似
注意C1在这里选择本地网卡,C2 C3 一定选择NET8
下面开始配置R1 R2R3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
R1的配置如下:
Router#sh running-config
Building configuration...
Current configuration : 1062 bytes
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
hostname Router
boot-start-marker
boot-end-marker
no aaa new-model
resource policy
ip subnet-zero
ip cef
no ip dhcp use vrf connected
no ip ips deny-action ips-interface
interface FastEthernet0/0
ip address 6.6.6.2 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 1.1.1.2 255.255.255.0
duplex auto
speed auto
!
interface Ethernet1/0
no ip address
shutdown
duplex half
!
interface Ethernet1/1
no ip address
shutdown
duplex half
!
interface Ethernet1/2
no ip address
shutdown
duplex half
!
interface Ethernet1/3
no ip address
shutdown
duplex half
!
router ospf 10
log-adjacency-changes
network 1.1.1.0 0.0.0.255 area 0
network 6.6.6.0 0.0.0.255 area 0
!
ip classless
no ip http server
no ip http secure-server
control-plane
gatekeeper
shutdown
line con 0
stopbits 1
line aux 0
line vty 0 4
end
R2的配置如下:
Router#sh running-config
Router#sh running-config
Building configuration...
Current configuration : 1062 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname Router
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
!
resource policy
!
ip subnet-zero
ip cef
!
!
no ip dhcp use vrf connected
!
!
no ip ips deny-action ips-interface
interface FastEthernet0/0
ip address 2.2.2.1 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 1.1.1.1 255.255.255.0
duplex auto
speed auto
!
interface Ethernet1/0
no ip address
shutdown
duplex half
!
interface Ethernet1/1
no ip address
shutdown
duplex half
!
interface Ethernet1/2
no ip address
shutdown
duplex half
!
interface Ethernet1/3
no ip address
shutdown
duplex half
!
router ospf 10
log-adjacency-changes
network 1.1.1.0 0.0.0.255 area 0
network 2.2.2.0 0.0.0.255 area 0
!
ip classless
no ip http server
no ip http secure-server
control-plane
gatekeeper
shutdown
line con 0
stopbits 1
line aux 0
line vty 0 4
!
!
end
#########################################################
R3的配置(三层交换的配置)
Router#sh running-config
Building configuration...
Current configuration : 1326 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname Router
!
boot-start-marker
boot-end-marker
no aaa new-model
memory-size iomem 5
ip cef
!
!
ip auth-proxy max-nodata-conns 3
ip admission max-nodata-conns 3
interface FastEthernet0/0
no switchport
ip address 2.2.2.2 255.255.255.0
!
interface FastEthernet0/1
switchport access vlan 2
!
interface FastEthernet0/2
switchport access vlan 2
!
interface FastEthernet0/3
!
interface FastEthernet0/4
!
interface FastEthernet0/5
!
interface FastEthernet0/6
!
interface FastEthernet0/7
!
interface FastEthernet0/8
!
interface FastEthernet0/9
!
interface FastEthernet0/10
!
interface FastEthernet0/11
!
interface FastEthernet0/12
!
interface FastEthernet0/13
!
interface FastEthernet0/14
!
interface FastEthernet0/15
!
interface Vlan1
no ip address
!
interface Vlan2
ip address 3.3.3.1 255.255.255.0
!
router ospf 10
log-adjacency-changes
network 2.2.2.0 0.0.0.255 area 0
network 3.3.3.0 0.0.0.255 area 0
!
no ip http server
no ip http secure-server
!
ip forward-protocol nd
!
!
mac-address-table static cc03.04c0.0000 interface FastEthernet0/2 vlan 1
control-plane
line con 0
line aux 0
line vty 0 4
login
end
分别查看R1R2 R3上的路由信息
R1:
Router#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, FastEthernet0/1
2.0.0.0/24 is subnetted, 1 subnets
O 2.2.2.0 via 1.1.1.1, 01:26:44, FastEthernet0/1
3.0.0.0/24 is subnetted, 1 subnets
O 3.3.3.0 via 1.1.1.1, 01:26:44, FastEthernet0/1
6.0.0.0/24 is subnetted, 1 subnets
C 6.6.6.0 is directly connected, FastEthernet0/0
192.168.0.0/32 is subnetted, 1 subnets
O 192.168.0.111 via 1.1.1.1, 01:26:44, FastEthernet0/1
R2:
Router#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, FastEthernet0/1
2.0.0.0/24 is subnetted, 1 subnets
C 2.2.2.0 is directly connected, FastEthernet0/0
3.0.0.0/24 is subnetted, 1 subnets
O 3.3.3.0 via 2.2.2.2, 01:27:12, FastEthernet0/0
6.0.0.0/24 is subnetted, 1 subnets
O 6.6.6.0 via 1.1.1.2, 01:27:12, FastEthernet0/1
192.168.0.0/32 is subnetted, 1 subnets
O 192.168.0.111 via 2.2.2.2, 01:27:12, FastEthernet0/0
R3:
Router#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
1.0.0.0/24 is subnetted, 1 subnets
O 1.1.1.0 via 2.2.2.1, 01:25:40, FastEthernet0/0
2.0.0.0/24 is subnetted, 1 subnets
C 2.2.2.0 is directly connected, FastEthernet0/0
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Vlan2
6.0.0.0/24 is subnetted, 1 subnets
O 6.6.6.0 via 2.2.2.1, 01:25:40, FastEthernet0/0
192.168.0.0/32 is subnetted, 1 subnets
O 192.168.0.111 via 3.3.3.8, 01:25:40, Vlan2
via 3.3.3.3, 01:25:42, Vlan2
下面是虚拟机的配置
虚拟机LVS1和2需要两个网卡1个走NET8模式一个走桥接模式
虚拟机首先安装quagga 包
yum -y install quaggakeepalived ipvsadm
LVS1和LVS2上都要安装
配置如下:
keepalived的配置:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# cat/etc/keepalived/keepalived.conf
vrrp_instance VI_2 {
interface eth3
virtual_router_id 11
priority 30
virtual_ipaddress {
192.168.0.111
}
}
virtual_server 192.168.0.111 80 {
delay_loop 6
lb_algo rr
lb_kind DR
protocol TCP
real_server 192.168.0.109 80 {
weight 10
inhibit_on_failure
TCP_CHECK {
connect_timeout 9
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
查看服务器上LV1或LVS2上的路由配置
最后 在拿一台电脑模仿PC客户端, 配置IP 6.6.6.3指定网管为6.6.6.2(R1的接口IP)
然后在该机器上ping192.168.0.111 重启lvs1 或者LV2VIP也不会断。
达到实验目的!!!
当然在起个虚拟机模仿也是可以的
页:
[1]