1
,
DHCP
的中继
作用:把客户端所发送的
discover/request
转变为单播传递给
DHCP
服务器
1
)实验
需求:
a
,
GW.R3
:
E0/0---- 10.1.1.100/24 E0/1 ---172.16.1.100/24
Out.R4:E0/1---172.16.1.10/24
b
,
Out.R4
作为
DHCP
的服务器,为内网用户动态指派
IP
地址
dhcp pool:10.1.1.0/24
default-route:10.1.1.100
DNS:8.8.8.8
domain-name:xh.edu
配置:
**********************In.R1****************
!
interface Ethernet0/0
ip address
dhcp ---通过DHCP的方式获取IP地址及参数
!
****************************GW.R3****************
!
interface Ethernet0/0
ip address 10.1.1.100 255.255.255.0
ip
helper-address
172.16.1.10 ---DHCP中继,DHCP服务器的IP地址
!
interface Ethernet0/1
ip address 172.16.1.100 255.255.255.0
!
*************************Out.R4********************
!
interface Ethernet0/1
ip address 172.16.1.10 255.255.255.0
!
ip dhcp pool
LAN
---定义DHCP地址池
network 10.1.1.0 255.255.255.0
default-router 10.1.1.100
dns-server 8.8.8.8
domain-name xh.edu
!
ip route 0.0.0.0 0.0.0.0 172.16.1.100
!
2
,公有和私有地址
3
,
NAT
(网络地址转换)
作用:
NAT允许私有地址用户通过共享一个或多个公有地址来访问互联网
1
)几个重要的
NAT地址类型:
• Inside local: 主机内部网络(分配给内部设备的地址一般不对外公布)
• Inside global: 通常由ISP指派允许用户外部访问的地址(通过这个地
址外部可以知道内部设备)
• Outside global: 主机外部网络(分配给外部设备的地址一般不会对
内公布)
• Outside local:通过这个地址内部设备可以知道外部设备
2
)三种
NAT类型:
• Static NAT: 一对一地址映射
• Dynamic NAT: 多对多地址映射
• PAT: 多对一地址映射
3
)实验
拓扑
需求:
a
,内网
10.1.1.0/24
R1
:
10.1.1.1
R2
:
10.1.1.2
GW
:
10.1.1.100
b
,外网
202.100.1.0/24
R4
:
202.100.1.10
GW
:
202.100.1.100
c
,
R1
(
10.1.1.1
)为服务器,通过静态
NAT
转换到外部
202.100.1.1
d,202.100.1.11-15,为内部用户(10.1.1.0/24)提供互联网服务(动态NAT)
e
,所有内部用户通过外部接口
202.100.1.100
访问互联网(
PAT
)
配置:
*********************************需求C******************************
GW.R3:一对一的访问方式
!
interface Ethernet0/0
ip address 10.1.1.100 255.255.255.0
ip nat inside ---定义内部接口
!
interface Ethernet0/1
ip address 202.100.1.100 255.255.255.0
ip nat outside ---定义外部接口
!
ip nat
inside source
static
(
nat方式
)
10.1.1.1
(
inside local
)
202.100.1.1
(
inside global)
!
查看转换槽位:
静态
NAT
,甭管有没有流量,转换槽位始终存在
GW.R3#s
h ip nat translations
Pro Inside global Inside local Outside local Outside global
--- 202.100.1.1 10.1.1.1 --- ---
测试静态
NAT
:
-----外部发起
---内部发起
查看转换槽位:
********************************需求D********************
GW.R3:多对多的访问方式
!
interface Ethernet0/0
ip address 10.1.1.100 255.255.255.0
ip nat inside ---定义内部接口
!
interface Ethernet0/1
ip address 202.100.1.100 255.255.255.0
ip nat outside ---定义外部接口
!
access-list
10
permit 10.1.1.0 0.0.0.255 ----ACL抓取流量(转换前的)
!
ip nat pool
NATPOOL
202.100.1.11 202.100.1.15 netmask 255.255.255.0----定义转换后地址范围
!
ip nat inside source list
10
pool
NATPOOL ----调用
!
测试:
查看转换槽位:
***************************需求E***********************
GW.R3:多对一的访问方式
!
interface Ethernet0/0
ip address 10.1.1.100 255.255.255.0
ip nat inside ---定义内部接口
!
interface Ethernet0/1
ip address 202.100.1.100 255.255.255.0
ip nat outside ---定义外部接口
!
access-list
10
permit 10.1.1.0 0.0.0.255 ----ACL抓取流量(转换前的)
!
ip nat inside source list
10
interface
Ethernet0/1
overload ---复用
!
测试:
转换槽位: