centos7安装后的基本配置--搭建集群前的环境处理全解决

1、IP配置

复制代码
vi /etc/sysconfig/network-scripts/ifcfg-ens33
复制代码
BOOTPROTO=static #静态IP配置
ONBOOT=yes #开机自启
IPADDR=192.168.1.130 #IP地址
GATEWAY=192.168.1.2 #网关
NETMASK=255.255.255.0 #子网掩码
DNS1=8.8.8.8 #DNS服务器
DNS2=8.8.4.4
复制代码
复制代码

2、修改主机名

以下两种方式均可:

  1. 修改hostname/hosts文件
    vi /etc/hostname
    vi /etc/hosts
  2. 使用hostnamectl 命令
    hostnamectl set-hostname 名称

3、防火墙设置

复制代码
#查看防火墙状态
systemctl status firewalld.service
#开启防火墙
systemctl start firewalld.service
#关闭防火墙
systemctl stop firewalld.service 
#永久关闭防火墙
systemctl disable firewalld.service 
#开启防火墙(开机自启)
systemctl enable firewalld.service 
复制代码

4、端口设置

  1. 查看端口
    firewall-cmd --query-port=80/tc
  2. 查看所有开放端口
    firewall-cmd --zone=public --list-ports
  3. 关闭端口
    firewall-cmd --zone=public --remove-port=80/tcp --permanent  
  4. 开放端口
    firewall-cmd --zone=public --add-port=80/tcp --permanent
  5. 配置生效
    firewall-cmd --reload 
  6. 参数:
    –zone #作用域
    
    –add-port=80/tcp #添加端口,格式为:端口/通讯协议
    
    –permanent #永久生效,没有此参数重启后失效

猜你喜欢

转载自www.cnblogs.com/daisy8807/p/12944838.html
今日推荐