1: files related to network configuration
1、Network card name configuration related files
NIC naming rule file:
/etc/udev/rules.d/70-persistent-net.rules
# PCI device 0x8086:0x100f (e1000) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:db:c9:5c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" # PCI device 0x8086:0x100f (e1000) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:db:c9:66", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
Modify the naming example of network card:
1、View the driver of the NIC and uninstall the NIC driver.
[root@rhel6 ~]# ethtool -i eth0 driver: e1000 #Network card driver
[root@rhel6 ~]# modprobe -r e1000 #Uninstall NIC driver
2、Modify 70-persistent-net.rules file
3、Reloading the NIC driver and restarting the network service
[root@rhel6 ~]# modprobe e1000 #Reload the NIC driver[root@rhel6 ~] /etc/rc.d/init.d/network restart restart network service
Change the CentOS7.x NIC name to the traditional naming method:
1、Modify /etc/default/grbu file
# sed -i.bak -r 's/(GRUB_CMDLINE_LINUX=.*)"/\1 net.ifnames=0"/' /etc/default/grub
2、Generate a new grub configuration file and restart it.
grub2-mkconfig -o /etc/grub2.cfg
2、Network configuration related files
Network configuration reference: /usr/share/doc/initscripts-9.03.53/sysconfig.txt
The configuration of the network card is: /etc/sysconfig/network-scripts/, configuration file: ifcfg- network name.
Configuration file example:
③netstat
- -n:Digital display, no resolution, increase efficiency
- -r:View routing table
- -t:TCPRelevant
- -u:UDPRelevant
- -w:Bare socket
- -l:View ports in the listening state
- -a:View all status ports
- -e:Display more detailed information
- -p:View related processes PID
- -i:Display network card traffic
- -Iinterface:View the flow information of the specified network card = = ifconfig -s interface
[root@centos7 ~]# netstat -tnulp #Displays the listener status of TCP, UDP and port of related processes.
④ip
- link
- set interface {up|down}:Enabling or disabling network cards
- show interface:Display specified NIC information
- addr
- add IP/NETMASK [label interface:#] [scope {global | link | host}] [broadcast IP] dev interface:Add temporary address
- label:assign an alias
- scope:Scope of action
- global:Scope is global.
- link:Only the network connected to this NIC will take effect.
- host:Host only available
- broadcast:Set broadcast address
- del dev interface [label interface:#]:Delete IP
- flush dev interface [label interface:#]:Emptying IP
- add IP/NETMASK [label interface:#] [scope {global | link | host}] [broadcast IP] dev interface:Add temporary address
- route
- add IP/NETMASK via GATEWAY dev interface:Add routing
- add default via GATEWAY dev interface:Add default route
- del IP/NETMASK via GATEWAY dev interface:Delete route
- flush:Empty routing table
- show:View routing table
[root@centos7 ~]# ip addr add 192.168.1.100/24 label eth0:0 dev eth0 #Set temporary IP address
⑤ss
- -n:Digital display, no resolution, increase efficiency
- -t:TCPRelevant
- -u:UDPRelevant
- -w:Bare socket
- -x:Display UNIX sock related information
- -l:View ports in the listening state
- -a:View all status ports
- -e:Display more detailed information
- -p:View related processes PID
- -m:Amount of memory
- -o:Timer information
- -s:Display current socket details
- state TCP_STATE ‘( dport = :ssh or sport = :ssh )’
- established
- listen
- fin_wait_1
- fin_wait_2
- syn_sent
- syn_recv
[root@centos7 ~]# ss state established '( dport = :ssh or sport = :ssh )' #View connected SSH
⑥nmcli:Address configuration tool (CentOS7.x)
Subcommand completion function: Yum install bash-completion, depending on EPEL source.
1、see information
[root@centos7 ~]# nmcli device status
[root@centos7 ~]# nmcli connection show
2、Delete configuration
[root@centos7 ~]# nmcli connection delete ens33
3、Add configuration
[root@centos7 ~]# nmcli connection add con-name ens33 ifname ens33 type ethernet ipv4.method auto connection.autoconnect yes
- con-name ens33:Configuration file name
- ifname ens33:Designated network card device
- type ethernet:Network type Ethernet
- ipv4.method auto:Automatic acquisition of IP
- connection.autoconnect yes:Boot self starting
4、Switch configuration
[root@centos7 ~]# nmcli connection up ens33
5、Modify configuration file name ens33 –> ens33-static
[root@centos7 ~]# nmcli connection modify ens33 con-name ens33-static
6、Modify configuration IP
[root@centos7 ~]# nmcli connection modify ens33-static ipv4.addresses 192.168.0.100/24 ipv4.gateway 192.168.0.1 ipv4.method manual
- ipv4.addresses 192.168.0.100/24:IPaddress
- ipv4.gateway 192.168.0.1:gateway
- ipv4.method manual:Manual access, static address must be configured to manual, otherwise default dynamic.
7、Re read configuration files
[root@centos7 ~]# nmcli connection reload
8、Disconnect and connect network connections
[root@centos7 ~]# nmcli device disconnect ens33
[root@centos7 ~]# nmcli device connect ens33
9、View details of network configuration
[root@centos7 ~]# nmcli connection show ens33
10、Add another address to the configuration.
[root@centos7 ~]# nmcli connection modify ens33-static +ipv4.addresses 10.0.0.2/8
Three: other related tools
ping:Test network command
- -c count:pingThe number of times
- -W timeout:Overtime, cooperate with -c
- -I ipaddress:Specify IP to use your host’s Ping to host each other’s host.
- -s size:The maximum size of packet size per ping is 65507.
- -f:Send data packets to the best of your host’s capabilities.
[root@centos7 ~]# ping -c1 -W1 192.168.0.6 #Ping test commonly used in scripts, Ping once, timeout 1s[root @ centos7 ~]# ping-s 65507-f 192.168.0.6 # sent large packets to 192.168.0.6 as much as it couldDDoS Attacks
tcpdump:Bag tool
- -n:Prohibit parsing IP
- -i interface:Designated NIC interface
- tcp|udp|icmp|arp:Specified packet protocol
mtr:Network diagnostic tool
traceroute:Tracking routing
tracepath:Tracking routing
ifup:Enable network card
ifdown:Disable network card
setup:Character interface configuration tool (centos6.x)
system-config-network-tui:Character interface network configuration tool (centos6.x)
hostnamectl:Set up host name tool (centos7.x)
- status
- set-hostname HOSTNAME
mm-connection-editor:Graphical interface network configuration tool (centos7.x)
nmtui:Character interface configuration tool (centos7.x)
- nmtui-connect
- nmtui-edit
- nmtui-hostname
lftp | lftp [-u user[,pass]] [-p port] [-e cmd] FTPSERVER:FTPClient tools
- get
- mget
- put
- mput
- mirror DIR
lftpget URL:Non interactive downloading of FTP server files
wget:Network download tool
- -q:silent mode
- -c:Broken point
- -P /path/DIRNAME:The saved files are saved to the specified folder.
- -O /path/FILENAME:The saved file is saved to the specified location and renamed.
- –limit-rate=# K|M:Speed limit to K|M
elinks | links:Character interface web browser
- -source:View web page source code
- -dump:Display text only
Four: Bonding and Team
++Bonding++
Binding: Binding multiple network cards to the same IP address to provide services, can achieve high availability or load balancing.
Working mode:
mode 0:balance-rr Rotation strategy: multiple network cards can send packets in turn to achieve load balancing functions.
mode 1:active-backup Main and backup strategy: the sending packets of active network card and other spare parts.
mode 3:broadcast Broadcast strategy: each network card will send a package.
Configuration example:
1、Create device configuration file for bonding