The network configuration is related to the kernel module.

Source: Internet
Author: User

The network configuration is related to the kernel module.

================ Network configuration ================

Network parameter settings:

1) The command line setting can take effect immediately, but all the settings will become invalid after the computer is restarted;
2) modify the system configuration file, which does not take effect immediately, but can be permanently saved;

==== Set network parameters in the command line
1. network interface parameter ------- ifconfig command
Ifconfig eth0 192.168.10.10 netmask 255.255.255.0
Ifconfig eth0: View eth0 Nic Interface Information
Ifdown eth0; ifup eth0
2. Host name parameter ----- hostname command
Hostname chw
Hostname-I: to view the IP address of the Local Machine, read/etc/hosts to determine the IP address of the local machine.
3. route parameter -------- route command
Route add destination network gw gateway address add route table information
Delete route table records in the target network of route del

Related commands:
View current route table
Route
Replace host name with a digital address
Route-n
Add Default Gateway
Route add default gw 192.168.1.1
Add a gateway for the specified CIDR Block
Route add-net 172.16.0.0/16 gw 192.168.0.254
Add route records and specify the data transmitted to the 192.56.76.0 CIDR Block through eth0
Route add-net 192.56.76.0 netmask limit 255.0 dev eth0
Delete default gateway
Route del default gw 192.168.0.254
Deletes a gateway record for a specified CIDR block.
Route del-net 172.16.0.0/16

============= Modifying network parameters through files

1. network interface parameters. The storage file is/etc/sysconfig/network-scripts/ifcfg-eth *
DEVICE Name
TYPE Device TYPE; Value: ethernet
BOOTPROTO startup Protocol
HWADDR hardware address
Can the NM_CONTROLLED Nic be controlled by networkmanager?
Whether or not the ONBOOT Nic is started, which is invalid for the virtual Nic
Whether the Virtual Interface is started after the ONPARENT real interface is started
Ipaddr ip Address
Number of network bit masks in PREFIX, which is invalid for virtual Interfaces
NETMASK Subnet Mask
GATEWAY
DNS {1, 2} DNS Server

2. Host name parameter. The host name configuration file is/etc/sysconfig/network. You can set the host name by modifying the HOSTNAME value;

3. Routing Parameters: You can specify the default gateway for the NIC after setting network parameters through the NIC interface, but cannot set the Static Routing Information to the specific CIDR block, in this case, you need to create a route configuration file for the specified NIC (the default file does not exist). The configuration file name is route-eth *, and each line of this file corresponds to a static route record for one day;

Instance:

Specify the gateway for the eth0 Nic To Go To The 172.16.0.0/16 network segment as 192.168.0.200
Vim/etc/sysconfig/network-scripts/route-eth0
Service network restart

 

================= Kernel module ====================================
The Linux kernel adopts the modular technology. This design minimizes the system kernel and ensures the scalability and maintainability of the kernel. the modular design allows us to load modules to the kernel as needed, achieve dynamic kernel adjustment;

1. kernel module storage location: the kernel module File is usually named as the module name. ko, and the kernel module is centrally stored in/lib/modules/kernel name;

2. view the loaded kernel modules. The lsmod command is used to display the status of the kernel modules of the current system. If no parameters are used, all the loaded kernel modules are displayed; the output information is the module name, memory usage, and whether it is in use. If the third column is 0, the module can be detached at any time. If the value is not 0, modprobe cannot be executed to delete the module;

3. Load and uninstall the kernel module: The modprobe command can dynamically load and uninstall the kernel module;
Modprobe ip_vs
Lsmod | grep ip_vs
Modprobe-r ip_vs

The modinfo command can view the kernel module information:

The modules loaded in the preceding method are only valid currently. If you need to be permanently valid, you can write the relevant commands into the/etc/rc. local and/etc/rc. sysinit files;

4. Modify Kernel Parameters
1) temporarily adjust kernel parameters: Linux kernel parameters will be written into the memory as the system starts up. We can directly modify a large number of files in the/proc directory to adjust kernel parameters, and the adjustment takes effect immediately;
* *** Enable the kernel route forwarding function (set the switch through 0 or 1)
Echo "1">/proc/sys/net/ipv4/ip_forward
* *** Disable all icmp return packets (prohibit other hosts from Pinging their hosts ).
Echo "1">/proc/sys/net/ipv4/icmp_echo_ignore_all
* *** Adjust the total number of files that can be opened by all processes (when a large number of users access website resources, this number may cause an error)
Echo "108248">/proc/sys/fs/file-max

2) permanent adjustment of kernel parameters: directly modifying/proc-related files will not be valid after the system restarts. If you want to set the parameters to take effect permanently, you can modify/etc/sysctl. conf file in the format of "option = value". After modification, you can use the sysctl-p command to make these settings take effect immediately;

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.