当前位置:Linux教程 - RedHat - Red hat 6 配置实例

Red hat 6 配置实例



        

    作者:李家芳 ([email protected]


    以下是我使用Red hat 6.0的一些笔记,与大家分享。

    使用APACHE提供虚拟主机WEB SERVER
    -------------------------------------
    1. 先把主机配置为多主址, 在X下运行linuxconf命令:
    在Server栏下配置virtual host, 选定网卡eth0, 配置其IP和MASK.
    原始IP:192.168.0.241
    掩码 :255.255.255.0

    Virtual host IP Mask
    ------------------------------------------
    192.168.0.242 255.255.255.0
    192.168.0.243 255.255.255.0
    192.168.0.244 255.255.255.0
    192.168.0.245 255.255.255.0
    192.168.0.246 255.255.255.0


    2. 编辑/etc/httpd/conf/httpd.conf文件, 在最后加入:


    DocumentRoot /home/httpd/html/241/Hardware.AIX
    ServerName bbs1.ttsc.hl.cn



    DocumentRoot /home/httpd/html/242/Networking.AIX
    ServerName bbs2.ttsc.hl.cn



    DocumentRoot /home/httpd/html/243/Security.AIX
    ServerName bbs3.ttsc.hl.cn



    DocumentRoot /home/httpd/html/244/Unix.AIX
    ServerName bbs4.ttsc.hl.cn



    DocumentRoot /home/httpd/html/245/WinNT.AIX
    ServerName bbs5.ttsc.hl.cn



    DocumentRoot /home/httpd/html/246/XWindow.AIX
    ServerName bbs6.ttsc.hl.cn


    3. 建立目录, 拷入WEB文档.

    mkdir /home/httpd/html/241/Hardware.AIX
    mkdir /home/httpd/html/242/Networking.AIX
    mkdir /home/httpd/html/243/Security.AIX
    mkdir /home/httpd/html/244/Unix.AIX
    mkdir /home/httpd/html/245/WinNT.AIX
    mkdir /home/httpd/html/246/XWindow.AIX

    4. 重新启动httpd服务.
    /usr/sbin/httpd stop
    /usr/sbin/httpd start

    5. OK, 现在可以在其他机器上访问
    http://192.168.0.241/
    http://192.168.0.242/
    http://192.168.0.243/
    http://192.168.0.244/
    http://192.168.0.245/
    http://192.168.0.246/

    ================================================================

    在REDHAT6.0上配置DHCP服务
    =====================================

    条件:
    ---------
    子网掩码: 255.255.255.0
    租借地址: 192.168.0.181 ~ 192.168.0.190
    192.168.0.201 ~ 192.168.0.220
    固定IP: 192.168.0.188 ~ 08:00:2b:4c:59:23
    缺省网关: 192.168.0.254
    DNS地址: 202.97.227.93, 192.168.0.241


    建立步骤如下:
    =================


    安装DHCPD服务程序:
    -------------------------
    可以到下面的网址取得

    ftp://ftp.isc.org/isc/dhcp/

    在你下载之後,你必须将它解开。然後进入解开的目录,输入:

    ./configure

    要做好安装前设定,可能要会花点时间。後随输入:

    make

    以及

    make install


    校验核心:
    ---------------
    请输入 ifconfig -a,你将看到如下的讯息:

    --------------------------------------------------------------------------------

    eth0 Link encap:10Mbps Ethernet HWaddr 00:C0:4F:D3:C4:62
    inet addr:183.217.19.43 Bcast:183.217.19.255 Mask:255.255.255.0
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:2875542 errors:0 dropped:0 overruns:0
    TX packets:218647 errors:0 dropped:0 overruns:0
    Interrupt:11 Base address:0x210

    --------------------------------------------------------------------------------

    如果未显示 MULTICAST 的讯息,你应该重新设定你的核心,加入对“多址传播(multicast)” 的支援。
    对於大多数的系统而言,你几乎都不必如此做。


    需要加入动态路由:
    ---------------------
    输入:

    route add -host 255.255.255.255 dev eth0

    如果你看到如下的讯息

    \"255.255.255.255: Unknown host\"

    你应该将下面的资讯加入到 /etc/hosts 档案中:

    255.255.255.255 all-ones

    然後,输入:

    route add -host all-ones dev eth0



    route add -net 255.255.255.0 dev eth0

    eth0 应该是你目前使用网路卡的装置名称。如果不是,你得配合实际情况做正确的修改。


    需要配置文件:
    ----------------------
    /etc/dhcpd.conf
    /etc/dhcpd.leases 初次配置只需建立文件名(内部为空), 当有客户租用时
    系统自动写入租用记录;


    调试命令:
    -----------------------------
    /usr/sbin/dhcpd 停止DHCP服务;
    /usr/sbin/dhcpd 启动DHCP服务;
    /usr/sbin/dhcpd -d -f 启动并放到前台调试;

    在/etc下配置dhcpd.conf文件如下:
    -----------------------------------------------------------------------
    [root@lee2 /etc]# more dhcpd.conf
    default-lease-time 6000;
    max-lease-time 72000;
    option subnet-mask 255.255.255.0;
    option broadcast-address 192.168.0.255;
    option routers 192.168.0.254;
    option domain-name-servers 202.97.227.93, 192.168.0.241;
    option domain-name \"ttsc.hl.cn\";

    subnet 192.168.0.0 netmask 255.255.255.0 {
    range 192.168.0.181 192.168.0.190;
    range 192.168.0.201 192.168.0.220;
    }

    #fix ip
    host haagen {
    hardware ethernet 08:00:2b:4c:59:23;
    fixed-address 192.168.0.188;
    }
    -----------------------------------------------------------------------====================================================================


    在REDHAT6.0上配置DNS服务
    =========================

    条件:
    -----------------
    服务器: lee2.ttsc.hl.cn 192.168.0.241 OS: Redhat6.0
    网段: 192.168.0
    域名: ttsc.hl.cn
    邮件服务器: lee2.ttsc.hl.cn
    ftp服务器: xiu.ttsc.hl.cn
    www服务器: lee2.ttsc.hl.cn
    主机: xiu 192.168.0.155
    lee 192.168.0.170
    zq 192.168.0.128
    lee2 192.168.0.241
    madi 192.168.0.108

    需配置文件:
    ---------------------
    /etc/named.boot
    /etc/named.conf
    /var/named/db.ttsc
    /var/named/db.192.168.0

    缺省文件(不需修改):
    -----------------------
    /var/named/named.ca
    /var/named/named.local

    若服务器自身也使用自己做解析,则配置文件:
    ------------------------------------------
    /etc/resolv.conf

    调试命令:
    --------------------
    /usr/sbin/ndc start 启动DNS服务;
    /usr/sbin/ndc stop 停止DNS服务;
    /usr/sbin/ndc reload 刷新数据库数据;


    配置文件清单:
    ------------------------------------------------------------------------------------------------
    [root@lee2 /etc]# more named.boot
    ;
    ; a caching only nameserver config
    ;
    directory /var/named
    cache . named.ca
    primary 0.0.127.in-addr.arpa named.local
    primary ttsc.hl.cn db.ttsc
    primary 0.168.192.in-addr.arpa db.192.168.0
    ------------------------------------------------------------------------------------------------
    [root@lee2 /etc]# more named.conf
    options {
    directory \"/var/named\";
    };
    zone \".\" {
    type hint;
    file \"named.ca\";
    };
    zone \"0.0.127.in-addr.arpa\"{
    type master;
    file \"named.local\";
    };
    zone \"0.168.192.in-addr.arpa\"{
    type master;
    file \"db.192.168.0\";
    };
    zone \"ttsc.hl.cn\"{
    type master;
    file \"db.ttsc\";
    };
    ------------------------------------------------------------------------------------------------
    [root@lee2 named]# more named.local
    @ IN SOA localhost. root.localhost. (
    1997022700 ; serial
    28800 ; refresh
    14400 ; retry
    3600000 ; expire
    86400 ; default_ttl
    )
    @ IN NS localhost.
    1 IN PTR localhost.
    ------------------------------------------------------------------------------------------------
    [root@lee2 named]# more db.ttsc
    @ IN SOA lee2.ttsc.hl.cn. root.lee2.ttsc.hl.cn. (
    2000082014; serial
    28800 ; refresh
    14400 ; retry
    3600000 ; expire
    86400 ; default_ttl
    )
    NS lee2.ttsc.hl.cn.
    MX 10 lee2.ttsc.hl.cn.

    localhost A 127.0.0.1
    lee2 A 192.168.0.241
    lee A 192.168.0.170
    xiu A 192.168.0.155
    zq A 192.168.0.128
    madi A 192.168.0.109

    mail MX 10 lee2.ttsc.hl.cn.

    www CNAME lee2.ttsc.hl.cn.
    ftp CNAME xiu.ttsc.hl.cn.
    ns CNAME lee2.ttsc.hl.cn.
    -----------------------------------------------------------------------------------------------
    [root@lee2 named]# more db.192.168.0
    @ IN SOA lee2.ttsc.hl.cn. root.lee2.ttsc.hl.cn. (
    2000082014; serial
    28800 ; refresh
    14400 ; retry
    3600000 ; expire
    86400 ; default_ttl
    )
    NS lee2.ttsc.hl.cn.

    241 IN PTR lee2.ttsc.hl.cn.
    170 IN PTR lee.ttsc.hl.cn.
    155 IN PTR xiu.ttsc.hl.cn.
    128 IN PTR zq.ttsc.hl.cn.
    109 IN PTR madi.ttsc.hl.cn.
    -----------------------------------------------------------------------------------------------
    [root@lee2 /etc]# more resolv.conf
    search ttsc.hl.cn
    # nameserver 202.97.227.93
    # nameserver 202.97.224.68
    nameserver 192.168.0.241
    -----------------------------------------------------------------------
    ======================================================================


    在REDHAT6.0上配置Sendmail服务
    =============================

    条件:
    -----------------
    服务器: lee2.ttsc.hl.cn 192.168.0.241 OS: Redhat6.0
    网段: 192.168.0
    域名: ttsc.hl.cn
    邮件服务器: lee2.ttsc.hl.cn
    email用户帐号:Soldier, 别名Duke
    email地址:[email protected]

    需建立帐号:
    ---------------------
    使用useradd命令创建用户的email帐号:
    # usr/sbin/useradd -g mail -n soldier
    # passwd soldier

    需配置文件:
    ---------------------
    /etc/sendmail.cw
    /etc/aliases
    /etc/mail/access
    /etc/inetd.conf
    /etc/services

    缺省文件(不需修改):
    -----------------------
    /etc/sendmail.mc
    /etc/sendmial.cf


    应保证在DNS服务器中有邮件主机的ENTRY:
    ------------------------------------------
    lee2.ttsc.hl.cn

    调试命令:
    --------------------
    修改POP3的影子服务(/etc/inetd.conf)和端口(/etc/services)以后,应重新启动inetd.

    修改EMAIL帐号的别名(/etc/aliases)以后,应使用newaliases命令编译:
    # newaliases

    修改邮件服务器的别名(/etc/sendmail.cw)以及其他改动以后,应重启动sendmail服务:
    # /etc/rc.d/init.d/sendmail restart


    配置文件清单:
    ------------------------------------------------------------------------------------------------
    [root@lee2 /etc]# more sendmail.cw
    # sendmail.cw - include all aliases for your machine here.
    #该邮件服务器的所有DNS名称。
    ttsc.hl.cn
    lee2.ttsc.hl.cn

    -----------------------------------------------------------------------
    所有EMAIL帐号的别名:

    [root@lee2 /etc]# more aliases
    #
    # @(#)aliases 8.2 (Berkeley) 3/5/94
    #
    # Aliases in this file will NOT be expanded in the header from
    # Mail, but WILL be visible over networks or from /bin/mail.
    #
    # >>>>>>>>>> The program \"newaliases\" must be run after
    # >> NOTE >> this file is updated for any changes to
    # >>>>>>>>>> show through to sendmail.
    #

    # Basic system aliases -- these MUST be present.
    MAILER-DAEMON: postmaster
    postmaster: root

    如果希望邮给[email protected]的邮件被转发到[email protected]则加入
    以下记录,否则不加。
    Soldier: [email protected]
    如希望邮给[email protected]的邮件被转发到[email protected]则加入
    以下记录,否则不加。
    Duke: Soldier

    # General redirections for pseudo accounts.
    bin: root
    daemon: root
    (以下略)
    -----------------------------------------------------------------------
    [root@lee2 mail]# more access
    # Check the /usr/doc/sendmail-8.9.3/README.cf file for a description
    # of the format of this file. (search for access_db in that file)
    # The /usr/doc/sendmail-8.9.3/README.cf is part of the sendmail-doc
    # package.
    #
    # by default we allow relaying from localhost...
    localhost.localdomain RELAY
    localhost RELAY
    # 加入可以通过本邮件服务器收发邮件的客户的IP:以下为允许该网段上的所有计算机。
    192.168.0 RELAY
    -----------------------------------------------------------------------
    [root@lee2 /etc]# more inetd.conf
    #
    # inetd.conf This file describes the services that will be available
    # through the INETD TCP/IP super server. To re-configure
    # the running INETD process, edit this file, then send the
    # INETD process a SIGHUP signal.
    #
    (中间略)
    # Pop and imap mail services et al
    #
    #pop-2 stream tcp nowait root /usr/sbin/tcpd ipop2d
    # 确定运行POP3影子服务程序:
    pop-3 stream tcp nowait root /usr/sbin/tcpd ipop3d
    #imap stream tcp nowait root /usr/sbin/tcpd imapd
    #
    # The Internet UUCP service.
    #
    #uucp stream tcp nowait uucp /usr/sbin/tcpd /usr/lib/uucp/uucico

    -l
    #
    (以下略)
    -----------------------------------------------------------------------
    [root@lee2 /etc]# more services
    # /etc/services:
    # $Id: services,v 1.4 1997/05/20 19:41:21 tobias Exp $
    #
    # Network services, Internet style
    #
    (中间略)
    # unfortunately the poppassd (Eudora) uses a port which has already
    # been assigned to a different service. We list the poppassd as an
    # alias here. This should work for programs asking for this service.
    # (due to a bug in inetd the 3com-tsmux line is disabled)
    #3com-tsmux 106/tcp poppassd
    #3com-tsmux 106/udp poppassd
    rtelnet 107/tcp # Remote Telnet
    rtelnet 107/udp
    pop-2 109/tcp postoffice # POP version 2
    pop-2 109/udp
    # 确保POP3端口开放:
    pop-3 110/tcp # POP version 3
    pop-3 110/udp
    sunrpc 111/tcp portmapper # RPC 4.0 portmapper TCP
    sunrpc 111/udp portmapper # RPC 4.0 portmapper UDP
    auth 113/tcp authentication tap ident
    sftp 115/tcp
    uucp-path 117/tcp
    (以下略)
    -----------------------------------------------------------------------=======================================================================

    samba
    -------------------------------------

    在/etc/services中,
    netbios-ns 137/tcp 137/udp;
    netbios-dgm 138/tcp 138/udp;
    netbios-ssn 139/tcp 139/udp;

    启动相关进程:
    /usr/sbin/smbd -D
    /usr/sbin/nmbd -D

    配置文件:
    /etc/smb.conf

    配置文件语法检查:
    /usr/bin/testparm smb.conf

    用户及口令文件:
    /etc/smbpasswd

    添加用户和口令:
    /usr/bin/smbpasswd -a username

    测试自身服务:
    smbclient -L localhost -U%

    浏览其他机器:
    smbclient -L servername

    访问其他机器共享资源:如访问\\\\wangpeng\\siguo
    smbclient //wangpeng/siguo

    测试网络:
    nmblookup -d 2 \*\

    测试WINS:
    smbclient -L server -R wins

    发布人:netbull 来自:蓝森林