linux6和7主机名的修改及防火墙的关闭

32 篇文章 1 订阅
23 篇文章 0 订阅

linux6系统修改主机名:

用户必须为root或者具有root权限

ifconfig或者ip addr查看ip

1 [root@localhost ~]# vi /etc/sysconfig/network
内容修改如下:
NETWORKING=yes
HOSTNAME=master

centos7的主机名称修改:
hostnamectl set-hostname  主机名

2 [root@localhost ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
ip hostname

note:不要修改原内容,后面追加写入保存就ok

服务器或者网路重新启动

[root@localhost ~]# reboot
[root@localhost ~]# service network restart
重新登录后查看对应的hostname

1 centos7 查看防火墙状态
centos7防火墙默认firewalld,如果需要用iptables则需要安装
#先检查是否安装了iptables
service iptables status
#安装iptables
yum install -y iptables
#升级iptables
yum update iptables 
#安装iptables-services
yum install iptables-services
systemctl enable iptables.service
#开启服务
systemctl start iptables.service
#查看状态
systemctl status iptables.service

在CentOS7.4中,系统已经默认安装了firewalld,我们只需要安装firewall-config
[root@lvxinghao ~]# yum install firewalld firewall-config
[root@lvxinghao ~]# yum -y install firewall-config
[root@lvxinghao ~]# yum -y update firewalld

[root@lvxinghao ~]# systemctl status firewalld


关闭防火墙命令:systemctl stop firewalld.service

开启防火墙:systemctl start firewalld.service

关闭开机自启动:systemctl disable firewalld.service

开启开机启动:systemctl enable firewalld.service

防火墙状态查看:systemctl status firewalld

查看开机是否启动防火墙服务: systemctl is-enabled firewalld

禁用防火墙(系统启动时不启动防火墙服务):systemctl disable firewalld  


永久有效开启和关闭:

开启: chkconfig iptables on 

关闭: chkconfig iptables off

防火墙状态查看:/etc/init.d/iptables status

防火墙临时关闭:/etc/init.d/iptables stop

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值