Centos network configuration 1

Network configuration:
1. ifconfig command: ifconfig command is used to configure the network or display the current network interface status. Similar to ipconfig under windows, the ifconfig command must be executed as root user.
Format: ifconfig [options] [interface] [inet | up | down | netmask | addr | broadcast]
Example: # ifconfig enp0s3 192.168.1.12 netmask 255.255.255.0 (Configure the network card enp0s3 network address and subnet mask, temporarily effective, restart the machine After the configuration disappears)
#ifconfig enp0s3:0 192.168.1.13 netmask 255.255.255.0 (You can bind multiple ip addresses to a network card, add: integer (0-253) after the network card name;)

ifconfig enp0s3:0 down (turn off enp0s3:0 network card)

                 # ifconfig  enp0s3  hw  ether xx:xx:xx:xx:xx:xx (修改网卡MAC地址)
                   # ifconfig  enp0s3 down (将网卡enp0s3禁用);       #ifconfig  enp0s3  up(将网卡enp0s3启用);
                  #ifconfig enp0s3(显示网卡enp0s3信息)
  2.ip命令 :
   设置ip地址,可以用IP命令:  #ip addr add 192.168.1.193/24 dev enp0s3 
     #ip  addr show enp0s3  (查看enp0s3网卡IP地址,也可简写为  ip  a)
     #ip  addr del  192.168.1.192/24  dev enp0s3  (删除ip地址,只需用del代替add)

    列出路由表条目:  # ip  route show  
    查看路由包来自的接口:  #ip  route get 192.168.1.1
    激活网络接口/停止网络接口   # ip link set enp0s3 up/down
   查看netlink消息  : # ip monitor all
   显示网络统计信息:  # ip -s link
  设置默认网关  :  # ip  route  add default via  192.168.1.254  
3.scp命令  : scp就是secure copy ,用于将文件或者目录从一个Linux系统拷贝到另一个linux系统下。scp传输数据用的是SSH协议,保证了数据传输的安全。
 格式: scp  远程用户名@ip地址:文件的绝对路径   本地Linux系统路径 (从远程主机拉取文件)
            scp  本地linux系统文件路径   远程用户名@ip地址:远程系统文件绝对路径名  (像远程主机推送文件)

            例: # scp  /home/ixdba/etc.tar.gz  [email protected]:/tmp(当报错 "not a regular file";可加参数 -r 解决,当拉取或推送的是目录时需加 -r 参数);
                    #scp  [email protected]:/home/ixdba/etc.tar.gz  /tmp
                    #scp -r  /etc  [email protected]:/opt
                    使用 -P参数可跟端口号,指定远程连接的端口号。
  1. traceroute command: It is used to display the path information of network data packet transmission to the specified host.
    traceroute [options] [remote host or IP address] [data packet size]
    -i <network interface> Use the specified network interface to send data packets
    -w<timeout seconds> Set the time to wait for a response from the remote host
    -s<source ip> Set the IP address
    of the local host to send data packets. Example: # traceroute -i eht0 -s 192.168.60.251 -w www.baidu.com 100

5. MTR command: mtr is a tool for judging network connectivity in linux, which combines the relevant characteristics of ping, traceroute, and nslookup.
The Loss% column is the packet loss rate corresponding to the IP row, and only the last target packet loss is considered a true packet loss.
The Last column is the delay of the last return, calculated in milliseconds.
The Avg column is an average of all return delays.
The Best column is the fastest return delay; the
Wrst column is the longest return delay; the
StDev column is the standard deviation;

  1. wget command: wget command is used to download a certain software from the network.
    Format: wget [URL of the software to be downloaded]
    wget -c Resumable upload
    wget -O wordpress.zip http://..... Use wget -O to download and save with a different file name
    wget -limit -rate Speed ​​limit Download wget -limit-rate=300K http://cn.wordpress.org/wordpress-3.1-zh_CN .zip
    wget -b background download

7. Telnet command: The telnet command communicates with the remote host through the telnet protocol or obtains the information of the corresponding port of the remote host.
Format: telnet host name or IP address of the port
to view a table of Linux systems 22 and 80 port is open and what services were opened up, use the following command:

telnet 192.168.3.98 (no port number, port 23 is used by default)

              #telnet  192.168.98  22
              #telnet  www.baidu.com  80

8. netstat command: The netstat command is used to display information about the local network connection, running port and routing table.

                     -a    显示本机所有连接和监听端口
                     -n    以网络IP地址的形式显示当前建立的有效连接和端口
                     -r     显示路由表信息
                      -s    显示按协议的统计信息。
                      -v    显示当前的有效连接,与“-n”选项类似。
                      -t    显示所有的TCP协议连接情况
                      -u   显示所有的UDP协议连接情况;

Common combinations: netstat -antlp; netstat -i; netstat -r;

Guess you like

Origin blog.51cto.com/12772149/2597062