Linux detailed network command configuration

Source: Internet
Author: User
Linux detailed network command configuration-Linux general technology-Linux technology and application information. The following is a detailed description. The document I read is quite good. I would like to share it with you. Of course it is not written by myself (it can be written, but there are ready-made documents... {: 2_97 :})
Network commands required for Linux
Ifconfig
1. Role
Ifconfig is used to view and change network interface addresses and parameters, including IP addresses, network masks, and broadcast addresses. The user has the permission to use ifconfig.
2. Format
Ifconfig-interface [options] address
3. Main Parameters
-Interface: Specifies the network interface name, such as eth0 and eth1.
Up: Activate the specified network interface card.
Down: Disable the specified network interface.
Broadcast address: Set the broadcast address of the API.
Pointopoint: enables point-to-point.
Address: Set the IP address of the specified interface device.
Netmask address: Set the subnet mask of the interface.
4. Application description
Ifconfig is a command line tool used to set and configure the NIC. To manually configure the network, this is a required command. The advantage of using this command is that you do not need to restart the machine. To assign the eth0 interface IP address 207.164.186.2 and activate it immediately, run the following command:
# Fconfig eth0 210.34.6.89 netmask 255.255.255.128 broadcast 210.34.6.127
This command is used to set the IP address, network mask, and local broadcast address of the network adapter eth0. If you run the ifconfig command without any parameters, the command displays information about all the machine's activation interfaces. The command with the "-a" parameter displays information about all interfaces, including interfaces that are not activated. Note that network device parameters configured using the ifconfig command will be lost after the machine is restarted.
To pause a network interface, you can use the down parameter:
# Ifconfig eth0 down
Ip
1. Role
Ip is a powerful network configuration tool in the iproute2 software package. It can replace some traditional network management tools, such as ifconfig and route, and use permissions as superusers. Almost all Linux releases support this command.
2. Format
Ip [OPTIONS] OBJECT [COMMAND [ARGUMENTS]
3. Main Parameters
OPTIONS is an option for modifying ip behavior or changing its output. All options start with a-character, which can be long or short. Currently, ip supports the options shown in table 1.
An OBJECT is an OBJECT for administrators to obtain information. Currently, the ip addresses are identified in table 2.
Table 1 ip support options
-V and-Version print the ip Version and exit.
-S,-stats, and-statistics Output more detailed information. If this option appears twice or multiple times, the output information is more detailed.
The-f,-family option is followed by the protocol type, including inet, inet6, or link, emphasizing the protocol type used. If there is not enough information to tell the protocol type used by the ip address, the default value is inet or any. Link is special. It indicates that no network protocol is involved.
-4 is short for-family inet.
-6 is short for-family inet6.
-0 is short for-family link.
-O and-oneline use single-line output for each record and replace the returned row with characters. This option is used if you need to use tools such as wc and grep to process ip output.
-R,-resolve queries the domain name resolution system and replaces the Host IP address with the obtained Host Name
COMMAND sets the operation performed on the specified object, which is related to the object type. Generally, ip addresses support adding, deleting, and displaying objects ). Some objects do not support these operations, or some other commands. For all objects, you can use the help command for help. This command lists the commands and parameter syntaxes supported by this object. If no operation command is specified for an object, the ip address uses the default command. Generally, the default command is list. If the object cannot be listed, the help Command is executed.
ARGUMENTS are some parameters of commands, which depend on objects and commands. Ip supports two types of parameters: flag and parameter. Flag is composed of a keyword. parameter is composed of a keyword and a value. For convenience, each command has a default parameter that can be ignored. For example, the dev parameter is the default parameter of the ip link command, so ip link ls eth0 is equal to ip link ls dev eth0. We will detail the use of each command in the following sections. The default parameters of the command will be marked with default.
4. Application Instance
Add the IP address 192.168.2.2/24 to the eth0 NIC:
# Ip addr add 192.168.1.1/24 dev eth0
Discard all data packets whose source address belongs to the 192.168.2.0/24 network:
# Ip rule add from 192.168.2.0/24 prio 32777 reject
Ping
1. Role
Ping checks the network interface status of the host. the permission is granted to all users.
2. Format
Ping [-dfnqrRv] [-c] [-I] [-I] [-l] [-p] [-s] [-t] IP Address
3. Main Parameters
-D: Use the Socket SO_DEBUG function.
-C: set the number of requests to respond.
-F: limit detection.
-I: specifies the number of seconds between sending and receiving information.
-I: the network interface uses the specified network interface to send data packets.
-L: The data packet that is sent before the request information is sent.
-N: only numbers are output.
-P: set the pattern for filling data packets.
-Q: The command execution process is not displayed, except for information related to the beginning and end.
-R: ignore common Routing tables and directly send data packets to the remote host.
-R: records the routing process.
-S: Set the packet size.
-T: Set the TTL value.
-V: displays the instruction execution process in detail.
The ping Command is the most commonly used network command. We usually use it to check whether the network is connected. It uses the ICMP protocol. However, sometimes we can view a web page in the browser, but we cannot ping it because some websites are in security consideration and have installed the firewall. In addition, you can try it on your computer and use the following method to make the system do not respond to ping:
# Echo 1>/proc/sys/net/ipv4/icmp_echo_ignore_all
Netstat
1. Role
Check the network status of Linux.
2. Format
Netstat [-acCeFghilMnNoprstuvVwx] [-A] [-- ip]
3. Main Parameters
-A -- all: displays the sockets in all connections.
-A: List the IP address and network type of the network connection.
-C -- continuous: continuously lists the network status.
-C -- cache: displays the cache information of the vro configuration.
-E -- extend: displays other network-related information.
-F -- fib: displays FIB.
-G -- groups: displays a list of members of multiple broadcast groups.
-H -- help: online help.
-I -- interfaces: displays the network interface information form.
-L -- listening: displays the Socket of the monitored server.
-M -- masquerade: displays disguised network connections.
-N -- numeric: the IP address is used directly instead of the Domain Name Server.
-N -- netlink -- symbolic: displays the symbolic connection name of the network hardware peripheral device.
-O -- timers: display the timer.
-P -- programs: displays the program identification code and program name using the Socket.
-R -- route: displays the Routing Table.
-S -- statistice: displays a statistical table of network work information.
-T -- tcp: displays the connection status of the TCP transmission protocol.
-U -- udp: displays the connection status of the UDP transmission protocol.
-V -- verbose: displays the command execution process.
-V -- version: displays the version information.
-W -- raw: displays the connection status of the RAW transmission protocol.
-X -- unix: it is the same as the specified "-A unix" parameter.
-- Ip -- inet: it is the same as the specified "-A inet" parameter.
4. Application Instance
Netstat is mainly used for Linux to view its own network conditions, such as the opened port, the user services, and the service status. It also displays the system route table and network interface status. It can be said that it is a comprehensive network status inspection tool. By default, netstat only displays the ports with established connections. To display all listening ports, use the-a parameter:
# Netstat-
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
Tcp 0 0 *: 32768 *: * LISTEN
Tcp 0 0 *: 32769 *: * LISTEN
Tcp 0 0 *: nfs *: * LISTEN
Tcp 0 0 *: 32770 *: * LISTEN
Tcp 0 0 *: 868 *: * LISTEN
Tcp 0 0 *: 617 *: * LISTEN
Tcp 0 0 *: mysql *: * LISTEN
Tcp 0 0 *: netbios-ssn *: * LISTEN
Tcp 0 0 *: sunrpc *: * LISTEN
Tcp 0 0 *: 10000 *: * LISTEN
Tcp 0 0 *: http *: * LISTEN
......
As shown above, this host provides HTTP, FTP, NFS, MySQL, and other services at the same time.
Telnet
1. Role
Telnet indicates to enable the terminal job and log on to the remote host. Telnet is a Linux Command and a protocol (Remote logon protocol ).
2. Format
Telnet [-8 acdEfFKLrx] [-B] [-e] [-k] [-l] [-n] [-S] [-X] [host name IP Address <通信端口> ]
3. Main Parameters
-8: 8 characters are allowed, including input and output.
-A: Try to automatically log on to the remote system.
-B: use an alias to specify the remote host name.
-C: Do not read the. telnetrc file in the user's exclusive directory.
-D: Start the troubleshooting mode.
-E: Set the escape character.
-E: filter out the escape characters.
-F: the effect of this parameter is the same as that of the specified "-F" parameter.
-F: When Kerberos V5 is used for authentication, you can add this parameter to upload the authentication data of the local host to the remote host.
-K: When Kerberos authentication is used, add this parameter to allow the remote host to use the specified domain name instead of the domain name of the host.
-K: do not automatically log on to the remote host.
-L: Specifies the name of the user to log on to the remote host.
-L: 8-character data can be output.
-N: Specifies the file record information.
-R: Use a user interface similar to the rlogin command.
-S: service type. Set the IP address TOS required for the telnet connection.
-X: if the host supports data encryption, use it.
-X: Disable the specified authentication format.
4. Application description
You can use the telnet command to remotely log on and communicate with each other. A user logs on to a remote computer over the network, just like logging on to a local machine and executing commands. To log on to the remote computer through telnet, you must know the valid user name and password on the remote computer. Although some systems do provide the logon function for remote users, the Operation permissions of guests must be restricted for security reasons. Therefore, in this case, few functions can be used.
Telnet only provides terminal Simulation for common terminals, but does not support graphic environments such as X-Window. When remote users are allowed to log on, the system usually places these users in a restricted Shell to prevent the system from being maliciously or accidentally damaged. You can also use telnet to log on from a remote site to your computer, check emails, edit files, and run programs, just like logging on locally.
Route
1. Role
Route indicates that the route table is manually generated, modified, and viewed.
2. Format
# Route [-add] [-net |-host] targetaddress [-netmask Nm] [dev] If]
# Route [-delete] [-net |-host] targetaddress [gw Gw] [-netmask Nm] [dev] If]
3. Main Parameters
-Add: add a route.
-Delete: delete a route.
-Net: A route arrives at a network, not a host.
-Host: The route arrives at a host.
-Netmask Nm: Specifies the subnet mask of the route.
Gw: the gateway of the specified route.
[Dev] If: forces the specified interface of the route chain.
4. Application Instance
The route command is used to view and set the route information of the Linux system for communication with other networks. To achieve communication between two different subnets, you need a router that connects two networks or a gateway that is located in both networks.
In Linux, routing is usually set to solve the following problems: the Linux system has a gateway in a LAN that allows machines to access the Internet, then you need to set the IP address of this machine to the default route of the Linux machine. Use the following command to add a default route:
Route add 0.0.0.0 192.168.1.1
Finger
1. Role
Finger is used to query the login account information on a host. It usually displays the user name, main directory, stagnation time, Logon Time, logon Shell, and other information. The permission is granted to all users.
2. Format
Finger [Option] [user] [user @ host]
3. Main Parameters
-S: displays the User Registration Name, actual name, terminal name, write status, stagnation time, Logon Time, and other information.
-L: In addition to the information displayed with the-s option, it also displays information such as the user's home directory, logon Shell, email status, and under the user's home directory. plan ,. project and. the content of the forward file.
-P: Except for not displaying the. plan and. project files, it is the same as the-l option.
4. Application Instance
Use finger on a computer:
[Root @ localhost root] # Finger
Login Name Tty Idle Login Time Office Phone
Root tty1 2 Dec 15 11
Root pts/0 1 Dec 15 11
Root * pts/1 Dec 15 11
5. Application description
To query user information on a remote machine, you must add "@ host name" after the user name, in the format of [user name @ host name, however, the network host to be queried must support running the finger daemon.
Nslookup
1. Role
The nslookup command is used to query the IP address of a machine and its corresponding domain name. Grant permissions to all users. It usually requires a Domain Name Server to provide domain name services. If you have configured a Domain Name Server, you can use this command to view the domain name corresponding to the IP addresses of different hosts.
2. Format
Nslookup [IP Address/domain name]
3. Application Instance
(1) Use the nslookup command on the Local Computer
$ Nslookup
Default Server: name.cao.com.cn
Address: 192.168.1.9

Enter the Domain Name of the IP address to be queried after the symbol ">" and press Enter. To exit the command, enter "exit" and press Enter.
(2) run the nslookup command to test named.
Enter the following command:
Nslookup
Then enter the switched nslookup environment. If named is started normally, nslookup will display the address and domain name of the current DNS server. Otherwise, named cannot be started properly.
The following describes some basic DNS diagnostics.
◆ Check for forward DNS resolution. Enter a host name with a domain name at the nslookup prompt, for example, hp712.my.com. nslookup should be able to display the IP address corresponding to this host name. If only hp712 is entered, nslookup automatically adds the my.com domain name and answers the corresponding IP address according to the definition of/etc/resolv. conf.
◆ Check reverse DNS resolution. Enter an IP address at the nslookup prompt, for example, 192.22.33.20. nslookup should be able to answer the host name corresponding to the IP address.
◆ Check the MX Email Address Record and enter at the nslookup prompt:
Set q = mx
Enter a domain name, my.com and mail.my.com, and nslookup should be able to answer the corresponding email server address, that is, support.my.com and support2.my.com.

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.