


Some common commands for setting network parameters in Linux
Here are three commands related to network settings:
ifconfig: Query and set network card and ip, subnet mask and other parameters (net-tools tool needs to be installed first)
ifup, ifdown: Start and shut down the network interface
route: View and configure routing information
ifconfig
First look at the ifconfig command
ifconfig [网卡名] [选项] up、down:启动或关闭该网络接口 mtu:设置mtu值 netmask:设置子网掩码 broadcast:设置广播地址
First look at the first example to view all network cards on the system, just enter ifconfig Just use the command without adding any parameters
# ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.2.220 netmask 255.255.255.0 broadcast 192.168.2.255 inet6 fe80::1733:cf21:906d:57af prefixlen 64 scopeid 0x20<link> ether 00:0c:29:84:5b:d0 txqueuelen 1000 (Ethernet) RX packets 9946 bytes 10315936 (9.8 MiB) RX errors 0 dropped 3 overruns 0 frame 0 TX packets 2208 bytes 186213 (181.8 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 ……
From the output information of this command, we can get a lot of information, such as network card name, IP address, subnet mask, broadcast address, etc.
Let's continue to look at a few examples
# 修改ip地址 # ifconfig eth0 192.168.1.222
You will find that you only modified the IP address, but the broadcast address will also change accordingly.
# 同时修改ip、子网掩码以及mtu值 ifconfig eth0 192.168.2.222 netmask 255.255.240.0 mtu 1000
Please practice with confidence as soon as possible. In the end, you only need to restart the network and it will be restored to the settings of the previous configuration file
ifup ifdown
When we modify the network configuration file /etc/sysconfig/network-scripts/ After eth0, I want to take effect immediately. Then you need to use
ifdown eth0 ifup eth0
In addition to this method, generally we will also use
/etc/init.d/network restart
to restart all network cards.
route
route This command can view the routing table and can also be used to set routes.
View routing information route [-nee]
-n: Do not display the host name, display it directly with IP, which is faster. This option has many commands about the network.
-ee: Display more detailed information
# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 172.19.255.253 0.0.0.0 UG 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0 172.19.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
Destination : Network address
Genmask: Subnet mask, Destination and Genmask form a network
Gateway: Gateway address (if displayed is 0.0. 0.0 means that the route is transmitted directly by the local machine, that is, it can be sent directly through the LAN. If the IP address is displayed, it means that the route needs the help of the router (gateway) before it can be sent out.
Flag: Flag, the common U indicates that the route is enabled, G indicates that the route needs to transmit data packets through an external host.
The above is the detailed content of Some common commands for setting network parameters in Linux. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The key differences between CentOS and Ubuntu are: origin (CentOS originates from Red Hat, for enterprises; Ubuntu originates from Debian, for individuals), package management (CentOS uses yum, focusing on stability; Ubuntu uses apt, for high update frequency), support cycle (CentOS provides 10 years of support, Ubuntu provides 5 years of LTS support), community support (CentOS focuses on stability, Ubuntu provides a wide range of tutorials and documents), uses (CentOS is biased towards servers, Ubuntu is suitable for servers and desktops), other differences include installation simplicity (CentOS is thin)

CentOS installation steps: Download the ISO image and burn bootable media; boot and select the installation source; select the language and keyboard layout; configure the network; partition the hard disk; set the system clock; create the root user; select the software package; start the installation; restart and boot from the hard disk after the installation is completed.

CentOS has been discontinued, alternatives include: 1. Rocky Linux (best compatibility); 2. AlmaLinux (compatible with CentOS); 3. Ubuntu Server (configuration required); 4. Red Hat Enterprise Linux (commercial version, paid license); 5. Oracle Linux (compatible with CentOS and RHEL). When migrating, considerations are: compatibility, availability, support, cost, and community support.

Docker uses Linux kernel features to provide an efficient and isolated application running environment. Its working principle is as follows: 1. The mirror is used as a read-only template, which contains everything you need to run the application; 2. The Union File System (UnionFS) stacks multiple file systems, only storing the differences, saving space and speeding up; 3. The daemon manages the mirrors and containers, and the client uses them for interaction; 4. Namespaces and cgroups implement container isolation and resource limitations; 5. Multiple network modes support container interconnection. Only by understanding these core concepts can you better utilize Docker.

How to use Docker Desktop? Docker Desktop is a tool for running Docker containers on local machines. The steps to use include: 1. Install Docker Desktop; 2. Start Docker Desktop; 3. Create Docker image (using Dockerfile); 4. Build Docker image (using docker build); 5. Run Docker container (using docker run).

After CentOS is stopped, users can take the following measures to deal with it: Select a compatible distribution: such as AlmaLinux, Rocky Linux, and CentOS Stream. Migrate to commercial distributions: such as Red Hat Enterprise Linux, Oracle Linux. Upgrade to CentOS 9 Stream: Rolling distribution, providing the latest technology. Select other Linux distributions: such as Ubuntu, Debian. Evaluate other options such as containers, virtual machines, or cloud platforms.

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

Docker uses container engines, mirror formats, storage drivers, network models, container orchestration tools, operating system virtualization, and container registry to support its containerization capabilities, providing lightweight, portable and automated application deployment and management.
