Server building study notes

Using the hardware is the basic function of the operating system, and the linux operating system controls the hardware through the driver. The linux kernel adopts a loadable modular design, usually only
the most basic core code modules can be compiled into the kernel, and at the same time, the hardware information can be dynamically loaded into the kernel through the driver. Therefore, the network card driver can be dynamically loaded from the kernel
and Uninstall.
1.modprobe loads the specified module into the kernel, or loads a set of interdependent modules.
   -r unload the specified module
   -l show all available modules
   -n only show what to do without actually executing
   -a load a set of matching modules
2.depmod analyze the dependencies of loaded modules for modprobe to load modules into Use
  -a in the kernel to analyze all available modules
  -v display detailed information during execution
Compile and install the network card
  1.rpm/source rpm driver installation method
 Download the network card driver corresponding to the server model from IBM's official website, and use tools such as U disk to transfer it to the linux server , and then compile
 rpm -ivh bnx2-<version>.src.rpm
 because it is compiled by the root user, so enter the /root/rpmbulid path to compile
 cd /root/rpmbuild
  rpmbuild -bb SPECS/bnx2.spec The rpm file will default to Install it in the /root/rpmbuild/RPMS directory
  2. Install the compiled driver package
  cd /root/rpmbuild/RPMS/x86-64
  rpm -vih bnx2-<version>.src.rpm
  After installation, the driver will be installed to the following path
 /lib/modules/<kernel-version>/kernel/drivers/net/bnx2 .ko
  copy the generated module file to the /lib/modules/<kernel-version>/kernel/drivers/net/bnx2.ko directory
 . 3. Load the driver
 insmod \
 > /lib/modules/<kernel-version >/kernel/drivers/net/bnx2.ko
 can also use the following command modprobe bnx2
 4. Check whether the driver module is loaded with
  lsmod |grep bnx2
 If the command output contains the bnx2 module, it indicates that the NIC driver has been compiled successfully
 5. Activate the NIC to check the status of the NIC
 ifconfig eth0 up (network card device name, here is eth0 as an example)
 ifconfig -a
 (when compiling a module, because the driver needs to be compiled with the kernel, it will use the kernel source or kernel header and other packages. In addition, a compiler is also required
   With the help of the compiler, before installing in this way, make sure that your Linux system contains kernel-source kernel kernel-devel kernel-headers
  gcc make)

source code driver package installation method
   1. Download the source code package from the official website and pass On the linux system, create a directory and unzip the source code package into this directory. Under normal circumstances, there is a
 readme file in the downloaded source code file, which describes the installation method. The source code package downloaded here is r8168-8.aaa.bb.tar.bz2
   mkdir /temp
   cd /temp
   tar jxvf r8168-8.aaa.bb.tar.bz2
   2. Compile and install the source code Follow
  the above operation, switch to decompression directory, perform the following operations
 cd r8168-8.aaa.bb to
   compile and generate the module file r8168.ko in the current src directory Perform the following operations
   make clean modules
  to install the module file to /lib/modules/<kernel_version>/kernel/drivers/ Since the names of the downloaded driver packages are not the same in the net directory, the standard driver package will
 directly install the module files into the corresponding driver directory when executing "make install", but some driver packages will not. Therefore, if some installation programs do not
install into the corresponding driver directory, you must manually copy the module files to this directory.
  make install
  check the dependencies between modules
  depmod -a
  load the r8168 module
  insmod ./src/r8168.ko   check
  whether the r8168 module is loaded   lsmod
  | grep r8168 condition.    The configuration files for configuring the linux network  network are generally in the /etc directory, but the paths of the linux network configuration files in different distributions are slightly different.   The network configuration path under Centos Linux is:   /etc/sysconfig/network-scripts/ifcfg-lo #Network card loopback address   /etc/sysconfig/network #Hostname and gateway configuration file/etc/   resolv.conf #dns configuration file   /etc /hosts # Set the host and ip binding information   . The path of the network configuration file under Ubuntu Linux is   /etc/network/interfaces #Configuration files such as ip address and subnet mask   /etc/resolv.conf # DNS configuration file   /etc/hostname # Global hostname configuration file

















  /etc/hosts #Set the binding information of the host and ip
 
  Network configuration file details
  (1) The network configuration file in the CentOS 6.5 version The network
  card configuration file /etc/sysconfig/network-scripts/ifcfg-eth0 The content is as follows
  DEVICE=eth0 indicates the network card The device name
  ONBOOT=yes is configured to automatically start the network card at boot time. eth0
  BOOTPROTO=static indicates that the eth0 interface has a static (static) ip configuration. If the network environment is to obtain an IP address dynamically, change it to dncp
  BROADCAST= broadcast address
  IPADDR= static IP address
  NETMASK= subnet mask
  NETWORK= network number
  GATEWAY= gateway
  HWADDR=00:1E: 0E: CF: 1A: E4 Display the MAC address of the eth0 interface
  TYPE=Ethernet Specify the type of the network card as Ethernet
  and use the service network restart command after the configuration is complete Make network settings take effect
 
  The local loopback configuration file /etc/sysconfig/network-scripts/ifcfg-lo
  DEVICE=lo indicates
  the network device name IPADDR= lo interface IP address
  NETMASK= subnet mask
  NETWORK= network number
  BROADCAST= lo interface broadcast address
  ONBOOT=yes Start the lo interface
  NAME=loopback Set the lo interface device to the local loopback (loopback) address

  Hostname and gateway configuration file /etc/sysconfig/network
  NETWORKING=yes Indicates whether the configuration network is running normally
  NETWORKING_IPV6=no Indicates whether the IPv6 network is normal
  HOSTNAME=WEBServer Indicates the host name of Linux
  GATEWAY= Indicates the gateway address

  DNS configuration file /etc/resolv.conf
  nameserver 221.11.1.67
  Set two DNS server addresses here, nameserver indicates the domain name server, and the latter IP address is the dns server.
  When a user accesses a domain name on the Internet under Linux, it is resolved by the specified DNS servers.
 
  Set the host and IP binding configuration file /etc/hosts
  host and IP binding, also known as local resolution. Similar to the hosts file under Windows, if the host and IP binding are set, then when accessing the bound host, the system will
  look up the corresponding IP address from the hosts instead of the dns server from /etc/resolv.conf For IP resolution
 
  , the following is the content in /etc/hosts
  127.0.0.1 localhost.localdomain localhost.192.168.60.133
  www.ixdba.net The
  content of each line in the hosts file is a host. Each line consists of three parts or two parts, namely IP address and hostname.
  The first part represents the network IP address
  The second part represents the host name. Domain name Note that there is a half-width period between the host name and the domain name, such as localhost.localdomain
  The third part represents the host name (hostname alias)
  will be 192.168.60.133 and www.ixdba.net bind. In this way, when accessing the www.ixdba.net host, the system will resolve to the 192.168.60.133 machine to access


   the network configuration file in the CentOS version
    TYPE=Ethernet
    BOOTPROTO=static Enable static IP address
    DNS=223.5.5.5                
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=yes
    IPv6INIT=no
    NAME=eth0 A label corresponding to the network card configuration file name, meaningless
    UUID= network card unique device identifier, the system automatically generates
    DEVICE=enp0s3 network card device name
    ONBOOT=yes
    IPADDR0= identifies the IP address CentOS The new function after version 7.0 can configure multiple IP addresses in one network card configuration file
    PREFIX0=24 Set subnet mask
    GATEWAY= Set gateway address

   
   Version after CentOS 7.0 All network and management are unified by NetworkManager service to maintain. Compared to the /etc/init.d/network script management method, NetworkManager
  is a dynamic, event-driven network management service. NetworkManager has led to some changes in some commonly used network commands. The
  management tool corresponding to the NetworkManager service is nmtui. The nmtui command is relatively complicated, and it is difficult for novices. It is recommended that beginners configure the network by modifying the configuration file method. After they have a
  complete understanding of the system as a whole, learn nmtui
 
  2) Hostname configuration file /etc/sysconfig/network
  The hostname in version 7.x is stored in a special configuration file. To modify the hostname of the system, just add the hostname to this file.
  3) Gateway In the configuration file /etc/sysconfig/network
   , the system default gateway
   GATEWAY=192.168.66.254 can be configured
   . When the network card configuration file has been configured with a gateway address, the gateway configuration in this file will automatically become invalid. On the contrary, if the gateway
   address is not set in the network card configuration file, the system will read the gateway configuration from this file by default.


  Linux network applications
  Under Linux, multiple interfaces can be virtualized on a network device interface. For example, the eth0:0 interface is actually a device virtualized by the device eth0, so a network card device has
  multiple IP addresses. The function of a network card with multiple IP addresses becomes an IP alias, that is, a network card can bind multiple IP addresses.
  1. In CentOS 6.x and previous versions, the network card is bound to multiple IP addresses.
  The Linux network device configuration file is stored in the /etc/sysconfig/network-scripts directory.
  For the first network device of the Ethernet, the configuration file name is generally ifcfg-eth0 If you need to bind another IP address to the first network device, you only need to create
  a file named ifcfg-eth0:0 in the directory, Then configure the corresponding IP information.
   DEVICE="eth0:0"
   BOOTPROTO=static
   IPADDR="192.168.66.168"
   NETMASK="255.255.255.0"
   ONBOOT="yes"
   NETWORK=192.168.60.0
   BROADCAST=192.168.60.255
  CentOS Linux can support 255 IP aliases.
  In fact, you can use the ifconfig command to virtualize a network interface and can be connected immediately. But when the network card or system is restarted, the virtual network interface will be cancelled.
  The way to make the settings permanent is by adding configuration files.
  ifconfig [device] [IP] netmask [netmask IP] [up|down]
  ifconfig eth0:1 192.168.66.131 netmask 255.255.255.0 up


  Enable the Linux proxy forwarding function
  1. Modify the content of the kernel parameter file under /proc and
   directly modify the kernel parameter ip_forward in The corresponding file under /proc is /proc/sys/net/ipv4/ip_forward Use the following command to view the content of the ip_forward file
   cat /proc/sys/net/ipv4/ip_forward
   The default value of 0 in this file means that IP forwarding is prohibited. Modify it to 1. Turn on forwarding. The modification takes effect immediately, that is, the kernel has turned on the IP forwarding function. If the system restarts
   Restore the default value of 0. To permanently open the IP forwarding function, you need to modify the content of the etc/sysctl.conf file to achieve
  2. Modify the /etcsysctl.conf file
   . There is a variable in the default sysctl.conf file that is
  net.ipv4.ip_forward=0
  will Change the following value to 1 and save the file. If you want to take effect immediately, you need to execute the command systl -p

  . Routes are classified
  into static routes and dynamic routes.
  Routes configured on Linux are all static routes. The generation of static routes is due to the static routing rules added by the system administrator using the route command, that is,
  the routing rules added by manual input.
  Dynamic routing means that there is no need to manually input routing rules. The routing rules are obtained by exchanging routing rules between the local machine and different machines through the routing program. If the network changes
, the router will recalculate the route and send out new route update information. This information is updated to the network, causing the routers to recalculate and make corresponding changes to the routing table.
  route [-n|ee]
  route add[-net|-host] [network or host] netmask [mask] [gw|dev]
  -n Do not use communication protocol or host name, use ip address directly
  -ee Display more detailed information Routing information
  add means adding routing information
  -net means adding a network, that is, followed by a network address
  -host means the following is a route linked to a separate host
  netmask indicates that the information of the subnet mask is followed, and the subnet mask can limit the size of the network
  gw gateway IP information
  dev specifies which network device to connect to, followed by the name of the network device
   gateway: the address of the gateway to connect to, indicating the network It goes out through this IP link. If it shows 0:0:0:0, it means that the route is changed directly from the machine.
            If there is an IP display, it means that this route must go through the transfer of this IP before it can be connected out.
   When adding a route using route, the set route must be able to communicate directly with the network interface (eth0) or IP of your own system to be added successfully.
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324849244&siteId=291194637