IP地址与域名详解

IPv4 Addresses

IPv4 addresses are 32 bits long and are usually written as 4 decimal numbers, separated by dots ("."). This is called dotted-decimal notation, and each decimal number represents one of the 4 bytes of the 32-bit address. The first of the 4 decimal numbers identifies the address type, as shown in Figure A.3. Although historically IPv4 addresses were divided into five classes, as shown in Figure A.3, the three classes used for unicast addresses are functionally equivalent, so we show them as one range.

Figure A.3. Ranges for the five different classes of IPv4 addresses.

graphics/xafig03.gif

Whenever we talk about an IPv4 network or subnet address, we talk about a 32-bit network address and a corresponding 32-bit mask. Bits of 1 in the mask cover the network address and bits of 0 in the mask cover the host. Since the bits of 1 in the mask are usually contiguous from the leftmost bit, and the bits of 0 in the mask are always contiguous from the rightmost bit, this address mask can also be specified as a prefix length that denotes the number of contiguous bits of 1 starting from the left. For example, a mask of 255.255.255.0 corresponds with a prefix length of 24. These are known as classless addresses, so called because the mask is explicitly specified instead of being implied by the address class. IPv4 network addresses are normally written as a dotted-decimal number, followed by a slash, followed by the prefix length. Figure 1.16 showed examples of this.

Discontiguous subnet masks were never ruled out by any RFC, but they are confusing and cannot be represented in prefix notation. BGP4, the Internet interdomain routing protocol, cannot represent discontiguous masks. IPv6 also requires that all address masks be contiguous starting at the leftmost bit.

Using classless addresses requires classless routing, and this is normally called classless interdomain routing (CIDR) (RFC 1519 [Fuller et al. 1993]). CIDR usage decreases the size of the Internet backbone routing tables and reduces the rate of IPv4 address depletion. All routes in CIDR must be accompanied by a mask or a prefix length. The class of the address no longer implies the mask. Section 10.8 of TCPv1 talks more about CIDR.

Subnet Addresses

IPv4 addresses are often subnetted (RFC 950 [Mogul and Postel 1985]). This adds another level to the address hierarchy:

  • Network ID (assigned to site)

  • Subnet ID (chosen by site)

  • Host ID (chosen by site)

The boundary between the network ID and the subnet ID is fixed by the prefix length of the assigned network address. This prefix length is normally assigned by the organization's Internet service provider (ISP). But, the boundary between the subnet ID and the host ID is chosen by the site. All the hosts on a given subnet share a common subnet mask, and this mask specifies the boundary between the subnet ID and the host ID. Bits of 1 in the subnet mask cover the network ID and subnet ID, and bits of 0 cover the host ID.

As an example, consider a site that is assigned the prefix 192.168.42.0/24 by its ISP. If it chooses to use a 3-bit subnet ID, 5 bits are left for the host ID, as shown in Figure A.4.

Figure A.4. 24-bit network address with 3-bit subnet ID and 5-bit host ID.

graphics/xafig04.gif

This division results in the subnets shown in Figure A.5.

Figure A.5. Subnet list for 3-bit subnet ID and 5-bit host ID.

graphics/xafig05.gif

This gives us 6 to 8 subnets (subnet IDs 1–6 or 0–7), each supporting 30 systems (host IDs 1–30). RFC 950 recommends not using the two subnets with a subnet ID of all zero bits or all one bits (the ones marked with a dagger in Figure A.5. Most systems today support these two forms of subnet IDs. The highest host ID (31, in this case) is reserved for the broadcast address. The host ID 0 is reserved for identifying the network and to avoid problems with old systems that used host ID 0 as the broadcast address. However, on controlled networks with no such systems, it may be possible to use host ID 0. In general, network programs need not care about specific subnet or host IDs and should treat IP addresses as opaque values.

Loopback Addresses

By convention, the address 127.0.0.1 is assigned to the loopback interface. Anything sent to this IP address loops around and becomes IP input without ever leaving the machine. We often use this address when testing a client and server on the same host. This address is normally known by the name INADDR_LOOPBACK.

Any address on the network 127/8 can be assigned to the loopback interface, but 127.0.0.1 is and is often configured automatically by the IP stack.

Unspecified Address

The address consisting of 32 zero bits is the IPv4 unspecified address. In an IPv4 packet, it is only permitted to appear as the source address in packets sent by a node that is bootstrapping before the node learns its IP address. In the sockets API, this address is called the wildcard address and is normally known by the name INADDR_ANY. Also, specifying it in the sockets API, for example, to bind for a listening TCP socket, indicates that the socket will accept client connections destined to any of the node's IPv4 addresses.

Private Addresses

RFC 1918 [Rekhter et al. 1996] sets aside three address ranges for "private Internets," that is, networks that do not connect to the public Internet without a NAT or proxies in between. These address ranges are shown in Figure A.6:

Figure A.6. Ranges for private IPv4 addresses.

graphics/xafig06.gif

These addresses must never appear on the Internet; they are reserved for use in private networks. Many small sites use these private addresses and NAT to a single public IP address visible to the Internet.

Multihoming and Address Aliases

Traditionally, the definition of a multihomed host has been a host with multiple interfaces: two Ethernets, for example, or an Ethernet and a point-to-point link. Each interface must generally have a unique IPv4 address. When counting interfaces to determine if a host is multihomed, the loopback interface does not count.

A router, by definition, is multihomed since it forwards packets that arrive on one interface out another interface. But, a multihomed host is not a router unless it forwards packets. Indeed, a multihomed host must not assume it is a router just because the host has multiple interfaces; it must not act as a router unless it has been configured to do so (typically by the administrator enabling a configuration option).

The term "multihoming," however, is more general and covers two different scenarios (Section 3.3.4 of RFC 1122 [Braden 1989]):

  • A host with multiple interfaces is multihomed and each interface must in general have its own IP address. ("Unnumbered" interfaces need not have IP addresses, but we mostly encounter these on routers.) This is the traditional definition.

  • Newer hosts have the capability of assigning multiple IP addresses to a given physical interface. Each additional IP address, after the first (primary), is called an alias or logical interface. Often, aliased IP addresses share the same subnet address as the primary address but have different host IDs. But, it is also possible for aliases to have a completely different network address or subnet addresses from the primary. We show an example of aliased addresses in Section 17.6.

Hence, the definition of a multihomed host is one with multiple interfaces visible to the IP layer, regardless of whether those interfaces are physical or logical.

It is common to give a high-usage server multiple connections to the same Ethernet switch, and to aggregate these connections to appear as one higher bandwidth interface. Although such a system has multiple physical interfaces, it is not considered to be multihomed since only one logical interface is visible to IP.

The term "multihoming" is also used in another context. A network that has multiple connections to the Internet is also called multihomed. For example, some sites have two connections to the Internet instead of one, providing a backup capability. The SCTP transport protocol can potentially take advantage of these multiple connections by communicating that the site is multihomed to its peer. 

IP是 Internet Protocol(国际互联网协议)的缩写。各主机间要进行信息传递必须要知道对方的IP地址。每个IP地址的长度为32位(bit),分4段,每段8位(1个字节),常用十进制数字表示,每段数字范围为1~254,段与段之间用小数点分隔。每个字节(段)也可以用十六进制或二进制表示。每个IP地址包括两个ID(标识码),即网络ID和宿主机ID。同一个物理网络上的所有主机都用同一个网络ID,网络上的一个主机(工作站、服务器和路由器等)对应有一个主机ID。这样把IP地址的4个字节划分为2个部分,一部分用来标明具体的网络段,即网络ID;另一部分用来标明具体的节点,即宿主机ID。这样的32位地址又分为五类分别对应于A类、B类、C类、D类和E类IP地址。   

  1.A类IP地址

  一个A类IP地址由1字节(每个字节是8位)的网络地址和3个字节主机地址组成,网络地址的最高位必须是“0”,即第一段数字范围为1~127。每个A类地址可连接16387064台主机,Internet有126个A类地址。  

  2.B类IP地址

   一个B类IP地址由2个字节的网络地址和2个字节的主机地址组成,网络地址的最高位必须是“10”,即第一段数字范围为128~191。每个B类地址可连接64516台主机,Internet有16256个B类地址。  

  3.C类IP地址

   一个C类地址是由3个字节的网络地址和1个字节的主机地址组成,网络地址的最高位必须是“ll0”,即第一段数字范围为192~223。每个C类地址可连接254台主机,Internet有2054512个C类地址。   

  4.D类地址用于多点播送。

  第一个字节以“lll0”开始,第一个字节的数字范围为224~239,是多点播送地址,用于多目的地信息的传输,和作为备用。全零(“0.0.0.0”)地址对应于当前主机,全“1”的IP地址(“255.255.255.255”)是当前子网的广播地址。
 5.E类地址

  以“llll0”开始,即第一段数字范围为240~254。E类地址保留,仅作实验和开发用。

  几种用作特殊用途的IP地址

  ①主机段(即宿主机)ID全部设为“0”的IP地址称之为网络地址,如129.45.0.0就是B类网络地址。

  ②主机ID部分全设为“1”(即255)的IP地址称之为广播地址,如129.45.255.255就是B类的广播地址。

  ③网络ID不能以十进制“127”作为开头,在地址中数字127保留给诊断用。如127.1.1.1用于回路测试,同时网络ID的第一个8位组也不能全置为“0”,全置“0”表示本地网络。网络ID部分全为“0”和全部为“1”的IP地址被保留使用。

  Internet的设计者也不清楚它会怎样发展。一些人设想一个Internet会是包含有许多主机的几个网。另一些人则预言有许多的网而每一个网上的主机并不太多,作为折中, Internet的地址是适合大网和小网的。它们被确定为32位但有三种类型。地址是自定义的,它的最高位定义地址的类型。A类地址支持多个主机在一个网:最高位为0,跟随有7bit网络部份和24bii主机部份。在B类地址,最高位是非0,跟随有14bit网络号和16bii主机号。C类地址以110 开始,跟随有2lbit网络号和8bit主机号。按常规,Internet地址由加点的字符给出。地址由四部份10进制数组成,用点作分隔。例如,10. 0,0.51和128.10.2.1分别是A类和B类的Internet地址。   

  由于IP地址全是些的数字,为了便于用户记忆,Internet上引进了域名服务系统DNS(Domain Name System)。当您键入某个域名的时候,这个信息首先到达提供此域名解析的服务器上,再将此域名解析为相应网站的IP地址。完成这一任务的过程就称为域名解析。域名解析的过程是:当一台机器a向其域名服务器A发出域名解 析请求时,如果 A可以解析,则将解析结果发给 a,否则,A将向其上级域名服务器B发出解 析请求,如果B能解析,则将解析结果发给a,如果 B无法解析,则将请求发给再上一级域名服务器 C……如此下去,直至解析到为止。域名简单地说就是Internet上主机的名字,它采用层次结构,每一层构成一个子域名,子域名之间用圆点隔开,自左至右分别为:计算机名、网络名、机构名、最高域名。Internet域名系统是一个树型结构。

  以机构区分的最高域名原来有7个: com(商业机构)、net(网络服务机构)、gov(政府机构)、mil(军事机构)、org(非盈利性组织)、edu(教育部门)、int(国际机构)。1997年又新增7个最高级标准域名:firm(企业和公司)、store(商业企业)、web(从事与WEB相关业务的实体)、arts(从事文化娱乐的实体)、REC(从事休闲娱乐业的实体)、info(从事信息服务业的实体)、nom(从事个人活动的个体、发布个人信息)。这些域名的注册服务由多家机构承担, CNNIC也有幸成为注册机构 之一; 按照ISO-3166标准制定的国家域名,一般 由各国的NIC(Network Information Center, 网络信息中心 )负责运行。

 以地域区分的最高域名有:AQ(南极洲)、AR(阿根廷)、AT(奥地利)、AU(澳大利亚)、BE(比利时)、BR(巴西)、CA(加拿大)、CH(瑞士)、CN(中国)、DE(德国)、DK(丹麦)、ES(西班牙)、FI(芬兰)、FR(法国)、GR(希腊)、IE(、爱尔兰)、IL(以色列)、IN (印度)、IS(冰岛)、IT(意大利)、JP(日本)、KR(韩国)、MY(马来西亚)、NL(荷兰)、NO(挪威)、NZ(新西兰)、PT(葡萄牙)、RU(俄罗斯)、SE(瑞典)、SG(新加坡)、TH(泰国)、TW(中国台湾)、UK或GB(英国)、US(美国)(一般可省略)等。
  我国域名体系分为类别域名和行政区域名两套。类别域名有六个,分别依照申请机构的性质依次分为: A C-科研机构; COM-工、商、金融等专业; EDU-教育机构; GOV-政府部门; NET-互 联网络、接入网络的信息中心和运行中心; ORG-各种非盈利性的组织。行政区域名是按照我国的各个行政区划分而成的,其划分标准依照国家技术监督局发布的国家标准而定,包括“行政区域名”34个, 适用于我国的各省、自治区、直辖市,分别为 : BJ-北京市; SH-上海市;TJ-天津市; CQ-重庆市; HE-河北省; SX-山西省; NM-内蒙古自治区;LN-辽宁省; JL-吉林 省; HL-黑龙江省; JS-江苏省; ZJ-浙江省; AH-安徽; FJ-福建省; JX- 江西省; SD-山东省; HA-河南省; HB- 湖北省; HN-湖南省; GD-广东省; GX- 广西壮族自治区; HI-海南省; SC-四川 省; GZ-贵州省;YN-云南省; XZ-西藏 自治区; SN-陕西省; GS-甘肃省; QH -青海省; NX-宁夏回族自治区; XJ-新 疆维吾尔自治区; TW-台湾; HK-香港; MO-澳门。 CN域名除 edu.cn由CernNic(教育网)运行外,其他均由 CNNIC运行。

  传统的域名和网址是一个技术层面上的事物,并有着严格的规定,上述几个部分组成了一个完整的“网址”(URL),有的URL中还包含了数据库、密码等内容。近来出现了中文域名,如“3721中文网址”是一种架设在IP地址和域名技术之上的“应用和服务”,它不需改变现有的网络结构和域名体系,将一个复杂的URL转换为一个直观的中文词汇,实现中文用户的轻松上网。另一种“CNNIC中文域名”则突出网络的概念和技术,因为它是一个技术标准和规范,它的推出使域名汉化有标准可循,充分体现了CNNIC作为中国域名管理机构的身份,为中文网站提供了本土化

  域名注册的服务。这两者不是一个层面上的事物,因此完全不冲突,而且3721中文网址支持传统的“IP地址”和“域名”技术体系,也就自然支持CNNIC“中文域名”, 3721的用户只要在浏览器地址栏中输入“http://”+“中文域名”就可以使用CNNIC中文域名系统,如果按照老习惯直接输入中文名称则仍然使用 3721中文网址服务。一般每个“域名”或“中文域名”只对应一个“IP地址”,由于3721中文网址作为一种架设在上层的应用,3721中文网址可以实现“一对一”(一个中文网址对应一个网站)、“一对多”(一个中文网址对应多个镜像站点)、“多对一”(多个中文网址对应一个中文网站)、“多对多”等不同形式。可以将整个URL(包括深层目录)转换成一个简单直观的中文词汇。科学技术的不断发展地址与域名将有更丰富的含义……  

  在INTERNET上,另一类地址——电子邮件的地址,即E-MAIL地址。E-MAIL地址具有以下统一的标准格式:用户名@主机域名,用户名就是你在主机上使用的用户码,@符号是你使用的计算机域名。@可以读成“AT”,也就是“在”的意思。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值