CentOS 7
1.配置DNS
vim /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
2.配置ip地址
vim /etc/sysconfig/network-scripts/ifcfg-*
HWADDR=00:0C:29:8D:24:73
TYPE=Ethernet
BOOTPROTO=static #启用静态IP地址
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777736
UUID=ae0965e7-22b9-45aa-8ec9-3f0a20a85d11
ONBOOT=yes #开启自动启用网络连接
IPADDR=192.168.194.* #设置IP地址
GATEWAY=192.168.194.2 #设置网关
NETMASK=255.255.255.0 #设置掩码
:wq! #保存退出
3. 重启网络 systemctl restart network.service
4.关闭防火墙
关闭firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running
CentOS 6
1.配置ip地址
vim /etc/sysconfig/network-scripts/ifcfg-*
BOOTPROTO=static #启用静态IP地址
ONBOOT=yes #开启自动启用网络连接
IPADDR=192.168.194.* #设置IP地址
GATEWAY=192.168.194.2 #设置网关
NETMASK=255.255.255.0 #设置掩码
2.配置DNS
vim /etc/resolv.conf
nameserver 8.8.8.8
3.重启网络
systemctl restart network.service Centos7
service network restart Cenos 6.5
4.关闭防火墙
现在生效,重启后默认又开启
service iptables stop
systemctl stop firewalld.service
重启后生效,现在无效
chkconfig iptables off
systemctl disable firewalld.service