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

Linux basic Network Settings

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

First, the main points of content:

1. View network settings

2. Test the network connection

3. Use network configuration commands

4. Modify the network configuration file

Second, view network settings

1. View the network interface information ifconfig

View information for all active network interfaces

Execute the ifconfig command

View specified network interface information

Ifconfig network interface number

2. Check the host name hostname

[root@localhost ~] # hostname View hostname

[root@localhost ~] # hostnamectl set-hostname http01 modify hostname

3. View the routing table entry route

Route command: view or set routing table information in the host

Route [- n] or direct route

4. Check the network connection netstat

Netstat command: view the network connection status, routing table, interface statistics and other information of the system

Netstat [options]

Common option

-a: list all

-n: digital representation

-p: protocol

-t: list tcp protocol connections

-u: list udp protocol connections

-r: list routing table information

Neistat-ntap view all protocol interface information in tcp in digital form

Neistat-nuap view all protocol interface information in udp in digital form

Neistat-r View routing table information just like route

Third, test the network connection

A, ping command: test network connectivity

Ping [option] target host

B. Trace packet traceroute

Traceroute command: test the network node passing from the current host to the destination host (used when judging a fault)

Tracerouter destination host address

C. Domain name resolution nslookup

Nslookup command: test DNS domain name resolution

Nslookup destination host address

Fourth, the way to set network parameters

1. Temporary configuration-use commands to adjust network parameters

Simple, fast, can directly modify the running network parameters

Generally, it can only be used in the process of debugging the network.

After the system is rebooted, the changes will be invalidated

2. Fixed settings-modify network parameters through configuration files

Modify the configuration file of each network parameter

Suitable for setting fixed parameters on the server

It will not take effect until the network service is reloaded or restarted.

1. Set the network interface parameter ifconfig

A. Set the IP address of the network interface and subnet mask (temporary setting)

Ifconfig interface number IP address [netmask subnet mask]

Ifconfig network interface IP address [/ mask length]

B. disable or reactivate the network card

Ifconfig network interface up

Ifconfig network interface down

C. Set up virtual network interface (different ip share one network card and realize multiple IP addresses)

Ifconfig interface number: serial number IP address

2. Set routing record route

A. Route record added to the specified network segment

Route add-net network segment address gw IP address

B. Delete the route record to the specified network segment

Route del-net network segment address

C. Delete the default gateway record in the routing table

Route del default gw IP address

D. Add default gateway records to the routing table

Route add default gw IP address

Modify the network configuration file (fixed settings)

A, network interface configuration file

/ etc/sysconfig/network-scripts/ directory

B, enable, disable network interface configuration

Systemctl restart network restart

C, disable, enable network interface

Ifdown ens33

Ifup ens33

D, domain name resolution profile

/ etc/resolv.conf file

Save the IP address of the DNS server you need to use on this machine

[root@localhost ~] # vim / etc/sysconfig/network configuration hostname file

E. Local host mapping file

/ etc/hosts file

Save the mapping record between hostname and IP address

Comparison between hosts File and DNS Server

By default, the system first looks for the parsing record from the hosts file

The hosts file is only valid for the current host

Hosts files speed up access by reducing the DNS query process

[root@localhost ~] # vim / etc/hosts configuration dns resolution of the current host

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

Servers

Wechat

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

12
Report