概述:
1、ifconfig改成了 ip addr,
2、CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。
firewall:
systemctl start firewalld.service#启动firewall
systemctl stop firewalld.service#停止firewall
systemctl disable firewalld.service#禁止firewall开机启动
接下来配置网络:
1、查看当前网卡
[root@master cdh]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:a6:e3:af brd ff:ff:ff:ff:ff:ff
inet 192.168.41.160/24 brd 192.168.41.255 scope global eno16777736
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fea6:e3af/64 scope link
valid_lft forever preferred_lft forever
备注:这里我已经是修改好了的,所以可以看到我设置的。记住eno16777736这个网卡,接下来找到这个文件。
2、进入到 cd /etc/sysconfig/network-scripts/
[root@master network-scripts]# cd /etc/sysconfig/network-scripts/
<pre name="code" class="html"><pre name="code" class="html">[root@master network-scripts]# ls
ifcfg-eno16777736 ifdown-ib ifdown-ppp ifdown-tunnel ifup-ib ifup-plusb ifup-Team network-functions
ifcfg-lo ifdown-ippp ifdown-routes ifup ifup-ippp ifup-post ifup-TeamPort network-functions-ipv6
ifdown ifdown-ipv6 ifdown-sit ifup-aliases ifup-ipv6 ifup-ppp ifup-tunnel
ifdown-bnep ifdown-isdn ifdown-Team ifup-bnep ifup-isdn ifup-routes ifup-wireless
ifdown-eth ifdown-post ifdown-TeamPort ifup-eth ifup-plip ifup-sit init.ipv6-global
3、修改
[root@master network-scripts]# vi ifcfg-eno16777736
4、
找到对应的内容(HWADDR、BOOTPROTO、ONBOOT、IPADDR、NETMASK、GATEWAY和DNS):
uTYPE=Ethernet
HWADDR=00:0c:29:a6:e3:af #你机器的mac地址
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=ff2cf6f2-49fc-49fa-8ec0-6facf1ddb832 #uuid 不重复就行
DEVICE=eno16777736
ONBOOT=yes
IPADDR=192.168.41.160 #静态ip 地址
PREFIXO=24
NETMASK=255.255.255.0 #网关
GATEWAY=192.168.41.2 #子网掩码
DNS1=192.168.41.2 #主DNS
DNS2=8.8.8.8 #备用DNS
保存退出
5、重启网卡
[root@master network-scripts]# systemctl restart network
6、验证
[root@master network-scripts]# ip addr
就可以看到自己配置的静态ip了。