First, the basic concept:
1, agreement protocol: agreed to send and receive the data format understood by both parties.
2. Layering: Decompose complex tasks into simple tasks.
3, Mac:media access controls media access control.
Second, the network type:
1, CSMA/CD: The supervisor hears the network is idle immediately sends the information, the side sends the side listens.
The famous Ethernet uses this method to send information.
Simplex: Either the hair or the charge.
Duplex: Send and receive at the same time, non-impact.
CSMA/CD Equipment:
A, hub: hub, the receiving parties in the receiving information on the exclusive line, the other receiving parties can only wait. Visibility is less efficient.
The hub is rarely used now.
B, Bridge (only two ports): The bridge solves the problem of the conflict domain. Data can be staged, there is an internal address data table and there are multiple lines inside,
In receiving the information is a temporary establishment of a path, the connection is complete disconnection. High visibility efficiency.
Switch (Mac table) (multi-port bridge): But does not solve the broadcast domain problem.
Router (routing table): A problem that is used to partition the broadcast domain, which solves the problem of broadcast domain.
So it realizes the cross-network communication and effectively solves the problem of broadcast domain.
IP: Four segment: Network address and host address
A large network: 0 000 0000-0 111 1111:0-127, the first segment is the network address, and the first digit is 0, the other is the host address
B Medium Network: 10 00 0000-10 11 1111:128-191, the first two paragraphs are network addresses, and the first two bits are 10, the other is the host address
C Small Network: 110 0 0000-110 1 1111:192-223, the first three segment is the network address, and the first three bits are 110, the other is the host address
Host Address 1110 0000-1110 1111:224-239
Test network 1111 0000-1111 1111:240-255
All 0: Network address
All 1: Broadcast address
a:1-126:
2^7 a network
Hosts in each network: 2^24-2
Default Mask: 255.0.0.0
1 private network: 10.0.0.0
b:128-191
2^14 a network
Hosts in each network: 2^16-2
Default Mask: 255.255.0.0
16 Private Networks: 172.16.0.0-172.31.0.0
c:192-223
2^21 a network
Hosts in each network: 2^8-2
Default Mask: 255.255.255.0
256 Private Networks: 192.168.0.0-192.168.255.0
Subnet Mask: The network address is 1 and the host address is 0, so the subnet mask for the small company is 225.255.255.0
1-4: Communication, complete in kernel space resolution.
Physical layer: Physical media, encapsulating preamble.
Link layer: A data frame that encapsulates the source Mac and the target Mac, and can only complete communication from one physical device to another.
Network layer: Packet, IP protocol. The router works on this layer.
Transport layer: Used to mark the process as Port (0-65535), TCP/UDP protocol.
tcp:0-65535,transimission Control Protocol
udp:0-65535 user Datagram Protocol Subscriber Packet Protocol
Socket Socket: composed of ip+port.
5-7: Resource, completed in user space resolution.
Session Layer: Hold session
Presentation layer: Tag resource presentation.
Application Layer: Tags The resource, that is, what format the file is returned to the client.
TCP: There is a connection agreement to establish a logical connection.
to establish a connection: three handshake is required.
syn=1,ack=0,fin=0
syn=1,ack=1,fin=0
syn=1,ack=1,fin=0
Disconnect: Requires four handshake.
2, the Token Ring: the network of tokens.
Third, configure the host to access the TCP/IP network:
Ip/netmask (Mask)
Routing: Provides communication with a host other than the local network.
Host routes: Hosts
Network routing: Net
Default route: Defaults, also known as gateways.
DNS server:
The primary DNS server.
Alternate DNS server.
Host Name:
Four, network configuration:
1, static designation: Must configure the IP, netmask these two, configure these two items can complete the local network communication.
To complete communication with other networks, you must "route (Gateway) and DNS server"
1.1IP belongs to the kernel and is only displayed on the NIC.
1.2 Configure IP:
A, Network equipment service configuration file: Configure IP information, read at machine startup, complete IP configuration long-term effective.
B, Gui/tui: Text window/Graphics window.
Tui interface: #system-config-network-tui, the configuration will be saved to the configuration file when it is finished.
Note You can open the Tui interface by selecting Network-configration from Setup.
GUI: graphical interface. Click the mouse to configure. Very little use.
c, User space command-line tools: Immediate effect, the single will not be effective for a long time. Ifconfig and Iproute2
Ifconfig
Ifconfig No parameters: Displays information about all active interfaces, some of which show the following results:
Link Encap:ethernet Ethernet.
Hwaddr:mac Address
inet Addr:ip Address
Bcast: Broadcast Address
Mask: Mask
MTU: The maximum transmission unit, such as 1500.
RX: Receive message information.
TX: Transmits message information.
Lo: Local loopback address information.
Ifconfig Interface: Displays only information about the specified interface. such as Ifconfig eth0
Set IP with ifconfig:
Long format:
Ifconfig Interface IP netmask mask:ifconfig eth0 192.168.1.1 netmask 255.255.255.0
Short format:
Ifconfig Interface ip/mask:ifconfig eth0 172.16.100.7/16
Route: Displays routing information,
-N: Use number format to display, do not reverse address to host name.
Route add: Add route
-host host_ip GW next_hop (Dev Device)
-net net_addr
-net 0.0.0.0 Destination address is any address
Route del: Delete route
-host host_ip
-net net_addr
2. Dynamic configuration:
DHCP (Dynamic Host Configuration Protocol) server
/etc/resolv.conf
The DNS server points to: requires a/etc/resolv.conf configuration, with a maximum of three configurations.
NameServer DNS_SERVER_IP
Positive solution test: #dig-T A FQDN, such as #dig-t a www.baidu.com
Anti-Solution test: #dig-X IP, such as #dig-x 115.239.210.27
3, network equipment how to express:
Kernel Recognition Device: Driver
Ethernet setting: EthX, such as eth0,eth1,eth2 ...
4, Service script: Most for control run in the background daemon, receive parameters {Start|stop|restart|status}
Configure a service to boot automatically: Chkconfig srv_script_name on
Disable start-up automatically: Chkconfig srv_script_name off
Views:: Chkconfig--list Srv_script_name
Call mechanism: #/etc/init.d/script_name {start|stop|restart|status}
Network device-related service scripts: they are usually able to read the embryo files of a network device and implement management functions for which they are configured to take effect or fail.
CentOS 5/6: Network Services script:/etc/init.d/network
CentOS 6 also has a separate service script: Network Service script:/etc/init.d/networkmanager
Note: The configuration of the cluster needs to be shut down NetworkManager: Execute chkconfig NetworkManager off
There are two types of network configuration files (/etc/sysconfig/network-scripts):
Configure IP, mask, Gateway:
Ethernet: Ifcfg-ethx
Ppp:ifcfg-pppx
Configuration file for Ifcfg-ethx:
Device= "eth0": The device associated with this configuration, the device name should be consistent with the contents of the file name ifcfg-.
Bootproto= "DHCP": Boot protocol, {NONE|STATIC|DHCP (dynamic fetch) |BOOTP}
Hwaddr= "00:0c:29:8c:d0:8f": MAC address, to be consistent with the real Mac, can be omitted.
Ipv6init= "Yes": whether the IPV6 protocol address is initialized automatically.
Nm_controlled= "Yes": Accept NetworkManager Script control {Yes|no}
Onboot= "Yes": whether the shutdown automatically enables this network device {Yes|no}
Type= "Ethernet": device type, such as Ethernet,bridge
Uuid= "A9AA12E9-0450-497D-BC7D-909F1B0FD5CF": unique indication, can be omitted.
Ipaddr=192.168.127.135:ip Address
netmask=255.255.255.0: Mask
gateway=10.0.0.1: Default gateway
dns1=10.0.0.1
Userctl=no: Whether to allow normal users to enable or disable this network device.
Note: bootproto= "DHCP", the subsequent configuration of Ip/netmask/gateway/dns and so on is not valid because it is dynamically fetched.
Principle and dynamic IP acquisition of window.
The content configured in IFCFG-ETHX is permanently valid, the content configured through Ifconfig is temporarily valid, and the restart is invalidated.
To configure routing:
Route-ethx
Route-pppx
ROUTE-ETHX configuration file: path entry for one line configuration per line
Example: 192.168.0.0/24 via 172.6.100.177, with Route add-net 192.168.0.0/24 GW 172.6.100.177
The content configured in ROUTE-ETHX is permanently valid, the content configured with the route add is temporarily valid, and the restart is invalidated.
The configuration Format 1 is: DEST via Next_hop, as in the example above.
Configuration Format 2 is: Address#=dest
Netmaske#=netmask
Gateway#=gateway
For example: Format 1 with Format 2 is configured as follows:
address0=192.168.0.0
netmaske0=255.255.255.0
gateway0=172.6.100.177
5, Iproute2 (IP,SS): Pay attention to more complex use less.
6, network management or monitoring of the relevant tools:
Ping:
-C (count): Specifies the number of pings. such as: Ping-c 2 www.baidu.com
Traceroute: Gets the route (gateway) that passes from the current host to the destination host, but the general server prohibits traceroute.
Netstat: Execution speed is a bit slow.
-N: Number format display
Links to the-T:TCP agreement
Links to the-U:UDP agreement
-L: Monitoring status link
-A: links to all States
-P: Link related processes
-R: Show routing Table
Common combination: Netstat-tan
Netstat-tuan
Netstat-tunl
Netstat-rn
SS: Execution speed is faster than netstat.
-N: Number format display
Links to the-T:TCP agreement
Links to the-U:UDP agreement
-L: Monitoring status link
-A: links to all States
-P: Link related processes
-E: Show extended information
-M: Displays memory information used by the socket link
-O State {established established Link |listen listener link}
Ethtool EthX: Display Device interface properties, such as Ethtool eth0
Ethtool-s EthX: Displays device interface statistics.
Linux Network Configuration and management