25-IP Address Allocation I - Basic

本文介绍了LTE网络中IP地址分配的两种方式:动态分配和静态分配。动态分配由网络自动选择IP地址,而静态分配则为用户指定固定IP地址。文章详细解释了这两种分配方式的过程,并通过实例进行说明。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文链接:http://www.netmanias.com/en/?m=view&id=techdocs&no=7246

I. Introduction

lte是全IP网络。这就意味着交付所有用户流量时都是以IP数据包的形式,提供给用户always on IP connectivity的服务。当UE加入LTE网络,会给UE分配一个PDN地址让UE连接这个PDN,并建立默认承载。默认承载保持连接知道UE从LTE网络中detach掉。 
默认承载对用户拥有的没有APN建立,为每一个APN分配独立的IP地址,一个IP地址可以为ipv4,ipv6,ipv4/ipv6三种类型。

这篇文件主要解释当用户初始接入网络时LTE网络怎么给用户分配IP地址的,并通过实例来解释。

在接下来的文档中我们将会涉及到两种类型的IP地址,这篇文档涉及到基本IP地址分配机制和过程,描述熊地址是怎样分配给用户的(用户处于一个位置,对网络执行多次初始attach)。接下来文档我们将学习不同类型的IP地址分配(用户在两个物理分割区域cityA和cityB执行初始附着)。 
这篇文档组织如下:第二章,不同类型的IP地址分配–动态的和静态的,并讨论他们的特点。第三章和第四章将详细讨论动态和静态IP地址的分配过程。

II. Types of IP Address Allocation

当UE初始附着到LTE网络,UE请求PDN连接。PGW分配一个IP地址供UE连接PDN,并在U默认承载建立时连接UE和PDN,转发给UE。使用这个IP地址,UE可以获得PDN提供的服务。 
PGW分配IP地址有两种方式:动态的和静态的分配。对于动态分配,当UE每次接入网络时自动分配一个IP地址。对于静态分配,一旦用户签约后指定给UE一个固定的IP地址,并在每次UE接入网络时都分配这个指定的IP地址。图1比较两种方式的不同。 
这里写图片描述

对于动态分配,网络PGW自动为UE选择IP地址。在PGW中网络运营商有一个IP地址池。的那个UE初始附着到LTE网络时,PGW动态为UE分配一个IP地址。所以每次UE初始附着到网络时分配的一个新的动态IP地址。 
但是,对于静态分配,一旦UE签约网络之后网络运营商就分配了一个固定的IP地址。运营商在hss中和其他签约信息一起为UE分配了静态的IP地址。接着当UE初始附着到LTE网络时,PGW从hss中获得这个静态IP地址并转发给UE。所以在每次UE初始附着网络时给UE分配的都是特定的IP地址。

当在初始附着请求PDN连接时,UE通过使用协议配置选项PCO可以请求和外部协议/应用相关的协议数据(eg请求dns服务器地址,P-CSCF地址)。这篇文档将详细解释dns服务器地址和IP地址的请求。

III. Dynamic IP Address Allocation

对于动态IP地址分配,PGW为UE保留IP地址池,并在UE初始附着到LTE网络时为其分配一个IP地址。 
这里写图片描述

PGW中提供IP地址 
在PGW中,分配了一个IP地址池,并且dns服务器IP地址已经分配了。 
这里写图片描述

动态IP地址分配过程 
用户打开UE,试图初始附着到LTE网络上。

1)【UE->MME】请求PDN connectivity 
UE通过发送PDN connectivity request(PDN type=IPv4, PCO=DNS Server IPv4 Address Request)消息给MME请求PDN连接。这是,除了请求ipv4地址,也请求dns服务器地址。PDN connectivity request消息是一个ESM消息,但是这个消息是嵌入在attach request(IMSI,ESM Message Container)消息中传输的。

2)~3)【MME->SGW->PGW】请求会话创建 
MME基于从hss接收到的签约配置文件,发送create session request(IMSI, PDN Type=IPv4, PDN Address=0.0.0.0, PCO=DNS Server IPv4 Address Request) 消息给SGW请求EPS会话创建。因为是动态IP分配,这个签约配置文件中不包含IP地址信息,在create sessionrequest消息中PDN地址域是0.0.0.0,从UE接受到的PCO信息也包含在PCO域中。

4)【PGW】分配PDN地址和dns服务器地址 
PGW在检查PDN类型和PDN地址(0.0.0.0)之后发现需要分配ipv4地址。PGW从ipv4地址池中选择一个IP地址(e.g. UE IP=1.1.1.5),并分配给UE。根据PCO域的请求,也分配相应的dns服务器IP地址。

5)~6)【MME<-SGW<-PGW】对请求会话创建的响应 
作为对2-3步请求的响应,PGW发送create session response消息给MME。这个消息包含PDN地址域的UE IP地址,PCO域的dns服务器IP地址。

7)【UE<-MME】请求默认承载上下文的激活 
MME给UE发送activate default EPS bearer context request(PDN Type=IPv4, PDN Address=UE IP(1.1.1.5), PCO={Primary DNS IP, Secondary DNS IP})消息来请求对默认承载上下文的激活。这个ESM消息包含dns服务器IP地址和UE IP地址,嵌入到attach accept消息中传输。

8)【UE】获得动态IP地址使用PDN服务 
UE获得动态IP地址和dns服务器地址。UE和PGW之间建立默认承载。UE现在已经连接到PDN上,可以以动态IP地址来使用Internet服务。

IV. Static IP Address Allocation

对于静态IP地址分配,当用户第一次签约网络时网络运营商为用户指定了一个UE IP地址,在hss中提供用户签约配置文件,并在用户每次初始附着到网络时分配一个存储在配置文件中的静态IP地址。详细的过程如图3所示。 
这里写图片描述 
hss中提供IP 
在hss中,提供了每一个签约用户的签约配置文件。这个配置文件包括PDN类型,用于PDN连接的PDN地址。 
这里写图片描述 
PGW中IP提供 
在PGW中,dns服务器IP地址已经设置了。 
这里写图片描述

静态IP地址分配的过程 
用户打开UE,试图初始化附着到LTE网络。

1)【UE->MME】请求PDN连接 
UE通过发送PDN connectivity request消息(PDN type=IPv4, PCO=DNS Server IPv4 Address Request)消息给MME请求PDN连接。这时,除了IPv4地址,包括dns服务器地址也请求了。

2)【MME->HSS】为了注册请求LTE网络 
MME通过发送update location request消息通知HSS,UE已经在MME的控制之下,请求在网络上注册UE。

3)【MME<-HSS】转发签约配置文件 
HSS识别到UE已经在MME上注册了,通过发送update location answer(IMSI, PDN Type=IPv4, PDN Address=Static UE IP(1.1.1.1))消息来转发UE的签约配置文件。这个签约配置文件包含静态IP地址。

4)~5)【MME->SGW->PGW】请求会话创建 
在从HSS接收到UE签约配置文件后,MME知道UE已经有一个额静态IP地址了。MME准备create session request消息(IMSI, PDN Type=IPv4, PDN Address=Static UE IP(1.1.1.1), PCO=DNS Server IPv4 Address Request)并发送给PGW。这时,这个消息在PDN地址域包含从hss接收到的静态IP地址,在PCO域包含从UE接收到的PCO信息。

6)~7)【MME<-SGW<-PGW】对创建会话请求的响应 
作为对4-5步请求的响应,PGW和SGW发送create session response消息(IMSI, PDN Type=IPv4, PDN Address=Static UE IP(1.1.1.1), PCO={Primary DNS IP, Secondary DNS IP})给MME。这个消息在PDN地址域包含静态IP地址,在PCO域包含dns服务器地址。

8)【UE<-MME】请求默认承载上下文的激活 
MME通过发送active default EPS bearer context request消息(PDN Type=IPv4, PDN Address=Static UE IP(1.1.1.1), PCO={Primary DNS IP, Secondary DNS IP})请求默认承载上下文的创建。这个ESM消息包含UE的静态IP地址和dns服务器地址,嵌入到attach accept消息中。

9)【UE】获得静态IP地址来使用PDN服务 
UE获得静态IP地址和dns服务器IP地址。UE和PGW之间建立了默认承载。UE现在连接了PDN,可以通过静态IP地址使用Internet服务了。

V. Closing

到目前为止,我们讨论了两种分配IP的方式:静态和动态。当用户试图初始附着到LTE网络时,LTE网络分配一个IP地址来连接到PDN上和默认承载。只要用户网络注册有效,PDN地址和默认承载一直保持有用,即使用户没有在使用服务。这种方式叫做always-on IP connectivity。 
这个文档解释了IP地址分配的机制和过程。下面一个文章我们将讨论在不同的位置UE连接PDN时的情况。

References

[1] Netmanias Technical Document, “LTE IP Address Allocation Schemes II: A Case for Two Cities”, 
February 2014 (TBD) 
[2] Netmanias Technical Document, “EMM Procedure 1. Initial Attach - Part 1. Cases of Initial Attach”, 
December 2013, http://www.netmanias.com/en/?m=view&id=techdocs&no=6098 
[3] NMC Consulting Group Confidential Internal Report, “E2E LTE Network Design”, August 2010

# # Sample configuration file for ISC dhcpd for Debian # # Attention: If /etc/ltsp/dhcpd.conf exists, that will be used as # configuration file instead of this file. # # # The ddns-updates-style parameter controls whether or not the server will # attempt to do a DNS update when a lease is confirmed. We default to the # behavior of the version 2 packages ('none', since DHCP v2 didn't # have support for DDNS.) ddns-update-style none; # option definitions common to all supported networks... option domain-name "example.org"; option domain-name-servers ns1.example.org, ns2.example.org; default-lease-time 600; max-lease-time 7200; # If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. #authoritative; # Use this to send dhcp log messages to a different log file (you also # have to hack syslog.conf to complete the redirection). log-facility local7; # No service will be given on this subnet, but declaring it helps the # DHCP server to understand the network topology. #subnet 10.152.187.0 netmask 255.255.255.0 { #} # This is a very basic subnet declaration. #subnet 10.254.239.0 netmask 255.255.255.224 { # range 10.254.239.10 10.254.239.20; # option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org; #} # This declaration allows BOOTP clients to get dynamic addresses, # which we don't really recommend. #subnet 10.254.239.32 netmask 255.255.255.224 { # range dynamic-bootp 10.254.239.40 10.254.239.60; # option broadcast-address 10.254.239.31; # option routers rtr-239-32-1.example.org; #} # A slightly different configuration for an internal subnet. #subnet 10.5.5.0 netmask 255.255.255.224 { # range 10.5.5.26 10.5.5.30; # option domain-name-servers ns1.internal.example.org; # option domain-name "internal.example.org"; # option subnet-mask 255.255.255.224; # option routers 10.5.5.1; # option broadcast-address 10.5.5.31; # default-lease-time 600; # max-lease-time 7200; #} # Hosts which require special configuration options can be listed in # host statements. If no address is specified, the address will be # allocated dynamically (if possible), but the host-specific information # will still come from the host declaration. #host passacaglia { # hardware ethernet 0:0:c0:5d:bd:95; # filename "vmunix.passacaglia"; # server-name "toccata.fugue.com"; #} # Fixed IP addresses can also be specified for hosts. These addresses # should not also be listed as being available for dynamic assignment. # Hosts for which fixed IP addresses have been specified can boot using # BOOTP or DHCP. Hosts for which no fixed address is specified can only # be booted with DHCP, unless there is an address range on the subnet # to which a BOOTP client is connected which has the dynamic-bootp flag # set. #host fantasia { # hardware ethernet 08:00:07:26:c0:a5; # fixed-address fantasia.fugue.com; #} # You can declare a class of clients and then do address allocation # based on that. The example below shows a case where all clients # in a certain class get addresses on the 10.17.224/24 subnet, and all # other clients get addresses on the 10.0.29/24 subnet. #class "foo" { # match if substring (option vendor-class-identifier, 0, 4) = "SUNW"; #} #shared-network 224-29 { # subnet 10.17.224.0 netmask 255.255.255.0 { # option routers rtr-224.example.org; # } # subnet 10.0.29.0 netmask 255.255.255.0 { # option routers rtr-29.example.org; # } # pool { # allow members of "foo"; # range 10.17.224.10 10.17.224.250; # } # pool { # deny members of "foo"; # range 10.0.29.10 10.0.29.230; # } #} 上面是dhcpd.conf 文件中的内容,我怎样把下面的配置加进去?# 基本配置 option domain-name "example.org"; option domain-name-servers 8.8.8.8, 8.8.4.4; # DNS服务器 default-lease-time 600; # 默认租期(秒) max-lease-time 7200; # 最大租期 authoritative; # 声明为权威服务器 # IP池配置(避开Windows主机IP) subnet 10.160.85.0 netmask 255.255.255.0 { range 10.160.85.150 10.160.85.200; # 可分配IP范围 option routers 10.160.85.1; # 网关(物理路由器IP) option broadcast-address 10.160.85.255; }
最新发布
08-21
06-21
### SSH -R Reverse Tunnel Usage and Examples The `ssh -R` command is used to create a reverse tunnel, which allows remote access to a local service or machine through an SSH connection. This feature is particularly useful when the local machine is behind a NAT or firewall, making it inaccessible directly from the outside world. #### Basic Syntax The basic syntax for creating a reverse tunnel using `ssh -R` is as follows: ```bash ssh -R [bind_address:]port:host:hostport user@remote_host ``` - **`bind_address`**: The address on the remote host where the tunnel will be bound (optional; defaults to `localhost`). - **`port`**: The port on the remote host that will listen for incoming connections. - **`host`**: The hostname or IP address of the local machine or another machine accessible from the local machine. - **`hostport`**: The port on the local machine or the specified `host` that will receive forwarded traffic. - **`user@remote_host`**: The username and remote server to connect to via SSH. #### Example 1: Simple Reverse Tunnel To expose a local web server running on port 8080 to a remote server: ```bash ssh -R 8080:localhost:8080 user@remote_host ``` This command sets up a reverse tunnel so that any connection made to port 8080 on the remote server will be forwarded to port 8080 on the local machine[^3]. #### Example 2: Binding to All Interfaces on Remote Host If you want the reverse tunnel to listen on all interfaces (`0.0.0.0`) of the remote host instead of just `localhost`, you can specify the bind address: ```bash ssh -R 0.0.0.0:8080:localhost:8080 user@remote_host ``` This makes the service accessible not only from the remote server itself but also from other machines connecting to the remote server[^4]. #### Example 3: Dynamic Port Allocation You can let the remote server choose an available port by specifying `0` as the port number: ```bash ssh -R :0:localhost:22 user@remote_host ``` After establishing the connection, SSH will display the dynamically allocated port: ``` Allocated port 20000 for remote forward to localhost:22 ``` In this case, port 20000 on the remote server forwards traffic to port 22 on the local machine[^5]. #### Example 4: Exposing a Database Service Suppose you have a MySQL database running locally on port 3306 and wish to allow access to it from the remote server: ```bash ssh -R 3307:localhost:3306 user@remote_host ``` Now, any connection to port 3307 on the remote server will be forwarded to the local MySQL server on port 3306[^6]. #### Security Considerations When using reverse tunnels, ensure that appropriate security measures are in place: - Restrict access to the listening port on the remote server if binding to `0.0.0.0`. - Use SSH key-based authentication with passphrases for added security[^1]. - Regularly monitor and audit SSH connections to detect unauthorized usage. ```python # Example Python script to automate SSH reverse tunnel setup using Paramiko library import paramiko ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect('remote_host', username='user', key_filename='/path/to/private/key') transport = ssh.get_transport() transport.open_channel('direct-tcpip', ('localhost', 8080), ('localhost', 8080)) # Keep the connection alive while True: pass ```
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值