RedHat6 系统安装完后的网络配置和YUM镜像源修改

一、配置网络
1,配置DNS
vi /etc/resolv.conf
插入ifconf
nameserver 192.168.0.1 
nameserver 8.8.8.8
nameserver 8.8.4.4

2,配置网关:

vi /etc/sysconfig/network
加入:
GATEWAY=192.168.0.1
完整的如下:

3,配置ip地址: 
vi /etc/sysconfig/network-scripts/ifcfg-eth0
内容如下:
DEVICE="eth0"
HWADDR="00:0C:29:60:57:C3"
NM_CONTROLLED="yes"
NETMASK=255.255.255.0
IPADDR=192.168.0.8
GATEWAY=192.168.0.1
BOOTPROTO=static
ONBOOT=yes
PEERDNS=yes
4,重新启动服务:
/etc/init.d/network restart
或使用命令:
service network restart
或:
ifdown eth0 and ifup eth0

出现不能访问网址的现象请参考下面的

在 /etc/sysconfig/network-scripts/ifcfg-eth<N> 文件中加入 PEERDNS 选项。<N>可以是 0, 1, 2 等等,代表不同网卡的配置文件。例如,系统上第一张网卡是eth0的话,那它的配置文件就是 /etc/sysconfig/network-scripts/ifcfg-eth0 。

然后在文件中把 PEERDNS 改为 'no'. 例如:

DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Ethernet
PEERDNS=no这个选项可令 /etc/resolv.conf 在系统重启后不会被重写。

此法无效的话还要在eth0中添加dns信息:

/etc/ resolv.conf文件中的 namesever 在重启RedHat5或重启service network restart 后丢失,我按文件的说明到/etc/sysconfig/network-scripts/ ifcfg-eth0 添加DNS后解决。但是我不知道到底是什么在重启的时候重写了/etc/ resolv.conf文件。

/etc/ resolv.conf文件如下:

nameserver 59.51.78.210
nameserver 59.51.78.211
nameserver 192.168.0.1
search domain
domain domain
# Generated by NetworkManager

# No nameservers found; try putting DNS servers into your
# ifcfg files in /etc/sysconfig/network-scripts like so:

# DNS1=xxx.xxx.xxx.xxx
# DNS2=xxx.xxx.xxx.xxx
# DOMAIN=lab.foo.com bar.foo.com
===============================================
/etc/sysconfig/network-scripts/ ifcfg-eth0 的内容:

# Intel Corporation 82540EM Gigabit Ethernet Controller
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
HWADDR=08:00:27:cc:64:86
NETMASK=255.255.255.0
IPADDR=192.168.0.155
GATEWAY=192.168.0.1
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=no

#我在这添加了DNS后,/etc/ resolv.conf文件内容保存下来了
DNS1=202.96.128.86
DNS2=202.96.128.166
DNS3=8.8.8.8




5. 配置完成后,ping一下网关 ,检查是否能ping通或在用ifconfig eth0,检查下实际配置的ip地址。
二、配置图形桌面

Virtualbox下的虚拟光驱位于/dev/sr0,所以,向virtualbox加载RHEL6.1的镜像后,就可以配置yum库了
1.挂载镜像
[root@redhat ~]#   mkdir /media/rhel
[root@redhat ~]#   mount -o loop /dev/sr0 /media/rhel
2.使镜像能开机自动挂载
在/etc/fstab的最下面添加下面一句
[root@redhat ~]#   vi /etc/fstab
/dev/sr0                /media/rhel            iso9660       ro,loop         0 0
 
3.新建一个本地repo文件
紫色的部分可以不要添加,只要黑体那部分就行了。
[root@redhat ~]#   vi /etc/yum.repos.d/local.repo

[Server]
name=Server
baseurl=file:///media/rhel/Server
enabled=1
gpgcheck=0

[HighAvailability]
name=HighAvailability
baseurl=file:///media/rhel/HighAvailability
enabled=1
gpgcheck=0

[LoadBalancer]
name=LoadBalancer
baseurl=file:///media/rhel/LoadBalancer
enabled=1
gpgcheck=0


二、安装桌面
    1)检查软件组
查看一下桌面在哪个软件组里
[root@redhat ~]#  yum grouplist
Loaded plugins: refresh-packagekit
Setting up Group Process
HighAvailability/group_gz                                | 4.0 kB     00:00 ...  
LoadBalancer/group_gz                                    | 2.1 kB     00:00 ...  
Installed Groups:
   Additional Development
   Base
   Console internet tools
   Desktop
   Desktop Debugging and Performance Tools
   Dial-up Networking Support
   E-mail server
   FCoE Storage Client
   FTP server
   Fonts
   General Purpose Desktop
   Graphical Administration Tools
   Hardware monitoring utilities
   Input Methods
   Legacy UNIX compatibility
   Legacy X Window System compatibility
   NFS file server
   Network Infrastructure Server
   Network file system client
   Networking Tools
   Performance Tools
   Perl Support
   Remote Desktop Clients
   Security Tools
   Smart card support
   Storage Availability Tools
   System administration tools
   X Window System
   iSCSI Storage Client
Installed Language Groups:
   Arabic Support [ar]
   Armenian Support [hy]
   Assamese Support [as]
   Bengali Support [bn]
   Bhutanese Support [dz]
   Chinese Support [zh]
   Ethiopic Support [am]
   Georgian Support [ka]
   Gujarati Support [gu]
   Hebrew Support [he]
   Hindi Support [hi]
   Inuktitut Support [iu]
   Japanese Support [ja]
   Kannada Support [kn]
   Khmer Support [km]
   Konkani Support [kok]
   Korean Support [ko]
   Kurdish Support [ku]
   Lao Support [lo]
   Maithili Support [mai]
   Malayalam Support [ml]
   Marathi Support [mr]
   Myanmar (Burmese) Support [my]
   Oriya Support [or]
   Punjabi Support [pa]
   Sinhala Support [si]
   Tajik Support [tg]
   Tamil Support [ta]
   

································

Done

3.安装桌面
桌面在软件组desktop中,这和rhel5不太一样,rhel5里面好像为gnome
那么就开始安装桌面吧,但之前必须先安装Xwindow软件组
[root@redhat ~]# yum groupinstall “X Window System”
[root@redhat ~]# yum groupinstall “Desktop”

虽然到此就可以启动桌面了,但是linux建议不要让root用户直接登录图形界面
    所以,我们最好再创建一个普通用户
[root@redhat ~]#  useradd kevin
创建kevin的密码
[root@redhat ~]#  passwd kevin
4.启动X:
首先切换到普通用户
 [root@redhat ~]#  su - kevin
 [kevin@redhat ~] $ startx
5.更改启动模式
这时如果重启的话还是会直接进入命令界面,所以必须调整开机进入桌面还是命令界面
[root@redhat ~]#vim /etc/inittab
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
#
# Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,
# with configuration in /etc/sysconfig/init.
#
# For information on how to write upstart event handlers, or how
# upstart works, see init(5), init(8), and initctl(8).
#
# Default runlevel. The runlevels used are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
# 
id:3:initdefault:
 将上面红字部分的  3改成5

 3为命令行界面   5为X window图形界面
5.删除redhat订阅:
rhel6.1新增了一个redhat订阅,没有用,可以删除
[root@redhat ~]#   yum remove subscription*
6.安装桌面右键终端:
[root@redhat ~]#   yum install nautilus-open-terminal

你可能感兴趣的:(linux,网络,yum,red,hat)