Preface:
Take notes on network-related knowledge, including IP address A/B/C classification, static address configuration/DNS configuration, and nic information viewing.
*) Division of A/B/C/D network addresses
IP address = network address + host address or IP address = Host address + subnet address + host address
IPv4 addresses can be divided into five types: A/B/C/D/E
Class A address:
It consists of a 1-byte network address and a 3-byte host address. The maximum network address must be "0" and ranges from 1.0.0.0 to 126.0.0.0. there are 126 Class A networks, each of which can accommodate more than 0.1 billion hosts.
Class B address:
Consists of two bytes of network address and two bytes of host address, the maximum network address must be "10", the address range from 128.0.0.0 to 191.20.255. there are 16382 Class B networks, and each network can accommodate more than 60 thousand hosts.
Class C address:
Consists of 3 bytes of network address and 1 byte of host address, the maximum network address must be "110", range from 192.0.0.0 to 223.255.255.255. the Class C network can accommodate more than 2.09 million hosts, and each network can accommodate 254 hosts.
Class D address
It is used for multicast. The first byte starts with "1110" and is a reserved address.
Class E address
It starts with "1110" and is reserved for future use.
Special address
The 0.0.0.0 address corresponds to the current host, and 255.255.255.255 is the broadcast address of the current subnet.
In the three main types of IP addresses, each of the three regions is reserved as private addresses. The address ranges are as follows:
Class A address: 10.0.0.0 ~ 10.20.255.255
Class B address: 172.16.0.0 ~ 172.31.255.255
Class C address: 192.168.0.0 ~ 192.168.255.255
This private address is used for LAN networks, such as schools (Class A), Internet cafes (Class B), and dormitories (Class C). Nat is used for Internet access.
*) Static Address Configuration
Suppose the application scenario is:
Centos 6.4 system, LAN is a Class B private address, Gateway: 172.16.0.1, subnet mask: 255.255.252.0
1. Idle IP detection
Destination host unreachable, indicating that the IP address is not occupied
2. display the NIC Device List
Ifconfig-
3. Edit related Nic Devices
Take eth0 as an Example
Vim/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0ONBOOT=yesBOOTPROTO=staticIPADDR=172.16.1.211GATEWAY=172.16.0.1NETMASK=255.255.252.0
Configuration file corresponding to the IP address of the NIC:
Device = # describe the device alias corresponding to the NIC, for example, it is eth0bootproto = # Set the way the NIC gets the IP address in the ifcfg-eth0 file, possible options are static, DHCP or BOOTP, corresponding to the static IP address, the IP address obtained through DHCP protocol, IP address obtained through the BOOTP protocol broadcast = # corresponding subnet broadcast address hwaddr = # corresponding Nic physical address ipaddr = # If you set the nic ip address acquisition method to static, this field specifies the IP address of the network adapter ipv6init = no00006_autoconf = nonetmask = # network mask of the network adapter network = # network address of the network adapter onboot = yes # whether to set this network when the system starts. interface, when set to yes, the device is activated when the system starts.
4. Network restart
Service Network restart
5. Verify
In addition to this configuration method, ifconfig can also be used for configuration, but this will become invalid when the machine is restarted.
Ifconfig <interface> <ip> HW [hw addr] netmask [net mask] broadcast [Broadcast] [up/down]
Ifconfig eth0 172.16.1.106 netmask 255.255.252.0 up
*) Fqns settings
Assume that the local IP: 172.16.1.106, Host Name: tw-node6
1. edit/etc/sysconfig/Network
Networking = yeshostname = tw-node6 # The value of hostname is the host name
2. edit/etc/hosts
Add the following lines
172.16.1.106tw-node6
It is best to ensure that the bound Host Name and/etc/sysconfig/network are consistent under/etc/hosts.
*) DNS settings
# Vi/etc/resolv. conf
Configuration content instance:
Nameserver 8.8.8.8 # Google Domain Name Server nameserver 8.8.4.4 # Google Domain Name Server
*) View and modify the NIC bandwidth
1. View network card bandwidth
Ethtool eth0
Speed: 1000 Mb/s, that is, the bandwidth of the network card.
Of course, the NIC provides the following 10 Base/100 Base/1000 Base options, and the actual Nic bandwidth depends on the network environment and negotiation.
The MII-tool-V command is also executed.
2. Modify the NIC bandwidth
Ethtool-s ethx
[Speed 10 | 100 | 1000] // sets the speed of the network port to 10/100/1000 m
[Duplex half | Full] // sets the network port half/Full Duplex
[Autoneg on | off] // sets whether the network port is self-negotiated.
Reference link:
Http://blog.csdn.net/panjunnn/article/details/5653388
Http://pangxiaoming1020.blog.163.com/blog/static/35058493201382211353073/
Http://hi.baidu.com/yanghaiquanyyy/item/bfc8bace1ed78136a0b50a9b