CentOS9系统初始化脚本关闭防火墙 与Selinux

#!/bin/bash

:<guomc
# DateTime: 2023/12/11
# Author: guomc
# Desc: 系统初始化脚本,关闭SELINUX和firewalld
# Version: v1.0.0
# Mail: [email protected]

guomc

echo -e  "33[34;40m***************** $(date +%F-%T) ***************** 33[0m"

echo "************* step1 开始进行Selinux的初始化动作  *************  "
sestatus |grep 'Current mode' |grep -o  enforcing && setenforce 0
grep '^SELINUX=enforcing' /etc/sysconfig/selinux &&  sed -i 's@SELINUX=enforcing@SELINUX=disabled@' /etc/sysconfig/selinux
grep '^SELINUX=enforcing' /etc/selinux/config &&  sed -i 's@SELINUX=enforcing@SELINUX=disabled@' /etc/selinux/config

echo "************* step1 开始进行Selinux的初始化已完成  *************  "


echo "************* step2 开始进行Firewalld的初始化动作  *************  "
systemctl status firewalld | grep -o  'active (running)'  && systemctl stop firewalld
systemctl list-unit-files |grep 'STATE|firewalld' | awk '{print $2}' |grep -o enabled  &&  systemctl disable firewalld.service


echo "************* step2 开始进行Firewalld的初始化动作已完成  *************  "


echo "*************  当前主机 echo $HOSTNAME 的初始化操作已经完成 *************  "

echo -e  "33[34;40m***************** $(date +%F-%T) ***************** 33[0m"

CentOS9修改网卡配置:

[root@web-74 ~]# cat /etc/NetworkManager/system-connections/ens160.nmconnection 
[connection]
id=ens160
uuid=3df568f3-8dcd-3d18-9c17-d3e256ccbb83
type=ethernet
autoconnect-priority=-999
interface-name=ens160
timestamp=1705335427

[ethernet]

[ipv4]
address1=192.168.8.74/24,192.168.8.2
dns=8.8.8.8
method=manual

[ipv6]
addr-gen-mode=eui64
method=auto

[proxy]
 

配置参考:
[connection]
id=ens33
uuid=0050f214-01a7-395e-ab19-b6e95412995a
type=ethernet
autoconnect-priority=-999
interface-name=ens33
[ipv4]
address1=192.168.64.170/24,192.168.64.2   #配置IP地址
dns=114.114.114.114      #DNS配置
method=manual      #配置静态IP