A-A+

基于华为交换机和路由器网络的简单搭建方法

2015年11月20日 站长资讯 暂无评论

下面基于几个华为的交换机和路由器进行一个小型组网,也包含了VLAN的划分,这次搭建运用到的技术包括以下8个:路由器中继 ip relay-address ,路由器snat dnat 转换,控制列表建立,路由器子接口vlan划分,交换机vlan划分,交换机端口设置trunk,Dhcp服务器配置,www服务器配置。

路由器的相关内容如何:

E1端口 192.168.101.23

路由器划分vlan和实现中继

  1. Int e0.1  
  2. Vlan-type dot1q vid10  
  3. Int e0.2  
  4. Vlan-type dot1q vid20  
  5. Ip relay-address192.168.30.3  
  6. Int e0.1  
  7. Ip relay-address192.168.30.3  

路由器实现snat和dnat转换:

  1. acl 2000(建访问控制列表)  
  2. rule permit source 192.168.30.0 0.0.0.255  
  3. rule deny source any  
  4. quit  
  5. nat bound 2000 interface   #(SNAT)  
  6. inter e1  
  7. nat server global 192.168.101.23 80 inside 192.168.30.3 80 tcp    #(DNAT)  

Linux作为dhcp服务器:

  1. subnet 192.168.10.0 netmask 255.255.255.0 {  
  2.  http://www.xiaoxiongboke.com   
  3. # --- default gateway  
  4.         option routers                  192.168.10.254;  
  5.         option subnet-mask              255.255.255.0;  
  6.    
  7.         option nis-domain               "domain.org";  
  8.         option domain-name              "qqqq.com";  
  9.         option domain-name-servers      222.88.88.88;  
  10.    
  11.         option time-offset              -18000; # Eastern Standard Time  
  12. #       option ntp-servers              192.168.1.1;  
  13. #       option netbios-name-servers     192.168.1.1;  
  14. # --- Selects point-to-point node (default is hybrid). Don't change this unless  
  15. # -- you understand Netbios very well  
  16. #       option netbios-node-type 2;  
  17.    
  18.         range dynamic-bootp 192.168.10.128 192.168.10.253;  
  19.         default-lease-time 21600;  
  20.         max-lease-time 43200;  
  21.         http://www.xiaoxiongboke.com  
  22.         # we want the nameserver to appear at a fixed address  
  23.    
  24. }  
  25.    
  26. subnet 192.168.20.0 netmask 255.255.255.0 {  
  27.    
  28. # --- default gateway  
  29.         option routers                  192.168.20.254;  
  30.         option subnet-mask              255.255.255.0;  
  31.    
  32.         option nis-domain               "domain.org";  
  33.         option domain-name              "www.com";  
  34.         option domain-name-servers      222.88.88.88;  
  35.    
  36.         option time-offset              -18000; # Eastern Standard Time  
  37. #       option ntp-servers              192.168.1.1;  
  38. #       option netbios-name-servers     192.168.1.1;  
  39. # --- Selects point-to-point node (default is hybrid). Don't change this unless  
  40. # -- you understand Netbios very well  
  41. #       option netbios-node-type 2;  
  42.    
  43.         range dynamic-bootp 192.168.20.128 192.168.20.253;  
  44.         default-lease-time 21600;  
  45.         max-lease-time 43200;  
  46.    
  47.         # we want the nameserver to appear at a fixed address  
  48. }  
  49.    
  50. subnet 192.168.30.0 netmask 255.255.255.0 {  
  51.    
  52. # --- default gateway  
  53.         option routers                  192.168.30.254;  
  54.         option subnet-mask              255.255.255.0;  
  55.    
  56.         option nis-domain               "domain.org";  
  57.         option domain-name              "eee.com";  
  58.         option domain-name-servers      222.88.88.88;  
  59.    
  60.         option time-offset              -18000; # Eastern Standard Time  
  61. #       option ntp-servers              192.168.1.1;  
  62. #       option netbios-name-servers     192.168.1.1;  
  63. # --- Selects point-to-point node (default is hybrid). Don't change this unless  
  64. # -- you understand Netbios very well  
  65. #       option netbios-node-type 2;  
  66.    
  67.         range dynamic-bootp 192.168.30.128 192.168.30.253;  
  68.         default-lease-time 21600;  
  69.         max-lease-time 43200;  
  70.    
  71.         # we want the nameserver to appear at a fixed address  
  72. }  

www服务器配置方法如下:

在linux系统上安装www服务器

  1. [root@localhost ~]# mount /dev/cdrom /mnt/cdrom  
  2. mount: block device /dev/cdrom is write-protected, mounting read-only  
  3. [root@localhost ~]# cd /mnt/cdrom/Server  
  4. [root@localhost Server]# ll httpd*  
  5. -r--r--r-- 86 root root 1266575 Jul 27 2009 httpd-2.2.3-31.el5.i386.rpm  
  6. -r--r--r-- 99 root root 150002 Jul 27 2009 httpd-devel-2.2.3-31.el5.i386.rpm  
  7. -r--r--r-- 86 root root 830924 Jul 27 2009 httpd-manual-2.2.3-31.el5.i386.rpm  
  8. [root@localhost Server]# rpm -ivh httpd-2.2.3-31.el5.i386.rpm  
  9. warning: httpd-2.2.3-31.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186  
  10. Preparing...                ########################################### [100%]  
  11.    1:httpd                  ########################################### [100%]  

手工编辑index.html文件如下:

  1. [root@localhost Server]# cd /var/www/html  
  2. [root@localhost html]# ll  
  3. total 0  
  4. [root@localhost html]# touch index.html  
  5. [root@localhost html]# vi index.html  
  6. 写入内容;huanyingfangwen!  
  7. [root@localhost html]# service httpd start  
  8. Starting httpd:                                            [ OK ]  
  9. [root@localhost html]#  

交换机1

14和18口设置为trunk

14路由器18交换机

E0/10为10网段

E0/20为20网段

E0/15为30网段

  1. [sw1]vlan 10  
  2. [sw1-vlan10]port e0/10  
  3. [sw1-vlan10]vlan 20  
  4. [sw1-vlan20]port e0/20  
  5. [sw1-vlan20]vlan 30  
  6. [sw1-vlan30]port e0/15  
  7. [sw1-Ethernet0/20]inter e0/14  
  8. [sw1-Ethernet0/14]port link-type trunk  
  9. [sw1-Ethernet0/20]inter e0/18  
  10. [sw1-Ethernet0/18]port link-type trunk  

交换机2

22端口trunk

E1/0/10为10网段

E1/0/20为20网段

E1/0/15为30网段

  1. [sw2-Ethernet1/0/22]quit  
  2. [sw2]vlan 10  
  3. [sw2-vlan10]port e1/0/10  
  4. [sw2-vlan10]vlan 20  
  5. [sw2-vlan20]port e1/0/20  
  6. [sw2-vlan20]vlan 30  
  7. [sw2-vlan30]e1/0/15  
  8.             ^  
  9.  % Unrecognized command found at '^' position.  
  10. [sw2-vlan30]port e1/0/15  
  11. [sw2-vlan30]  
  12. [sw2]inter e1/0/22  
  13. [sw2-Ethernet1/0/22]port link-type trunk  
  14. [sw2-Ethernet1/0/22]port trunk permit vlan all  
  15.  Please wait........................................... Done.  

然后找一台pc机接sw1 10端口测试是否能获得10.0地址。

再试20端口,交换机2也是如此。

测试www服务器,用此主机访问192.168.30.3

标签:

给我留言