`

从头开始打造Ubuntu服务器 (2) - 网络配置篇

阅读更多

配置

Important files

 

/etc/network/interfaces #ip, netmasks should be configured here.

/etc/resolv.conf        #dns server should be configured here.

/etc/hosts              #it is looked up before the dns is searched.

 

The IP address, Netmask, Network Address, Broadcast Address, and Gateway Address are typically specified via the appropriate directives in the file /etc/network/interfaces . The Nameserver Addresses are typically specified via nameserver directives in the file /etc/resolv.conf .

 

How to get the help?

 

man interfaces
man resolv.conf

man hosts

 

Special Nouns.

 

  • IP address The IP address is a unique identifying string expressed as four decimal numbers ranging from zero (0) to two-hundred and fifty-five (255), separated by periods, with each of the four numbers representing eight (8) bits of the address for a total length of thirty-two (32) bits for the whole address. This format is called dotted quad notation .

  • Netmask The Subnet Mask (or simply, netmask ) is a local bit mask, or set of flags which separate the portions of an IP address significant to the network from the bits significant to the subnetwork . For example, in a Class C network, the standard netmask is 255.255.255.0 which masks the first three bytes of the IP address and allows the last byte of the IP address to remain available for specifying hosts on the subnetwork.

  • Network Address The Network Address represents the bytes comprising the network portion of an IP address. For example, the host 12.128.1.2 in a Class A network would use 12.0.0.0 as the network address, where twelve (12) represents the first byte of the IP address, (the network part) and zeroes (0) in all of the remaining three bytes to represent the potential host values. A network host using the private IP address 192.168.1.100 would in turn use a Network Address of 192.168.1.0, which specifies the first three bytes of the Class C 192.168.1 network and a zero (0) for all the possible hosts on the network.

  • Broadcast Address The Broadcast Address is an IP address which allows network data to be sent simultaneously to all hosts on a given subnetwork rather than specifying a particular host. The standard general broadcast address for IP networks is 255.255.255.255, but this broadcast address cannot be used to send a broadcast message to every host on the Internet because routers block it. A more appropriate broadcast address is set to match a specific subnetwork. For example, on the private Class C IP network, 192.168.1.0, the broadcast address is 192.168.1.255. Broadcast messages are typically produced by network protocols such as the Address Resolution Protocol (ARP) and the Routing Information Protocol (RIP).

  • Gateway Address A Gateway Address is the IP address through which a particular network, or host on a network, may be reached. If one network host wishes to communicate with another network host, and that host is not located on the same network, then a gateway must be used. In many cases, the Gateway Address will be that of a router on the same network, which will in turn pass traffic on to other networks or hosts, such as Internet hosts. The value of the Gateway Address setting must be correct, or your system will not be able to reach any hosts beyond those on the same network.

  • Nameserver Address Nameserver Addresses represent the IP addresses of Domain Name Service (DNS) systems, which resolve network hostnames into IP addresses. There are three levels of Nameserver Addresses, which may be specified in order of precedence: The Primary Nameserver, the Secondary Nameserver, and the Tertiary Nameserver. In order for your system to be able to resolve network hostnames into their corresponding IP addresses, you must specify valid Nameserver Addresses which you are authorized to use in your system's TCP/IP configuration. In many cases these addresses can and will be provided by your network service provider, but many free and publicly accessible nameservers are available for use, such as the Level3 (Verizon) servers with IP addresses from 4.2.2.1 to 4.2.2.6.

 

Static Routing VS.Dynamic Routing

 

静态路由对动态路由

 

TCP VS. UDP

 

With Connections VS. without Connections.

 

DHCP

 

原理

 

请求IP租约:
        当客户机初始化一个TCP/IP,IP寻址信息广播一个DHCPISCOVER消息,这时客户机没有IP地址,所以它使用0.0.0.0作为源地址。因为 此时客户机不知道DHCP服务器的IP地址,所以它使用255.255.255.255作为目录地址。这样把消息广播到整个子网。


提供IP租约:
      DHCP服务器接受到discover的消息后,会回答一个DHCPFFER消息,这个消息包含了:客户机的硬件地址;所提供的IP地址;子网掩码;租约期限长度;服务器IP地址。
      DHCP客户机花费一秒钟的时间等待提供IP地址。如果它没有接收到提供的IP地址,它就将这个请求重新广播四次,广播时间间隔2、4、8、16秒,如 果客户机经过四次请求后,还没有接收到所提供的IP地址,它就采用从169.254.X.X地址。以后再每隔5分钟,该DHCP客户机都继续尝试发现一个 DHCP服务器。
选择IP租约
      DHCP客户机在接收到第一个提供(offer)消息之后,广播一个DHCPREQUEST消息作为响应,标识接受该提供。该消息包括发出提供IP信息 并且接受的服务器,然后,所有其他DHCP服务器将收回它们的提供,并将他们的IP地址保留给其他的IP租约请求使用。
确认IP租约
      发出接受提供消息的DHCP服务器将广播一个DHCP确认消息(DHCPPACK),用于确认这一成功的租约。

 

配置文件

 

/etc/dhcp3/dhclient.conf

 

Time Ajustment

Tool

 

1. ntpdate

2. ntpd


这两个工具还是不太会用,以后再研究。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics