Linux - Network Configuration

  • basic settings:

First, set the virtual machine as a bridge, click Settings

 

Get the following interface:

 

Click on Network Adapter to change to Bridged.

 

After selecting the current network connection, perform basic settings, the process is not described in detail.

2. Commonly used setting commands

1. Set the host name

Command: hostname

Format: hostname [hostname]

Function: View or modify the hostname of the computer

 

2. Configure network interface commands

Command: ifconfig

The full name is network interface configuring, which is used to configure the network card information in the Linux system.

Format: ifconfig [network interface name] [IP address] [netmask subnet mask] [up|down]

Function: display. Check, configure or monitor network interfaces, without parameters, it means to display the status of each network interface that is currently started

For example: ifconfig eth0 192.168.1.23 netmask 255.255.255.0

  1. Ifconfig eth0 up to open the network card

Note: After turning on the network card, you need to connect to eth0 to access the Internet.

  1. Ifconfig eth0 down turns off the network card

3. Check the network connection status

Command: netstat

Format: netstat [options]

Function: View various statuses of the network

Common options:

-a (all) displays all options, and does not display LISTEN related by default

-t (tcp) only show tcp related options

-u (udp) only show udp related options

-n Refuse to display aliases, and all numbers that can be displayed are converted into numbers.

-l list only the service status in Listening (listening)

-p show the name of the program that established the relative link

-r display routing information, routing table

-e Display extended information, such as uid, etc.

-s statistics by each protocol

-c Execute the netstat command at regular intervals.

Tip: The status of LISTEN and LISTENING can only be seen with -a or -l

Examples of practical commands

(1) List all ports (including listening and unlistening)

list all ports netstat -a

list all tcp ports netstat -at

list all udp ports netstat -au

(2) List all Sockets in listening state

  Only show listening ports netstat -l

  Only list all listening tcp ports netstat -lt

  Only list all listening udp ports netstat -lu

  List only all listening UNIX ports netstat -lx

(3) Display statistics for each protocol

  Display statistics for all ports netstat -s

  Display statistics for TCP or UDP ports netstat -st or -su

(4) Display PID and process name in netstat output netstat -p

netstat -p can be used together with other switches, you can add "PID/process name" to the output of netstat, so that you can easily find the program running on a specific port when debugging.

(5) Do not display host, port and user name (host, port or user) in netstat output

When you don't want the host, port and username to be displayed, use netstat -n. Numbers will be used in place of those names.

It can also speed up the output, because no comparison query is required.

# netstat -an

If you just don't want one of these three names to be displayed, use the following command

# netsat -a --numeric-ports

# netsat -a --numeric-hosts

# netsat -a --numeric-users

4.ping command

The Linux ping command is used to detect hosts.

Executing the ping command will use the ICMP transmission protocol to send out a message requesting a response. If the network function of the remote host is normal, it will respond to the message, thus knowing that the host is operating normally.

Command format: ping [parameter] [host name or IP address]

Command function: The ping command is used to: determine the status of the network and each external host; track and isolate hardware and software problems; test, evaluate and manage the network. If the host is running and connected to the network, it responds to the echo signal. Each echo request consists of an Internet Protocol (IP) and ICMP header, followed by a tim structure, and enough bytes to fill the packet. The default is to send echo signal requests continuously until an interrupt signal (Ctrl-C) is received.

The ping command sends one datagram per second and prints one line of output for each response received. The ping command calculates round-trip time and packet loss statistics, and displays a brief summary after completion. The ping command ends when the program times out or when a SIGINT signal is received. The Host parameter is either a valid hostname or an Internet address.

Command parameters:

-d Use SO_DEBUG function of Socket.

-f limit detection. Send lots and lots of network packets to a machine quickly and see its response.

-n Output only numeric values.

-q Do not display any information about the transmitted packet, only the final result.

-r Ignore the ordinary Routing Table, and send the data packet directly to the remote host. Usually it is to check whether there is a problem with the network interface of the machine.

-R Log the routing process.

-v Displays the execution of the command in detail.

<p>-c count: Stop after sending the specified number of packets.

-i seconds: set the interval to send a network packet to a machine in seconds, the default value is to send once a second.

-I network interface: Send packets using the specified network interface.

-l Preload: Set the packet sent before sending the requested information.

-p template style: set the template style to fill the packet.

-s number of bytes: specify the number of data bytes to send, the default value is 56, plus the 8-byte ICMP header, a total of 64 ICMP data bytes.

-t survival value: Set the size of the survival value TTL.

Example:

Ping gateway ping -b 192.168.120.1 (ping -b broadcast ip address, to ping the broadcast address, the parameter "b" must be added.)

Ping the specified number of times ping -c 10 192.168.120.20

Ping with time interval and times limit ping -c 10 -i 0.5 192.168.120.206

Ping the site on the public network through the domain name ping -c 5 www.58.com

 

What does ping -i 3 -s 1024 -t 255 192.168.120.206 do?

(-i 3 send period is 3 seconds -s set the size of sending packet to 1024 -t set TTL value

practise:

Create a new user wang, set the password to 123456, and add it to the root group. Write down the commands used.

 

        Set the IP address of the current computer to 192.168.1.123, and the subnet mask to 255.255.255.0. Write down the commands used.

 

Count the number of bytes and lines in the /etc/passwd file, and write out the commands used.

 

will hello! Write commands to /home/wang/test.txt (except vi and vim editors).

 

The command to view the hostname of the current linux server.

 

The command to ping the destination IP 192.168.2.245 consecutively is 10 times.

 

The command to view the current host TCP protocol connection status.

 

Command to test whether httpd is installed.

 

Command to uninstall named package.

 

View commands for the current directory.

 

A command to display the entire contents of the history command table.

 

Append the contents of /etc/passwd to the command in the file aaa.

 

View the commands in the first 10 lines of the /etc/passwd file.

Check the commands in the last 10 lines of /etc/vsftpd/vsftpd.conf.

 

Command to view process status.

 

Command to list background jobs.

 

A command to bring a background job with job ID 5 to the foreground.

 

The command to add the executable attribute to the file file1.

 

In order to achieve the command that the owner of the file sudent.txt has read (r) and write (w) permissions, while other users can only have read-only access.

 

Command to display operating system core version details.

 

How to check which group a user zhang belongs to.

 

Create a user with the pinyin abbreviation of your last name.

 

Enter the user's home directory and display the current path.

 

Copy the file /etc/group to the user's home directory, and the file name remains unchanged.

 

Count the number of lines, words, and characters in the file /etc/fstab.

 

Check the last 5 lines of the /etc/passwd file.

 

Create the normal file /home/abc.

 

Modify the properties of /home/abc: the owner has all permissions, and users in the same group and other users have read and write permissions.

 

Displays the current time.

Write the command to shut down the system after 1 minute.

 

 

Create a new user with your student ID as the account.

The background startup program gedit.

 

Add a user group named wuxi.

​​​​​​​

 Modify the newly created user to belong to the wuxi group.

 

Guess you like

Origin blog.csdn.net/qq_52117201/article/details/128378141