vi /etc/sysconfig/network-scripts/ifcfg-eth0
修改如下内容
vi /etc/sysconfig/network
修改如下内容
vi /etc/resolv.conf修改如下内容
nameserver 202.101.224.68 # (域名服务器) nameserver 202.101.224.69 # (域名服务器)
service network restart
或
/etc/init.d/network restart
ifconfig eth0 192.168.0.2 netmask 255.255.255.0
启动生效:
修改/etc/sysconfig/network-scripts/ifcfg-eth0php
route add default gw 192.168.0.1 dev eth0
启动生效:
修改/etc/sysconfig/networkweb
修改后可即时生效,启动一样有效shell
hostname centos1启动生效:
修改/etc/sysconfig/networkcentos
ifdown eth0 # 关闭网络 ifconfig eth0 down # 关闭网络 ifup eth0 # 开启网络 ifconfig eth0 up # 开启网络 service network start # 启动网络服务 service network stop # 中止网络服务 service network restart # 重启网络服务 service network status # 查看网络服务状态
确保安装了网卡并工做正常, 使用以下命令查看网卡的状态: 服务器
ifconfig eth0
若是已经设置了默认路由,使用如下方法删除:
在文件 /etc/sysconfig/network/ifconfig-eth0 中删除 GATEWAY= 这一行,而后以root执行:网络
service network restart
Linux下的PPPOE客户端软件比较多,并且大多使用GNU License,咱们推荐使用rp-pppoe这个软件包。从http://www.roaringpenguin.com/products/pppoe这个网站上,不只能够下载各发布包下的rp-pppoe的二进制软件包,并且能够下载源代码软件包。咱们使用centos下的yum安装方法,来安装rp-pppoe软件包架构
yum install rp-pppoe
安装完软件包后,必须配置PPPOE的配置文件/etc/ppp/pppoe.conf,从而让ADSL拨号时使用配置文件中的用户名、密码等参数。ide
# adsl-setup ← 创建ADSL链接工具
Welcome to the ADSL client setup. First, I will run some checks on
your system to make sure the PPPoE client is installed properly...测试
LOGIN NAME
Enter your Login Name (default root): ← 填入ADSL链接的用户名
INTERFACE
Enter the Ethernet interface connected to the ADSL modem
For Solaris, this is likely to be something like /dev/hme0.
For Linux, it will be ethX, where 'X' is a number.
(default eth0): ← 指定网络接入设备,一块网卡的状况下,通常为默认eth0
Do you want the link to come up on demand, or stay up continuously?
If you want it to come up on demand, enter the idle time in seconds
after which the link should be dropped. If you want the link to
stay up permanently, enter 'no' (two letters, lower-case.)
NOTE: Demand-activated links do not interact well with dynamic IP
addresses. You may have some problems with demand-activated links.
Enter the demand value (default no): ← 直接按回车,接受默认设置
DNS
Please enter the IP address of your ISP's primary DNS server.
If your ISP claims that 'the server will provide dynamic DNS addresses',
enter 'server' (all lower-case) here.
If you just press enter, I will assume you know what you are
doing and not modify your DNS setup.
Enter the DNS information here: ← 若是知道DNS服务器的信息在此填入。不知道的状况按回车跳过
PASSWORD
Please enter your Password: ← 输入ADSL的链接密码
Please re-enter your Password: ← 再次确认输入ADSL的链接密码
USERCTRL
Please enter 'yes' (two letters, lower-case.) if you want to allow
normal user to start or stop DSL connection (default yes): no ← 填入no,不容许通常用户控制PPPoE的链接
FIREWALLING
Please choose the firewall rules to use. Note that these rules are
very basic. You are strongly encouraged to use a more sophisticated
firewall setup; however, these will provide basic security. If you
are running any servers on your machine, you must choose 'NONE' and
set up firewalling yourself. Otherwise, the firewall rules will deny
access to all standard servers like Web, e-mail, ftp, etc. If you
are using SSH, the rules will block outgoing SSH connections which
allocate a privileged source port.
The firewall choices are:
0 - NONE: This script will not set any firewall rules. You are responsible
for ensuring the security of your machine. You are STRONGLY
recommended to use some kind of firewall rules.
1 - STANDALONE: Appropriate for a basic stand-alone web-surfing workstation
2 - MASQUERADE: Appropriate for a machine acting as an Internet gateway
for a LAN
Choose a type of firewall (0-2): 0 ← 输入0,不在这里使用防火墙
Start this connection at boot time
Do you want to start this connection at boot time?
Please enter no or yes (default no): yes ← 填入yes,在系统启动时自动链接ADSL
** Summary of what you entered **
Ethernet Interface: eth0
User name: caun870293@ca.dti.ne.jp
Activate-on-demand: No
DNS: Do not adjust
Firewalling: NONE
User Control: no
Accept these settings and adjust configuration files (y/n)? y ← 配置信息确认无误后,键入y赞成设置
Adjusting /etc/sysconfig/network-scripts/ifcfg-ppp0
Adjusting /etc/ppp/chap-secrets and /etc/ppp/pap-secrets
(But first backing it up to /etc/ppp/chap-secrets.bak)
(But first backing it up to /etc/ppp/pap-secrets.bak)
?
Congratulations, it should be all set up!
Type '/sbin/ifup ppp0' to bring up your xDSL link and '/sbin/ifdown ppp0'
to bring it down.
Type '/sbin/adsl-status /etc/sysconfig/network-scripts/ifcfg-ppp0'
to see the link status.
若是不成功,请检查网线、ADSL MODEM等物理设备,并查看 /var/log/messages中的信息
/usr/sbin/adsl-stop 关闭和ISP的链接
/usr/sbin/adsl-status 查看当前链接的状态
若是想在Linux系统启动时自动启动ADSL链接,输入如下命令
#chkconfig --add adsl
将在当前的运行级下加入ADSL的自启动脚本
<1>CentOS的镜像站点
完整的CentOS软件库很是大。CentOS的软件包位于CentOS的镜像站点的目录树中,可经过FTP或HTTP访问它们。
在http://mirror-status.centos.org/能够看到各镜像的状态。
在http://www.centos.org/modules/tinycontent/index.php?id=22能够看到如何进行镜像的知识。
镜像站点的第一级目录是发行版本号,如三、四、5等。任何CentOS镜像站点的版本号为5的目录下都有下列目录。
<2>CentOS的仓库
仓库(repository)是一个预备好的目录,或是一个网站,包含了软件包和索引文件。yum能够在仓库中自动地定位并获取正确的RPM软件包。这样,你就没必要手动搜索和安装新应用程序和升级补丁了。只用一个命令,就能够更新系统中全部软件,也能够根据指定搜索目标来查找安装新软件。
镜像服务器为每一个版本的CentOS分别提供了一些仓库。CentOS5中的软件管理工具yum已经预先配置为使用下列4个仓库。
你还可使用下面的仓库,但在CentOS5默认状况下未被启用。
CentOS仓库的目录结构
下面以CentOS5的updates仓库为例,说明其在镜像站点上的目录结构(其余仓库结构相似)。
updates/ |
SRPMS |
*.src.rpm |
|
repodata/ |
|||
i386 |
RPMS |
*.i386.rpm |
|
*.centos.noarch.rpm |
|||
repodata/ |
|||
x86_64 |
RPMS |
*.i386.rpm |
|
*.centos.noarch.rpm |
|||
repodata/ |
(2)配置yum客户的更新源
yum使用reposdir(/etc/yum.repos.d)目录下的一系列.repo文件列出可得到软件包仓库的镜像站点地址。围住状况下有以下两个文件。
在.repo文件中,配置语法是分段的,每一段配置一个软件仓库,配置语法以下:
[repositoryid]
name=Some name for this repository
baseurl=url://server1/path/to/repository/
url://server2/path/to/repository/
url://server3/path/to/repository/
mirrorlist=url://path/to/mirrorlist/repository/
enabled=0/1
gpgcheck=0/1
gpgkey=A URL pointing to the ASCII-armoured GPG key file for the repository
其中:
http - 用于指定远程HTTP协议的源。
ftp - 用于指定远程FTP协议的源。
file - 用于本地镜像或NFS挂装文件系统。
Tips:在name baseurl中常用以下的变量:
另外,你还要注意如下几点。
<1>设置网络更新源
#vi /etc/yum.repos.d/CetnOS-Base.repo
[base]
name=CentOS-5-Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever5&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://ftp.sjtu.edu.cn/centos/5/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#released updates
[update]
name=CentOS-5-Updates
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=updates
baseurl=http://ftp.sjtu.edu.cn/centos/5/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#packages used/produced in the build but not released
[addons]
name=CentOS-5-Addons
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=addons
baseurl=http://ftp.sjtu.edu.cn/centos/5/addons/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#additional packages that may be useful
[extras]
name=CentOS-5-Extras
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=extras
baseurl=http://ftp.sjtu.edu.cn/centos/5/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-5-Plus
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=centosplus
baseurl=http://ftp.sjtu.edu.cn/centos/5/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#contrib - packages by Centos Users
[contrib]
name=CentOS-5-Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=contrib
baseurl=http://ftp.sjtu.edu.cn/centos/5/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
导入key
#rpm --import http://ftp.sjtu.edu.cn/centos/5/os/i386/RPM-GPG-KEY-CentOS-5
运行,测试
#yum update
所有删除临时文件
#yum clean all
<2>设置本地更新源
为了使用安装光盘做为更新源,能够修改CentOS-Media.repo文件,下面是一个配置实例。
[c5-media]
name=CentOS-$releaserver - Media
baseurl=file:///media/CentOS/
file:///media/cdrom/
file:///media/cdrecorder/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-beta
Tips:1.为了使用c5-media仓库,须要将CentOS-Base.repo文件中的base仓库用enabled=0设置成不可用。
2.若本地磁盘空间有足够空间,你也能够将安装光盘复制到本地磁盘的一个目录中。
<3>设置非官方更新源
下面以安装rpmforge软件包为例添加非官方更新源。
步骤1:到http://dag.wieers.com/rpm/packages/rpmforge-release/查找适用于RHEL5/CentOS5软件包。
步骤2:下载适用于RHEL5/CentOS5的软件包。
#wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-el5.rf.i386.rpm
#rpm -ivh rpm rpmforge-release-0.3.6-el5.rf.i386.rpm
#rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfiorge-*
安装rpmforge-release软件包以后,你能够看到/etc/yum.repos.d/rpmforge.repo文件。之后yum就可使用这个更新源了。
你也可使用手工方法添加DAG的仓库。好比,创建dag.repo定义非官方库: #vi /etc/yum.repos.d/dag.repo [dag] name=Dag RPM Repository for Red Hat Enterprise Linux baseurl=http://apt.sw.be/redhat/el$releaserver/en/$basearch/dag gpgcheck=1 enabled=1 gpgkey=http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt