Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the network commands in linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "what are the network commands in linux". In daily operation, I believe many people have doubts about the network commands in linux. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "what are the network commands in linux?" Next, please follow the editor to study!

Linux has built-in a variety of network commands: 1, ping, used to test whether the TCP/IP network is smooth or test the network connection speed; 2, telnet, used to log on to the remote host and manage the remote host; 3, netstat, used to print the status information of the network system in the Linux; 4, ifconfig, etc.

The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.

There are many kinds of network commands under Linux. Here are some common network commands.

Common network commands under Linux

1 、 ping

The ping command is used to test whether the TCP/IP network is open or to test the speed of the network connection. It is very useful to determine whether the network is connected correctly and the condition of the network connection. To put it simply, ping is a test program. If ping runs correctly, it can generally eliminate the problems existing in the network access layer, network card, Modem input and output lines, cables and routers, thus narrowing the scope of the problem.

The principle of ping command is that according to the unique IP address of the computer, when the user sends a data packet to the destination address, the other party will return a data packet of the same size. According to the returned data packet, the user can determine the existence of the destination host and preliminarily judge the operating system of the destination host.

Usage

(1) Command format

Ping (option) destination address

The destination address refers to the IP address, hostname, or domain name of the computer under test. The ping command contains 12 parameters, all of which can be viewed by executing ping. As shown below:

(2) examples

Note: the ping command under Linux is different from the ping command under Windows. Ctrl+C is required to terminate.

(the difference between the ping command under Linux and Windows)

(3) option

-d: use the SO_DEBUG function of Socket

-c: sets the number of times the request response is completed

-f: limit detection

-I: specify the interval between sending and receiving messages

-L: sends out packets using the specified network interface

-l: sets the packet sent before the request information is sent

-n: output only numeric values

-p: sets the template style for filling packets

-Q: does not display the instruction execution process, except for the relevant information at the beginning and end

-r: ignore the ordinary Routing Table and send the packet directly to the remote host

-R: record the routing process

-s: sets the size of the packet

-v: shows the execution of the instruction in detail.

-t: sets the size of the survival value TTL

Talk about the-c and-I parameters.

Where-c count, that is, the number of ping;-I interval interval, the time space between each ping

2 、 telnet

The telnet command is used to log in to the remote host and manage the remote host. Because telnet uses plaintext to send messages, the security is not good. Many Linux servers do not open telnet services, but use a more secure ssh way.

Usage

(1) the format of the command:

Telnet (option) (parameter)

(2) examples

(3) parameters

Remote host: specify the remote host to log in to manage

Port: specifies the port number used by the TELNET protocol

(4) option

-8: allows the use of 8-bit character data, including input and output

-a: try to log in to the remote system automatically

-b: specify the remote host name using an alias

-c: do not read .telnetrc files in the user-specific directory

-d: start debug mode

-e: set detach character

-E: filter out detached characters

-f: the effect of this parameter is the same as the specified "- F" parameter

-F: add this parameter to upload the authentication data of the local host to the remote host when using Kerberos V5 authentication

-k: when using Kerberos authentication, add this parameter to make the remote host use the specified domain name instead of the host's domain name

-K: do not automatically log in to the remote host

-l: specify the user name to log in to the remote host

-L: allows the output of 8-bit character data

-n: specify file record related information

-r: use a user interface similar to rlogin instructions

-S: set the ip TOS information required for telnet connection

-x: assuming that the host has a feature that supports data encryption, use it

-X: closes the specified authentication form.

3 、 netstat

The netstat command is used to print the status information of the network system in Linux, so that you can know the network situation of the whole Linux system.

Usage

(1) Command format

Netstat (option)

(2) option

-an or-all: displays the Socket in all connections

-An or -: list the relevant addresses in the connection of this network type

-c or-continuous: continuously lists network status

-C or-cache: displays the cache information configured by the router

-e or-extend: displays other relevant information about the network

-F or-fib: displays FIB

-g or-groups: displays the list of group members with multi-broadcast function

-h or-help: online help

-I or-interfaces: displays the web interface information form

-l or-listening: displays the Socket of the server under monitoring

-M or-masquerade: shows a camouflaged network connection

-n or-numeric: use the ip address directly, not through the domain name server

-N or-netlink or-symbolic: displays the symbolic connection name of the network hardware peripheral

-o or-timers: display timer

-p or-programs: displays the program identification number and program name that are using Socket

-r or-route: displays Routing Table

-s or-statistice: displays statistical tables of network work information

-t or-tcp: displays the connection status of the TCP transport protocol

-u or-udp: displays the connection status of the UDP transport protocol

-v or-verbose: displays the instruction execution process

-V or-version: displays version information

-w or-raw: displays the connection status of the RAW transport protocol

-x or-unix: this parameter has the same effect as specifying the "- A unix" parameter

-ip or-inet: this parameter has the same effect as specifying the "- An inet" parameter

(3) examples

Netstat-a / / list all ports netstat-at / / list all tcp ports netstat-au / / list all udp ports

Show all TCP ports here

Netstat-l / / Show only listening ports netstat-lt / / list only all listening tcp ports netstat-lu / / list only all listening udp ports

Compared with the figure above, you can see the TCP port that only shows the listening status

4 、 ifconfig

The ifconfig command is used to configure and display the network parameters of the network interface in the Linux kernel. The network card information configured with the ifconfig command will not exist after the machine is restarted after the network card is rebooted. If you want to keep the above configuration information on your computer forever, you need to modify the configuration file of the network card.

Usage

(1) Command format

Ifconfig (parameter)

(2) examples

Eth0 indicates the first network card, and you can see the information of this network card.

HWaddr represents the physical address of the network card, that is, the MAC address. You can see that the current MAC address of this network card is: 00:0C:29:A7:C0:6C

Inet addr is used to represent the IP address of the network card. The IP address of this network card is: 192.168.1.106

Broadcast address Bcast:192.168.1.255

Mask address Mask:255.255.255.0

Lo is the loopback address of the host, which is generally used to test a network program, but does not want users of the local area network or external network to view it, so it can only run and view the network interface used on this host.

(3) parameters

Add: sets the ip address of the network device IPv6

Del: delete the IP address of the network device IPv6

Down: shuts down specified network devices

Io_addr

< I/O地址>

: set the Istroke O address of the network device

Irq

< IRQ地址>

: set the IRQ of network devices

Media: sets the media type of a network device

Mem_start: sets the starting address occupied by the network device in the main memory

Metric: specifies the number to be added when calculating the number of forwarding packets

Mtu: set the MTU of a network device

Netmask: sets the subnet mask for network devices

Tunnel: establish a tunnel communication address between IPv4 and IPv6

Up: starts the specified network device

-broadcast: packets to be sent to the specified address are treated as broadcast packets

-pointopoint: establish a direct connection with the network device at the specified address. This mode has the function of confidentiality.

-promisc: turns off or starts the promiscuous mode of the specified network device

IP address: specifies the IP address of the network device

Network device: specifies the name of the network device.

5 、 route

The route command is used to display and set the network routing table in the Linux kernel, and the routes set by the route command are mainly static routes.

It should be noted that the route will not be saved permanently by executing the route command directly under the command line, and the route will become invalid when the network card is restarted or the machine is rebooted. You can add the route command in * / etc/rc.local to ensure that the route setting is permanent.

Usage

(1) Command format

Route (option) (parameter)

(2) option

-A: set the address type

-C: printing caches the routes of the Linux core

-v: details mode

-n: do not perform DNS reverse lookup, but directly display IP addresses in numeric form

-e: display the routing table in netstat format

-net: to the routing table of a network

-host: to the routing table of a host.

(3) parameters

Add: add the specified route record

Del: deletes the specified route record

Target: destination network or destination host

Gw: setting default gateway

Mss: sets the maximum block length (MSS) of TCP in MB

Window: specifies the size of the TCP window for TCP connections through the routing table

Dev: network interface represented by the routing record

(4) examples

Shows the current route, as can be seen from the figure with the option-n added

Delete and add settings default gateway

6 、 arp

The arp command is used to manipulate the host arp buffer. It can display all entries in the arp buffer, delete specified entries, or increase the correspondence between static IP addresses and MAC addresses.

Usage

(1) Command format

Arp (option) (parameter)

(2) option

-a: displays all entries of the arp buffer

-H: specifies the type of address used by the arp instruction

-d: removes the arp entry for the specified host from the arp buffer

-D: use the hardware address of the specified interface

-e: displays entries in the arp buffer in the Linux display style

-I: specifies the network interface on which to operate the arp buffer

-s: sets the static mapping between the IP address and the MAC address of the specified host

-n: digitally displays entries in the arp buffer

-v: displays detailed arp buffer entries, including statistics for buffer entries

-f: sets the static mapping of the host's IP address to MAC address

(3) parameters

Host: queries the arp entry of the specified host in the arp buffer.

(4) examples

7 、 traceroute

The traceroute command is used to track the entire path of a packet as it travels across the network, and the default packet size is 40 bytes.

Through traceroute, we can know the path of information from your computer to the host on the other side of the Internet. Of course, each packet from the same starting point (source) to a certain same destination (destination) may take a different path, but basically, most of the time the route is the same.

Traceroute measures how long it takes to send a small packet to the destination device until it returns. The traceroute of each device on a path is tested 3 times. The output includes the time of each test (ms) and the name of the device (if any) and its ip address

Usage

(1) Command format

Traceroute (option) (parameter)

(2) option

-d: use Socket-level troubleshooting capabilities

-f: sets the size of the survival value TTL of the first inspection packet

-F: set do not break bit

-g: set source routing gateways. A maximum of 8 can be set.

-I: send packets using the specified network interface

-l: use ICMP responses instead of UDP data information

-m: sets the size of the maximum survival value TTL for detection packets

-n: use the IP address instead of the hostname directly

-p: sets the communication port of the UDP transport protocol

-r: ignore the ordinary Routing Table and send the packet directly to the remote host

-s: sets the TOS value of packets sent by the local host

-v: shows the execution of the instruction in detail

-w: sets the time to wait for the remote host to report back

-x: turn the correctness check of the packet on or off

(3) parameters

Host: specify the destination host IP address or hostname

(4) examples

From the figure, we can see that the record starts from 1 according to the serial number, and each record is a hop, and each hop represents a gateway. We can see that each row has three times in ms, which is actually the default parameter of-Q. Probe the time after the gateway responds after sending three packets to each gateway

In the later section we will see that some lines are represented by asterisks. When this happens, it may be that the firewall has blocked the return information of ICMP, so we can't get any relevant packet return data.

8 、 host

The host command is a commonly used query tool for analyzing domain names, which can check whether the domain name system is working properly.

Usage

(1) Command format

Host (option) (parameter)

(2) option

-a: displays detailed DNS information

-c: specifies the query type. The default is "IN".

-C: query the complete SOA record of the specified host

-r: do not use recursive query method when querying domain names

-t: specify the query domain name information type

-v: displays the details of instruction execution

-a: displays detailed DNS information

-w: if the domain name server does not give a reply, wait until the domain name server gives an answer

-W: specify the maximum time for domain name query. If the domain name server does not give a reply within the specified time, the exit instruction will be issued.

-4: use IPv4

-6: use IPv6

(3) parameters

Hosts: host information to be queried

(4) examples

9 、 tcpdump

The tcpdump command is a tool for grabbing packets. It can print the header information of all packets passing through the network interface, or you can use the-w option to save the packet to a file for later analysis.

Usage

(1) Command format

Tcpdump (option)

(2) option

-a: try to convert network and broadcast addresses to names

-c: after receiving the specified number of packets, the dumping operation is stopped.

-d: convert the compiled packet encoding to a readable format and dump it to standard output

-dd: converts the compiled packet encoding to C format and dumps it to standard output

-ddd: converts the compiled packet encoding to decimal number format and dumps it to standard output

-e: display the header at the connection level on each column of dumping data

-f: use numbers to display Internet addresses

-F: specify the file that contains the expression

-I: sends a packet using the specified network cross section

-l: buffer using standard output columns

-n: do not translate the network address of the host into a name

-N: domain name is not listed

-O: do not optimize packet coding

-p: keep the web interface out of promiscuous mode

-Q: fast output, listing only a small number of transport protocol information

-r: read packet data from the specified file

-s: sets the size of each packet

-S: lists TCP correlation numbers with absolute rather than relative values

-t: no timestamp is displayed on each column of dumping data

-tt: displays an unformatted timestamp on each column of dumping data

-T: forces the packet specified by the expression to be translated into the set packet type

-v: displays the instruction execution process in detail

-vv: show instruction execution in more detail

-x: list packet data in hexadecimal code

-w: writes packet data to the specified file.

(3) examples

Tcpdump: monitors all packets flowing on the first network interface (with the-I option, which monitors the specified network interface)

At this point, the study of "what are the network commands in linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report