一、CentOS 8防火牆配置文件
1、CentOS 8的防火牆配置文件位於/etc/firewalld目錄下,常用命令:
$ cd /etc/firewalld/
$ ls
2、修改防火牆配置文件sysconfig配置文件,默認情況下/etc/sysconfig/ firewalld,使用vi編輯器進行編輯:
$ vi /etc/sysconfig/firewalld
3、重新載入防火牆配置文件:
$ firewall-cmd --reload
二、CentOS 8防火牆配置
1、啟動防火牆,停止防火牆,重啟防火牆:
$ systemctl start firewalld #啟動防火牆
$ systemctl stop firewalld #停止防火牆
$ systemctl restart firewalld #重啟防火牆
2、開放埠:
$ firewall-cmd --add-port=80/tcp --permanent #開啟 80 埠
$ firewall-cmd --list-ports #查看開啟的埠
$ firewall-cmd --remove-port=80/tcp --permanent #刪除 80 埠
3、開放服務:
$ firewall-cmd --add-service=http --permanent #開啟 http 服務
$ firewall-cmd --list-services #查看開啟的服務
$ firewall-cmd --remove-service=http --permanent #刪除 http 服務
三、CentOS 8防火牆配置圖形化界面
1、CentOS 8默認已經安裝了圖形化的防火牆管理工具 firewall-config:
$ firewall-config
2、打開防火牆管理圖形化界面後,可以進行埠和服務的添加,刪除操作。
四、CentOS 8配置yum源
1、備份原有CentOS-Base.repo:
$ mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、下載使用阿里雲的yum源:
$ curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
3、更新yum源:
$ yum clean all
$ yum makecache
五、CentOS 8網路配置
1、查看當前網路狀態:
$ nmcli device status
2、開啟/關閉網路:
$ nmcli networking on/off
六、CentOS 8配置網卡
1、安裝network-manager:
$ yum install NetworkManager
2、啟動 network-manager 服務:
$ systemctl start NetworkManager
3、通過 nmcli 命令修改網路名 (eth0 為網卡名,new_name 為新的網卡名):
$ nmcli connection modify eth0 connection.id new_name
七、CentOS 8配置DNS
1、備份原有/etc/resolv.conf 文件:
$ mv /etc/resolv.conf /etc/resolv.conf.bak
2、創建新的/etc/resolv.conf 文件:
$ vi /etc/resolv.conf
文件內容如下:
nameserver 8.8.8.8
nameserver 8.8.4.4
3、使配置生效:
$ systemctl restart network
八、CentOS 8配置bond
1、檢查主機的網卡:
$ lspci |grep -i net
2、安裝bonding模塊:
$ yum install -y kernel-modules-extra
3、編輯/etc/modprobe.d/bonding.conf 文件,加入雙網卡綁定配置:
alias bond0 bonding
options bonding mode=6 miimon=100 primary=eth0
4、創建bond0 設備:
$ nmcli con add type bond con-name bond0 ifname bond0 mode active-backup ip4 192.168.0.100/24 gw4 192.168.0.1
九、CentOS 8配置靜態IP
1、編輯/etc/sysconfig/network-scripts/ifcfg-eth0 文件,配置靜態IP地址:
$ vi /etc/sysconfig/network-scripts/ifcfg-eth0
文件內容如下:
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=no
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=eth0
UUID=xxxxxx-xx-xxx-xxx-xxxxxx
ONBOOT=yes
HWADDR=xxxxxxxxxxxx
IPADDR=192.168.0.100
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
2、重啟網路服務:
$ systemctl restart network
原創文章,作者:UJSOS,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/331983.html