1.修改网卡配置 编辑:vi /etc/sysconfig/network-scripts/ifcfg-eth0
1
2
3
4
|
DEVICE=eth0
#描述网卡对应的设备别名,例如ifcfg-eth0的文件中它为eth0
BOOTPROTO=static
#设置网卡获得ip地址的方式,可能的选项为static,dhcp或bootp,分别对应静态指定的 ip地址,通过dhcp协议获得的ip地址,通过bootp协议获得的ip地址
IPADDR=192.168.119.224
#如果设置网卡获得 ip地址的方式为静态指定,此字段就指定了网卡对应的ip地址
NETMASK=255.255.255.0
#网卡对应的网络掩码
|
2.修改网关配置
编辑:vi /etc/sysconfig/network 修改添加GATEWAY
1
2
3
|
NETWORKING=
yes
#表示系统是否使用网络,一般设置为yes。如果设为no,则不能使用网络,而且很多系统服务程序将无法启动
HOSTNAME=centos
#设置本机的主机名,这里设置的主机名要和/etc/hosts中设置的主机名对应
GATEWAY=192.168.119.1
#设置本机连接的网关的IP地址。
|
3.修改DNS 配置
编辑:vi /etc/resolv.conf 修改后如下:
nameserver 即是DNS服务器IP地址,第一个是首选,第二个是备用。
4.重启网络服务
执行命令:
service network restar或/etc/init.d/network restart
安装setup tools、
1、安装setup工具及组件
1
2
3
4
5
|
yum
install
setuptool
#安装setup工具
#安装工具组件
yum
install
ntsysv
#系统服务
yum
install
system-config-network-tui
#网络服务
yum
install
system-config-securitylevel-tui
#防火墙配置
|
2、配置网卡IP
如果没有没配置DNS使用yum安装时可能会报错
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
[root@node-01 ~]
# yum install lrzsz
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http:
//mirrorlist
.centos.org/?release=6&arch=x86_64&repo=os&infra=stock error was
14: PYCURL ERROR 6 -
"Couldn't resolve host 'mirrorlist.centos.org'"
Error: Cannot
find
a valid baseurl
for
repo: base
[root@node-01 ~]
# vi /etc/resolv.conf
[root@node-01 ~]
# yum install lrzsz
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: centos.ustc.edu.cn
base | 3.7 kB 00:00
base
/primary_db
| 4.7 MB 00:00
extras | 3.4 kB 00:00
extras
/primary_db
| 37 kB 00:00
updates | 3.4 kB 00:00
updates
/primary_db
| 4.3 MB 00:01
Resolving Dependencies
--> Running transaction check
---> Package lrzsz.x86_64 0:0.12.20-27.1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================================================================================================================
Package Arch Version Repository Size
==========================================================================================================================================================================================
Installing:
lrzsz x86_64 0.12.20-27.1.el6 base 71 k
Transaction Summary
==========================================================================================================================================================================================
Install 1 Package(s)
Total download size: 71 k
Installed size: 159 k
Is this ok [y
/N
]: y
Downloading Packages:
lrzsz-0.12.20-27.1.el6.x86_64.rpm | 71 kB 00:00
warning: rpmts_HdrFromFdno: Header V3 RSA
/SHA256
Signature, key ID c105b9de: NOKEY
Retrieving key from
file
:
///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>
Package: centos-release-6-8.el6.centos.12.3.x86_64 (@anaconda-CentOS-201605220104.x86_64
/6
.8)
From :
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Is this ok [y
/N
]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : lrzsz-0.12.20-27.1.el6.x86_64 1
/1
Verifying : lrzsz-0.12.20-27.1.el6.x86_64 1
/1
Installed:
lrzsz.x86_64 0:0.12.20-27.1.el6
Complete!
[root@node-01 ~]
#
|
centos7按照初始安装时候的developer类型一路装好,在vmware里已经设置为bridge模式,按理说是会自动按照DHCP联网成功的,结果却发现连网卡都没有激活,这里记录下。
配置网卡
1
|
vim
/etc/sysconfig/network-scripts/ifcfg-ens33
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
HWADDR=00:0C:29:2C:E5:30
TYPE=Ethernet
BOOTPROTO=static
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=ens33
UUID=ea35e10e-ff50-4a7a-92d5-ab54c58d8b44
ONBOOT=no
|
没想到在centos7里默认是不启动网卡的,奇怪的设定啊,所以网卡才没有激活 改为yes,然后再加上以下几个参数的设置
1
2
3
4
|
IPADDR=192.168.2.181
GATEWAY=192.168.2.1
DNS1=114.114.114.114
DNS2=8.8.8.8
|
1
|
nameserver 114.114.114.114nameserver 8.8.8.8
|
如果按照上面把/etc/resolv.conf中的dns也配置好之后
1
|
sudo
service network restart
|
ps:也可以使用system-config-network-tui这个软件以GUI方式进行配置,用yum安装即可。
本文转自 运维小当家 51CTO博客,原文链接:http://blog.51cto.com/solin/1861888,如需转载请自行联系原作者