系统版本:7.3、8.0 作者:Linuxmars
前期准备很要求: 日期:2003-3-6
(1) RedHat Linux 7.3或RedHat Linux 8.0安装时选择了安装telnet、ftp、dns网络服务的软件包。
(2)确定机器的名称、IP、路由等;如:
----------------------------------------------------------------------------------------------------------------------
hostname: mail.orizone.com
ip: 10.0.0.100
netmask 255.255.255.0
gateway: 10.0.0.1
----------------------------------------------------------------------------------------------------------------------
(3)要启动的服务;下面介绍如何配置网络网卡和telnet、ftp、dns服务。
具体的配置步骤:
一、 保证网络畅通(配置网卡和IP)
在Redhat中,对网络的配置在系统安装的时候基本配置中就已经完成了。所有的配置数据都保存在/etc中。可以在运行中对网络进行配置,且不须重新启动系统。
先用命令ifconfig –a 查看是否找到了网卡,如果没有就进行下面的第1步,否则进行第3步。找到网卡应该显示如下信息:
----------------------------------------------------------------------------------------------------------------------
eth0 Link encap:Ethernet HWaddr 00:80:C8:43:BC:79
inet addr:10.0.0.100 Bcast:10.0.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:148 errors:0 dropped:0 overruns:0 frame:0
TX packets:244 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:10065 (9.8 Kb) TX bytes:15140 (14.7 Kb)
Interrupt:9 Base address:0x300
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:98 errors:0 dropped:0 overruns:0 frame:0
TX packets:98 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:9312 (9.0 Kb) TX bytes:9312 (9.0 Kb)
----------------------------------------------------------------------------------------------------------------------
由于Linux通常会自动检测该品牌类型所有安装的网卡,这对于PCI驱动程序来说,是没有什么问题的;但对于ISA网卡,探寻一个网卡是不安全的操作,因此你需要提供网卡的I/O地址以及模块知道去哪里查找。这一信息存储在文件/etc/ modules.conf中。
1、修改/etc/modules.conf文件,加入以下信息:
alias eth0 网络模块名(不用加.o)
options 网络模块名 io=I/O地址 irq=IRQ号(有时候可以不写这一项)
如:
----------------------------------------------------------------------------------------------------------------------
alias parport_lowlevel parport_pc //
alias usb-controller usb-uhci //
alias eth0 ne
options eth0 io=0x300 irq=9
----------------------------------------------------------------------------------------------------------------------
2、运行modprobe eth0测试一下。
3、修改/etc/sysconfig/network-scripts/ifcfg-eth0,如下:
----------------------------------------------------------------------------------------------------------------------
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=10.0.0.100 //你为服务器设定的IP地址
NETMASK=255.255.255.0
BROADCAST=10.0.0.255
GATEWAY=10.0.0.1 //网关
----------------------------------------------------------------------------------------------------------------------
4.运行/etc/rc.d/init.d/network restart网卡将生效。运行ifconfig –a 查看是否已经找到网卡,如果没有检查以上步骤的配置是否有误。如果找到了网卡,运行ifconfig eth0,应该显示相应的信息:
----------------------------------------------------------------------------------------------------------------------
eth0 Link encap:Ethernet HWaddr 00:80:C8:43:BC:79
inet addr:10.0.0.100 Bcast:10.0.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3135 errors:0 dropped:0 overruns:0 frame:0
TX packets:628 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:219744 (214.5 Kb) TX bytes:54105 (52.8 Kb)
Interrupt:9 Base address:0x300
二、 TELNET服务(虽然这里提到telnet,但是为了安全,最好还是使用ssh,这个程序现在流行的unix都默认安装)
修改如下2个文件,使系统能被网络上的其他机器的用户访问,如果要能root远程操作机器
开通TELNET服务是很必要的。
1./etc/securetty,添加以下行:
…… //省略
pts/0
pts/1
……
pts/5 //可以加多行
----------------------------------------------------------------------------------------------------------------------
2./etc/xinetd.d/telnet
----------------------------------------------------------------------------------------------------------------------
# default: on
# description: The telnet server serves telnet sessions; it uses # unencrypted username/password pairs for authentication.
service telnet
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
}
----------------------------------------------------------------------------------------------------------------------
确保disable=no
三、FTP服务
1./etc/ftpusers 这个文件中的用户被拒绝响应ftp服务。用#将root屏蔽掉:
#root
这样root没有被这个配置文件限制ftp服务,可以在其他机器上请求这台机器提供的ftp服务。
2./etc/ftpaccess 用#将以下两行注释掉,
deny-uid% -99%65534
deny-gid% -99%65534
注释后为:
#deny-uid% -99%65534
#deny-gid% -99%65534
3./etc/xinetd.d/wu-ftpd 决定是否能提供ftp服务。
确保disable=no,可以向其他机器开通ftp服务。
四、 配置唯缓存DNS服务
修改(若没有就添加)以下文件:
1./etc/resolv.conf 该文件指定域名服务器的IP和搜索的顺序。
----------------------------------------------------------------------------------------------------------------------
nameserver 202.103.44.5 //域名服务器的IP
search localdomain
----------------------------------------------------------------------------------------------------------------------
2./etc/nsswitch.conf 该文件处理host表和DNS的顺序,告诉系统哪里查找特定类型的配置信息(即服务),将以host开头的行替换为如下行:
hosts: files nisplus dns
替换后为:
----------------------------------------------------------------------------------------------------------------------
# Example:
#passwd: db files nisplus nis
#shadow: db files nisplus nis
#group: db files nisplus nis
passwd: files nisplus
shadow: files nisplus
group: files nisplus
#hosts: db files nisplus nis dns
hosts: files nisplus dns
# Example - obey only what nisplus tells us...
#services: nisplus [NOTFOUND=return] files
#networks: nisplus [NOTFOUND=return] files
#protocols: nisplus [NOTFOUND=return] files
#rpc: nisplus [NOTFOUND=return] files
#ethers: nisplus [NOTFOUND=return] files
#netmasks: nisplus [NOTFOUND=return] files
bootparams: nisplus [NOTFOUND=return] files
ethers: files
netmasks: files
networks: files
protocols: files nisplus
rpc: files
services: files nisplus
netgroup: files nisplus
publickey: nisplus
automount: files nisplus
aliases: files nisplus
----------------------------------------------------------------------------------------------------------------------
3../etc/named.conf
----------------------------------------------------------------------------------------------------------------------
options {
directory "/var/named"; //这里的/var/named用于存放下面3个配置文件,用户
//可以自己指定为别的的目录。
/*
* If there is a firewall between you and nameservers you want
* to talk to, you might need to uncomment the query-source
* directive below. Previous versions of BIND always asked
* questions using port 53, but BIND 8.1 uses an unprivileged
* port by default.
*/
// query-source address * port 53;
};
//
// a caching only nameserver config
//
controls {
inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
----------------------------------------------------------------------------------------------------------------------
对应的有以下3个配置文件,一般不需修改;
(1)./var/named/named.ca //系统自带,不要修改
(2)./var/named/named.local
----------------------------------------------------------------------------------------------------------------------
$TTL 86400
@ IN SOA localhost.
IN NS local
1 IN PTR localhost.
----------------------------------------------------------------------------------------------------------------------
(3)/var/named/localhost.zone ////系统自带,不要修改
----------------------------------------------------------------------------------------------------------------------
$TTL 86400
$ORIGIN localhost.
@ 1D IN SOA @ root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
1D IN NS @
1D IN A 127.0.0.1
一切配置就绪,运行以下命令:
#service named restart 或
#/etc/init.d/named restart
使配置生效。用nslookup命令测试是否能够进行正确的地址解析。例如:
#nslookup www.sina.com.cn
----------------------------------------------------------------------------------------------------------------------
Note: nslookup is deprecated and may be removed from future releases.
Consider using the `dig' or `host' programs instead. Run nslookup with
the `-sil[ent]' option to prevent this message from appearing.
Server: 202.103.44.5
Address: 202.103.44.5#53
Non-authoritative answer:
www.sina.com.cn canonical name = jupiter.sina.com.cn.
Name: jupiter.sina.com.cn
Address: 218.201.44.8
Name: jupiter.sina.com.cn
Address: 218.201.44.9