1、关闭防火墙
//查看防火墙状态
systemctl status firewalld
//临时关闭
systemctl stop firewalld
//禁止开机启动
systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
验证方式:reboot命令重启后查看防火墙状态
centos6以下:
//临时关闭
service iptables stop
//禁止开机启动
chkconfig iptables off
2、修改IP
//进入配置文件所在目录
cd /etc/sysconfig/network-scripts/
//使用ls查看目录下所有文件(有的名字叫ifcfg-ens33,有的叫ifcfg-eth0)
ls
//使用vim命令修改一行,添加三行(vim命令:按i进入编辑模式,按ESC退出编辑模式,再输入:wq可以保存并退出)
vim ifcfg-ens33
//重启网关
service network restart
//查看ip是否生效
ipconfig
ping www.baidu.com发现无法访问外网,需要修改dns
注意:添加nameserver值网关地址(192.168.3.1)或者 114(114.114.114.114)都可以。
如果有nameserver项,直接修改值,不想连外网可以直接注释掉此项
3、修改机器名(修改为test109),修改后reboot重启生效
将etc 目录下的hostname文件里的内容全部删除改成想要设置的机器名
有三种方式,原理都是修改/etc/hostnamea
(1)使用vim命令修改
vim /etc/hostname
(2)使用echo + > 直接修改
//修改
echo test109 > /etc/hostname
//查看
cat /etc/hostname
(3)使用修改主机名命令
//修改为test108
hostnamectl set-hostname test108
//查看
cat /etc/hostname
4.关闭SELINUX
查看selinux状态: getenforce
临时关闭命令:setenforce 0
vim /etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
:wq #保存,关闭。
reboot #重启系统