Linux设置主机名、ip、及关闭防火墙操作
1、查看主机名
hostname
2、设置ip
方式一:通过Linux图形界面进行修改
进入Linux图形界面 -> 右键点击右上方的两个小电脑 -> 点击编辑连接 -> 选中当前网络System eth0 -> 点击编辑按钮 -> 选择IPv4 -> method(方式)选择为manual(手动) -> 点击add按钮 -> 添加IP:192.168.110.105 子网掩码:255.255.255.0 网关:192.168.6.1 ->应用
如图:
方式二:修改配置文件方式
切换成root权限,输入:
vim /etc/sysconfig/network-scripts/ifcfg-eth0
修改以下###内容:
DEVICE="eth0"
BOOTPROTO="static" ###修改项
HWADDR="00:0C:29:6A:59:5D"
IPV6INIT="yes"
NM_CONTROLLED="yes"
ONBOOT="yes" ###修改项
TYPE="Ethernet"
UUID="2406ffe1-4cd5-4d8c-846a-0d50842c6eb7"
IPADDR="192.168.110.105" ###添加项
NETMASK="255.255.255.0" ###添加项
GATEWAY="192.168.6.1" ###添加项
3、修改主机名
vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=hostname ###
4、添加主机名和IP的映射关系
vim /etc/hosts
192.168.110.105 hostname ###
5、关闭防火墙
#查看防火墙状态
service iptables status
#关闭防火墙
service iptables stop
#查看防火墙开机启动状态
chkconfig iptables --list
#关闭防火墙开机启动
chkconfig iptables off
方式二:
#查看防火状态
systemctl status firewalld
#暂时关闭防火墙
systemctl stop firewalld
#永久关闭防火墙
systemctl disable firewalld
#重启防火墙
systemctl enable firewalld
6、重启Linux
reboot
7、完成,测试ping一下