One, four modes of network card configuration
1, directly modify the configuration file
vim /etc/sysconfig/network-scripts/ifcfg-ens33
Bootproto represents the way the address is assigned, with DHCP, static, none
Onboot indicates whether the network adapter is enabled, the parameters are Yes, no
The subnet mask can be written as netmask=255.255.255.0, or it can be written as prefix0=24
Need to restart Network service after modifying NIC configuration file
Systemctl Restart Network
2, Nmtui (CentOS 5, 6 for Setup)
3, Nm-connection-editor
The following two options are checked, equivalent to Onboot's Yes or no
4. Small Icons
Ii. four ways to set up a firewall
1, Iptables
- Input from outside to inside
- Output from inside to outside
- The firewall's policies are executed from top to bottom, executed directly after matching, and the following statements are not executed.
- Where reject traffic is divided into two
①reject--direct rejection, the other person sees is directly you reject his message
②drop--packet loss strategy, the other side see you are not online (play the role of the hidden host)
- Experiment
iptables -L#-L代表查看已有的规则列表,INPUT从外到内默认规则是放行所有流量
iptables -F#清空原有的防火墙策略
iptables -I INPUT -p icmp -j REJECT#-I代表放在规则链的头部,优先级最高(-A代表末尾),-p代表协议,-j表示后面接动作
iptables -I INPUT -p icmp -j ACCEPT#恢复允许icmp流量
iptables -P INPUT DROP#-P代表修改默认策略,禁止所有流量(默认策略只能是DROP,不能是REJECT)
iptables -I INPUT -p icmp -j ACCEPT#允许icmp,会发现又可以ping通了
iptables -I INPUT -p tcp --dport 22 -j ACCEPT#允许使用SSH(默认端口为22),--dport 22代表是目标的端口号22
#如果不知道对应的协议,可以查看/etc/services文件cat /etc/services | grep ssh#因为内容太多,可以使用grep来过滤查看
iptables -F#将防火墙策略清除,因为之前将默认的策略修改为了禁止所有流量,所以SSH远程连接断开了,需要重新到本机上修改回ACCEPTservice iptables save#清空后保存一下当前策略状态#再次连接,正常。
iptables -D INPUT 1#删除编号为1的策略
删除后再进行iptables -L查看
iptables -I INPUT -s 192.168.152.129 -p icmp -j REJECT#拒绝某台主机ping本机
2, Firewall-cmd
3, Firewall-config
4, Tcp_wrappers
Four modes of Linux NIC configuration and four ways of firewall setup (CentOS 7.4) not completed