Linux system basic Network commands

Source: Internet
Author: User

IP Network Setup Basics

Identify each connection to a network interface by assigning a worldwide unique 32bit identifier to each network interface. The IP address includes three parts: Internet network number, subnet number, host number. In the Internet, in that subnet, in that network interface. The network IP address "main" is divided into ABC three categories, the following is the coverage:  a class: 0.0.0.0-127.255.255.255, whose subnet mask is 255.0.0.0 (another way of labeling by subnet mask is/8, is to convert the subnet mask to binary 11111111.00000000.00000000.00000000, from left to 8 1) Class B: 128.0.0.0-191.255.255.255, whose subnet mask is 255.255.0.0 ( Another way of labeling by subnet mask is/16, that is, after the subnet mask is converted to binary, from the left number 16 1)  c class: 192.0.0.0-223.255.255.255, whose subnet mask is 255.255.255.0 ( Another way to label a subnet mask is/24, which is to convert the subnet mask to binary, from left to 24 1) subnet mask: It is a subnet that indicates which bits of an IP address are identified by the host, and which bits identify the host's bitmask. The subnet mask cannot exist alone, it must be used in conjunction with an IP address. The subnet mask has only one function, which is to divide an IP address into two parts: network address and host address. The IP network usually identifies the network itself with the smallest IP address, the largest IP address as the broadcast address of the network, and the remaining IP as the host in the network. An IP address is simply a routing table used to identify the host and really transmit the data. Gateways: For example, network A and network B, network a IP address range is "192.168.1.1~192." 168.1.254 ", the subnet mask is 255.255.255.0; the network b IP address range is" 192.168.2.1~192.168.2.254 "and the subnet mask is 255.255.255.0. In the absence of a router, there is no TCP/IP communication between the two networks, and even if two networks are connected on the same switch (or hub), the TCP/IP protocol will determine the two network hosts in different networks according to the subnet mask (255.255.255.0). To complete the communication between the two networks, it is necessary to pass through the gateway. If the host in Network A is aware that the host is not in the local network, the packet is forwarded to its own gateway, and then forwarded by the gateway to the Network B gateway, and the network B gateway is forwarded to a host in Network B. Network B forwards the packet to network a process as well.Query network card information: Ifconfig can query the network card information of the event. Lo represents the host itself, also known as the loopback interface. If you want to deliberately query a network interface, Ifconfig xxifconfig set an interface IP and mask format: ifconfig eth0 192.168.182.127 netmask 255.255.255.0 Configure dynamic IP: Dynamic Host Configuration Protocol enables dynamic allocation of IP resources. The process of configuring the dynamic IP by the computer: 1. Client looking for DHCP server: Client broadcasts request for dynamic IP; 2. The server provides an assignable IP address: All servers that receive DHCP for the request provide an IP to the client. 3. Client accepts IP address leasing: The client picks an IP from the provided IP address, notifies the DHCP server, and marks the selected DHCP server. 4. Server confirms lease IP: The selected DHCP server finally publishes a confirmation message, including the IP address, subnet mask, gateway, DNS server, and lease period. IP address in/etc/network/interfacesroute: To view the current routing table, the routing table is the function of transmitting data.
First line: Represents the network where natively is located. Second line: Indicates that the purpose of the transfer is the Internet. If the communication is within the LAN, the data is transmitted directly through the Eth0 interface. In the case of network traffic, the data is transferred to eth0 and then sent to the gateway by eth0 and then to the destination. Flags is a route flag that marks the state of the current network node. Another important role of the route is to re-modify the static routing table in the network where it resides. For example: To access the 172.20.0.0 network segment, you need to forward the packet through the gateway 192.168.182.2, you should add a sudo route add 172.20.0.0 netmask 255.255.0.0 GW in the static routing table of the current network 192.168.182.2 Dev eth0 command. Netstat: This command is included in the Net-tools software package to display the status of the current network in the system, including network connections, routing tables, interface statistics, maximum packet transmission units, and so on. To display the required information, you must explicitly give the second parameter of Netstat. Its command format is netstat "-r|-g|-i|-m|-s"hostname:The host configuration file is Etc/hostname, and after resetting, restarting the Linux system discovers that the user name will revert to the original name, because Linux initialization is based on etc/hostname data stored in the file when it restarts.

Linux system basic Network commands

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.