在当前的网络环境中,网络互联访问往往需要通过公网上的DNS服务器的辅助以及网络映射从而达到互联访问的目的。本次介绍如何创建两个公司通过互联网进行互联访问的网络配置。
设计主体为公司内部进行通信,各个主机可通过IP地址访问本公司内的服务器,其他公司可通过域名访问本公司服务器。公网互联网采用静态路由配置。
公司B与公司A配置相同
首先按针对各个路由器及其各个端口分配ip地址
R6
Router>enable
Password:
outer#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int gigabitEthernet 0/2
Router(config-if)#ip address 12.12.12.1 255.255.255.0
Router(config)#int gigabitEthernet 0/0
Router(config-if)#ip address 192.168.10.2 255.255.255.0
Router(config)#int gigabitEthernet 0/1
Router(config-if)#ip address 13.13.13.1 255.255.255.0
Router#show ip interface brief
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0 192.168.10.2 YES manual up up
GigabitEthernet0/1 13.13.13.1 YES manual up up
GigabitEthernet0/2 12.12.12.1 YES manual up up
Vlan1 unassigned YES unset administratively down down
R1
Router>enable
Password:
outer#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int gigabitEthernet 0/1
Router(config-if)#ip address 12.12.12.2 255.255.255.0
Router(config)#int gigabitEthernet 0/0
Router(config-if)#ip address 23.23.23.1 255.255.255.0
Router#show ip interface brief
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0 23.23.23.1 YES manual up up
GigabitEthernet0/1 12.12.12.2 YES manual up up
Vlan1 unassigned YES unset administratively down down
R2
Router>enable
Password:
outer#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int gigabitEthernet 0/1
Router(config-if)#ip address 34.34.34.1 255.255.255.0
Router(config)#int gigabitEthernet 0/0
Router(config-if)#ip address 13.13.13.2 255.255.255.0
Router#show ip interface brief
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0 13.13.13.2 YES manual up up
GigabitEthernet0/1 34.34.34.1 YES manual up up
Vlan1 unassigned YES unset administratively down down
R15
Router>enable
Password:
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int gigabitEthernet 0/1
Router(config-if)#ip address 23.23.23.2 255.255.255.0
Router(config)#int gigabitEthernet 0/0
Router(config-if)#ip address 34.34.34.2 255.255.255.0
Router(config-if)#exit
Router#vlan database
% Warning: It is recommended to configure VLAN from config mode,
as VLAN database mode is being deprecated. Please consult user
documentation for configuring VTP/VLAN in config mode.
Router(vlan)#vlan 10
VLAN 10 added:
Name: VLAN0010
Router(vlan)#vlan 20
VLAN 20 added:
Name: VLAN0020
Router(vlan)#exit
Router#configure terminal
Router(config)#int vlan10
Router(config-if)#ip address 8.8.8.9 255.255.255.0
Router(config)#int vlan20
Router(config-if)#ip address 45.45.45.2 255.255.255.0
Router(config)#int f 0/0/1
Router(config-if)#switchport mode access
Router(config-if)#switchport access vlan 10
Router(config)#int f 0/0/0
Router(config-if)#switchport mode access
Router(config-if)#switchport access vlan 20
Router#show ip interface brief
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0 34.34.34.2 YES manual up up
GigabitEthernet0/1 23.23.23.2 YES manual up up
FastEthernet0/0/0 unassigned YES unset up up
FastEthernet0/0/1 unassigned YES unset up up
FastEthernet0/0/2 unassigned YES unset up down
FastEthernet0/0/3 unassigned YES unset up down
Vlan1 unassigned YES unset administratively down down
Vlan10 8.8.8.9 YES manual up up
Vlan20 45.45.45.2 YES manual up up
R4
Router>enable
Password:
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int gigabitEthernet 0/1
Router(config-if)#ip address 192.168.10.2 255.255.255.0
Router(config)#int gigabitEthernet 0/0
Router(config-if)#ip address 45.45.45.1 255.255.255.0
Router#show ip interface brief
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0 45.45.45.1 YES manual up up
GigabitEthernet0/1 192.168.10.2 YES manual up up
Vlan1 unassigned YES unset administratively down down
接下来就是公网静态路由的配置
R6
Router(config)#ip route 23.23.23.0 255.255.255.0 12.12.12.2
Router(config)#ip route 34.34.34.0 255.255.255.0 13.13.13.2
Router(config)#ip route 8.8.8.0 255.255.255.0 12.12.12.2 10
Router(config)#ip route 8.8.8.0 255.255.255.0 13.13.13.2 20
Router(config)#ip route 45.45.45.0 255.255.255.0 12.12.12.2 10
Router(config)#ip route 45.45.45.0 255.255.255.0 13.13.13.2 20
R1
Router(config)#ip route 13.13.13.0 255.255.255.0 12.12.12.1
Router(config)#ip route 34.34.34.0 255.255.255.0 23.23.23.2
Router(config)#ip route 8.8.8.0 255.255.255.0 23.23.23.2
Router(config)#ip route 45.45.45.0 255.255.255.0 23.23.23.2
R2
Router(config)#ip route 12.12.12.0 255.255.255.0 13.13.13.1
Router(config)#ip route 23.23.23.0 255.255.255.0 34.34.34.2
Router(config)#ip route 8.8.8.0 255.255.255.0 34.34.34.2
Router(config)#ip route 45.45.45.0 255.255.255.0 34.34.34.2
R15
Router(config)#ip route 12.12.12.0 255.255.255.0 23.23.23.1
Router(config)#ip route 13.13.13.0 255.255.255.0 34.34.34.1
R4
Router(config)#ip route 0.0.0.0 0.0.0.0 45.45.45.2
以上我们的公网IP和路由就配置完毕
首先针对主机分配IP地址及vlan
主机 | IP及vlan |
---|---|
pc0 | 192.168.1.1 ---- vlan10 |
pc1 | 192.168.1.2 ---- vlan10 |
pc2 | 192.168.2.1 ---- vlan20 |
pc3 | 192.168.2.2 ---- vlan20 |
以上主机所有DNS均为8.8.8.8,网关为其网段的倒数第二位(如192.168.1.254是pc0和pc1的网关)
针对服务器,其配置如下:
配置 | 信息 |
---|---|
IP | 10.0.0.1 |
网关 | 10.0.0.254 |
DNS | 8.8.8.8 |
下面是二层交换机配置
S0
Switch#vlan database
% Warning: It is recommended to configure VLAN from config mode,
as VLAN database mode is being deprecated. Please consult user
documentation for configuring VTP/VLAN in config mode.
Switch(vlan)#vlan 10
VLAN 10 added:
Name: VLAN0010
Switch(vlan)#vlan 20
VLAN 20 added:
Name: VLAN0020
Switch(vlan)#exit
Switch#configure terminal
Switch(config)#int f 0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 10
Switch(config)#int f 0/2
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 10
Switch(config)#int f 0/3
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 20
Switch(config)#int f 0/4
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 20
Switch(config)#int f 0/5
Switch(config-if)#switchport mode trunk
Switch(config-if)#switchport trunk allowed vlan all
S1
Switch#vlan database
% Warning: It is recommended to configure VLAN from config mode,
as VLAN database mode is being deprecated. Please consult user
documentation for configuring VTP/VLAN in config mode.
Switch(vlan)#vlan 30
VLAN 30 added:
Name: VLAN0030
Switch(config)#int f 0/3
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 30
Switch(config)#int f 0/1
Switch(config-if)#switchport mode trunk
Switch(config-if)#switchport trunk allowed vlan all
接下来就是三层交换机的配置
Switch#vlan database
% Warning: It is recommended to configure VLAN from config mode,
as VLAN database mode is being deprecated. Please consult user
documentation for configuring VTP/VLAN in config mode.
Switch(vlan)#vlan 10
VLAN 10 added:
Name: VLAN0010
Switch(vlan)#vlan 20
VLAN 20 added:
Name: VLAN0020
Switch(vlan)#vlan 30
VLAN 30 added:
Name: VLAN0030
Switch(vlan)#exit
Switch#configure terminal
Switch(config)#int vlan10
Switch(config-if)#ip address 192.168.1.254 255.255.255.0
Switch(config)#int vlan20
Switch(config-if)#ip address 192.168.2.254 255.255.255.0
Switch(config)#int vlan30
Switch(config-if)#ip address 10.0.0.254 255.255.255.0
Switch(config-if)#int f 0/1
Switch(config-if)#switchport trunk encapsulation dot1q
Switch(config-if)#switchport mode trunk
Switch(config-if)#switchport trunk allowed vlan all
Switch(config-if)#int f 0/2
Switch(config-if)#switchport trunk encapsulation dot1q
Switch(config-if)#switchport mode trunk
Switch(config-if)#switchport trunk allowed vlan all
Switch(config)#ip routing
本次配置主要目的是将公司网络连接到互联网,并通过DNS服务器使其他公司可以访问
Switch#vlan database
% Warning: It is recommended to configure VLAN from config mode,
as VLAN database mode is being deprecated. Please consult user
documentation for configuring VTP/VLAN in config mode.
Switch(vlan)#vlan 2
VLAN 2 added:
Name: VLAN0002
Switch(config)#int vlan2
Switch(config-if)#ip address 192.168.10.1 255.255.255.0
Switch(config-if)#int f 0/3
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 2
Switch(config)#ip route 0.0.0.0 0.0.0.0 192.168.10.2
R6
Router(config)#ip access-list standard 10
Router(config-std-nacl)#permit any
Router(config)#int g 0/0
Router(config-if)#ip nat inside
Router(config)#int g 0/2
Router(config-if)#ip nat outside
Router(config)#ip nat inside source list 10 interface g 0/2
Router(config)#ip route 192.168.1.0 255.255.255.0 192.168.10.1
Router(config)#ip route 192.168.2.0 255.255.255.0 192.168.10.1
Router(config)#ip route 10.0.0.0 255.255.255.0 192.168.10.1
R4的配置同R6
R6
Router(config)#ip nat inside source static tcp 10.0.0.1 80 12.12.12.1 80
R4
Router(config)#ip nat inside source static tcp 10.0.0.1 80 45.45.45.1 80