A-A+
基于华为交换机和路由器网络的简单搭建方法
下面基于几个华为的交换机和路由器进行一个小型组网,也包含了VLAN的划分,这次搭建运用到的技术包括以下8个:路由器中继 ip relay-address ,路由器snat dnat 转换,控制列表建立,路由器子接口vlan划分,交换机vlan划分,交换机端口设置trunk,Dhcp服务器配置,www服务器配置。
路由器的相关内容如何:
E1端口 192.168.101.23
路由器划分vlan和实现中继
- Int e0.1
- Vlan-type dot1q vid10
- Int e0.2
- Vlan-type dot1q vid20
- Ip relay-address192.168.30.3
- Int e0.1
- Ip relay-address192.168.30.3
路由器实现snat和dnat转换:
- acl 2000(建访问控制列表)
- rule permit source 192.168.30.0 0.0.0.255
- rule deny source any
- quit
- nat bound 2000 interface #(SNAT)
- inter e1
- nat server global 192.168.101.23 80 inside 192.168.30.3 80 tcp #(DNAT)
Linux作为dhcp服务器:
- subnet 192.168.10.0 netmask 255.255.255.0 {
- http://www.xiaoxiongboke.com
- # --- default gateway
- option routers 192.168.10.254;
- option subnet-mask 255.255.255.0;
- option nis-domain "domain.org";
- option domain-name "qqqq.com";
- option domain-name-servers 222.88.88.88;
- option time-offset -18000; # Eastern Standard Time
- # option ntp-servers 192.168.1.1;
- # option netbios-name-servers 192.168.1.1;
- # --- Selects point-to-point node (default is hybrid). Don't change this unless
- # -- you understand Netbios very well
- # option netbios-node-type 2;
- range dynamic-bootp 192.168.10.128 192.168.10.253;
- default-lease-time 21600;
- max-lease-time 43200;
- http://www.xiaoxiongboke.com
- # we want the nameserver to appear at a fixed address
- }
- subnet 192.168.20.0 netmask 255.255.255.0 {
- # --- default gateway
- option routers 192.168.20.254;
- option subnet-mask 255.255.255.0;
- option nis-domain "domain.org";
- option domain-name "www.com";
- option domain-name-servers 222.88.88.88;
- option time-offset -18000; # Eastern Standard Time
- # option ntp-servers 192.168.1.1;
- # option netbios-name-servers 192.168.1.1;
- # --- Selects point-to-point node (default is hybrid). Don't change this unless
- # -- you understand Netbios very well
- # option netbios-node-type 2;
- range dynamic-bootp 192.168.20.128 192.168.20.253;
- default-lease-time 21600;
- max-lease-time 43200;
- # we want the nameserver to appear at a fixed address
- }
- subnet 192.168.30.0 netmask 255.255.255.0 {
- # --- default gateway
- option routers 192.168.30.254;
- option subnet-mask 255.255.255.0;
- option nis-domain "domain.org";
- option domain-name "eee.com";
- option domain-name-servers 222.88.88.88;
- option time-offset -18000; # Eastern Standard Time
- # option ntp-servers 192.168.1.1;
- # option netbios-name-servers 192.168.1.1;
- # --- Selects point-to-point node (default is hybrid). Don't change this unless
- # -- you understand Netbios very well
- # option netbios-node-type 2;
- range dynamic-bootp 192.168.30.128 192.168.30.253;
- default-lease-time 21600;
- max-lease-time 43200;
- # we want the nameserver to appear at a fixed address
- }
www服务器配置方法如下:
在linux系统上安装www服务器
- [root@localhost ~]# mount /dev/cdrom /mnt/cdrom
- mount: block device /dev/cdrom is write-protected, mounting read-only
- [root@localhost ~]# cd /mnt/cdrom/Server
- [root@localhost Server]# ll httpd*
- -r--r--r-- 86 root root 1266575 Jul 27 2009 httpd-2.2.3-31.el5.i386.rpm
- -r--r--r-- 99 root root 150002 Jul 27 2009 httpd-devel-2.2.3-31.el5.i386.rpm
- -r--r--r-- 86 root root 830924 Jul 27 2009 httpd-manual-2.2.3-31.el5.i386.rpm
- [root@localhost Server]# rpm -ivh httpd-2.2.3-31.el5.i386.rpm
- warning: httpd-2.2.3-31.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
- Preparing... ########################################### [100%]
- 1:httpd ########################################### [100%]
手工编辑index.html文件如下:
- [root@localhost Server]# cd /var/www/html
- [root@localhost html]# ll
- total 0
- [root@localhost html]# touch index.html
- [root@localhost html]# vi index.html
- 写入内容;huanyingfangwen!
- [root@localhost html]# service httpd start
- Starting httpd: [ OK ]
- [root@localhost html]#
交换机1
14和18口设置为trunk
14路由器18交换机
E0/10为10网段
E0/20为20网段
E0/15为30网段
- [sw1]vlan 10
- [sw1-vlan10]port e0/10
- [sw1-vlan10]vlan 20
- [sw1-vlan20]port e0/20
- [sw1-vlan20]vlan 30
- [sw1-vlan30]port e0/15
- [sw1-Ethernet0/20]inter e0/14
- [sw1-Ethernet0/14]port link-type trunk
- [sw1-Ethernet0/20]inter e0/18
- [sw1-Ethernet0/18]port link-type trunk
交换机2
22端口trunk
E1/0/10为10网段
E1/0/20为20网段
E1/0/15为30网段
- [sw2-Ethernet1/0/22]quit
- [sw2]vlan 10
- [sw2-vlan10]port e1/0/10
- [sw2-vlan10]vlan 20
- [sw2-vlan20]port e1/0/20
- [sw2-vlan20]vlan 30
- [sw2-vlan30]e1/0/15
- ^
- % Unrecognized command found at '^' position.
- [sw2-vlan30]port e1/0/15
- [sw2-vlan30]
- [sw2]inter e1/0/22
- [sw2-Ethernet1/0/22]port link-type trunk
- [sw2-Ethernet1/0/22]port trunk permit vlan all
- Please wait........................................... Done.
然后找一台pc机接sw1 10端口测试是否能获得10.0地址。
再试20端口,交换机2也是如此。
测试www服务器,用此主机访问192.168.30.3