小型网络拓扑配置
要求:
硬件:路由器一个,交换机二个,服务器一个,主机若干
1. 在交换机switch1上配置vlan10,vlan20,vlan30
2. 在交换机switch2上配置vlan10,vlan20
3. 划分ip网段,vlan10分配网段192.168.10.0
Vlan20分配网段192.168.20.0
Vlan30划分网段192.168.30.0
4. 服务器在vlan 30中,ip地址为192.168.30.2
5. 在服务器上配置dhcp服务器,对两个都交换机上vlan10与vlan20进行动态ip地址获取。
6. 在路由器上做snat地址转换,使内网用户可以使用外网
7. 在路由器上做dnat地址转换,使外网用户可以访问www服务器
配置
一.拓扑图
一.在路由器Router上进行配置
1.在e1上配置单臂路由
[R1]int e1.1
[R1-Ethernet1.1]vlan-type dot1q vid 10
[R1-Ethernet1.1]ip address 192.168.10.254 24
[R1-Ethernet1.1]
%01:07:04: Line protocol ip on the interface Ethernet1.1 is UP
[R1-Ethernet1.1]
[R1-Ethernet1.1]int e1.2
[R1-Ethernet1.2]vlan-type dot1q vid 20
[R1-Ethernet1.2]ip address 192.168.20.254 24
[R1-Ethernet1.2]
%01:07:38: Line protocol ip on the interface Ethernet1.2 is UP
[R1-Ethernet1.2]
[R1-Ethernet1.2]int e1.3
[R1-Ethernet1.3]vlan-type dot1q vid 30
[R1-Ethernet1.3]ip address 192.168.30.254 24
[R1-Ethernet1.3]
%01:08:10: Line protocol ip on the interface Ethernet1.3 is UP
[R1-Ethernet1.3]
2.配置telnet,方便管理
[R1]local-user user password cipher 123 service-type admin
[Router]int e1
[R1-Ethernet1]ip address 192.168.101.188 24
3.配置e0 ip地址,由于e0是连接外网的,ip地址要配置成外网的网段。
[Router]int e0
[Router-Ethernet0]ip address 192.168.101.188 24
[Router-Ethernet0]
4.因为我们内网的用户要访问外网,并且,外网用户也要访问内网的www服务器,所以要配置nat
首先要让内网用户访问外网,在路由器上配置Snat
[Router]acl 2000
[Router-acl-2000]rule permit source 192.168.20.0 0.0.0.255
Rule has been added to normal packet-filtering rules
[Router-acl-2000]rule permit source 192.168.10.0 0.0.0.255
Rule has been added to normal packet-filtering rules
[Router-acl-2000]
%01:32:52: Interface Serial0 is DOWN
[Router-acl-2000]rule permit source 192.168.30.0 0.0.0.255
Rule has been added to normal packet-filtering rules
[Router-acl-2000]rule deny source any
[Router-acl-2000]int e0
[Router-Ethernet0]nat outbound 2000 interface
外网用户访问内网www服务器,配置dnat
[Router]int e0
[Router-Ethernet0]nat server global 192.168.101.188 80 inside 192.168.30.2 80 tcp
5.因为不同vlan的数据包不能经过路由器,所以要让vlan10与vlan20的用户 能够动态的获取由vlan30提供的ip地址,要在路由器上配置DHCP中继。
[Router-Ethernet1]int e1.1
[Router-Ethernet1.1]ip relay-address 192.168.30.2
[Router-Ethernet1.1]int e1.2
[Router-Ethernet1.2]ip relay-address 192.168.30.2
二.在switch1上配置代码
1.划分vlan,并分配端口
[Quidway]vlan 10
[Quidway-vlan10]int e0/11
[Quidway-Ethernet0/11]quit
[Quidway]vlan 10
[Quidway-vlan10]port e0/11
[Quidway-vlan10]vlan 20
[Quidway-vlan20]port e0/6
[Quidway-vlan20]vlan 30
[Quidway-vlan30]port e0/2
[Quidway-vlan30]quit
在端口22与端口21上配置trunk口
[Quidway-Ethernet0/1]int e0/22
[Quidway-Ethernet0/22]port link-type trunk
[Quidway-Ethernet0/22]port trunk permit vlan all
Please wait........................................... Done.
[Quidway-Ethernet0/22]
[Quidway]int e0/21
[Quidway-Ethernet0/21]port link-type trunk
[Quidway-Ethernet0/21]port trunk permit vlan all
Please wait........................................... Done.
[Quidway-Ethernet0/21]
三.在交换机Switch2上配置代码,
1.配置vlan ,并加入端口
[sw1]vlan 10
[sw1-vlan10]port e1/0/8
[sw1-vlan10]vlan 20
[sw1-vlan20]port e1/0/9
2.在端口21上配置trunk口
[Quidway]int e0/21
[sw1-Ethernet1/0/21]port link-type trunk
[sw1-Ethernet1/0/21]port trunk permit vlan all
Please wait........................................... Done.
[sw1-Ethernet1/0/21]
四.服务器的配置
Dhcp服务器
安装文件
[root@localhost mnt]# cd /mnt/cdrom/Server/
[root@localhost Server]# rpm -ivh dhcp-3.0.5-21.el5.i386.rpm
主配置文件
Vim /etc/dhcpd.conf 修改如下
ddns-update-style interim;
ignore client-updates;
option routers 192.168.10.254;
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option domain-name-servers 222.88.88.88;
range dynamic-bootp 192.168.10.128 192.168.10.254;
default-lease-time 21600;
max-lease-time 43200;
}
subnet 192.168.20.0 netmask 255.255.255.0 {
option routers 192.168.20.254;
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option domain-name-servers 222.88.88.88;
option time-offset -18000; # Eastern Standard Time
range dynamic-bootp 192.168.20.128 192.168.20.254;
default-lease-time 21600;
max-lease-time 43200;
}
启动dhcp服务器
[root@localhost html]# service dhcpd start
启动 dhcpd: [确定]
Web服务器
安装软件httpd
[root@localhost ~]# cd /mnt/cdrom/Server/
[root@localhost Server]# rpm -ivh httpd-2.2.3-31.el5.i386.rpm
在/var/www/html/中新建一个文件index.html
[root@localhost html]# vim index.html
添加如下内容
bei jing huan ying ni
启动www服务器
[root@localhost html]# service httpd start
启动 httpd: [确定]
五.测试
在switch2的端口e0/8上连接一台主机,进行客户端的测试
1.测试是否能够获取ip地址。
可以正确获取192.168.10.0网段的ip地址
2.用此客户端访问www服务器。
3.使用外网用户访问www服务器
测试成功。