欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Linux系統(tǒng)配置網(wǎng)絡(luò)詳解

  發(fā)布時(shí)間:2008-09-08 17:07:56   作者:佚名   我要評(píng)論
一.安裝和配置網(wǎng)絡(luò)設(shè)備   在安裝linux時(shí),如果你有網(wǎng)卡,安裝程序?qū)?huì)提示你給出tcp/ip網(wǎng)絡(luò)的配置參數(shù),如本機(jī)的ip地址,缺省網(wǎng)關(guān)的ip地址,DNS的ip地址等等.根據(jù)這些配置參數(shù),安裝程序?qū)?huì)自動(dòng)把網(wǎng)卡(linux系統(tǒng)首先要支持)驅(qū)動(dòng)程序編譯到內(nèi)核中去.但是我們一定要了解

  2. 修改/etc/lilo.conf文件
  在一些比較新的linux版本中,由于操作系統(tǒng)自動(dòng)檢測(cè)所有相關(guān)的硬件,所以此時(shí)不必修改/etc/lilo.conf文件.但是對(duì)于ISA網(wǎng)卡和老的版本,為了在系統(tǒng)初始化中對(duì)新加的網(wǎng)卡進(jìn)行初始化,可以修改lilo.conf文件.在/etc/lilo.conf文件中增加如下命令:
  append="ether=5,0x240,eth0 ether=7,0x300,eth1"
  這條命令的含義是eth0的io地址是0x240,中斷是5,eth1的io地址是0x300,中斷是7.
  實(shí)際上,這條語(yǔ)句來(lái)自在系統(tǒng)引導(dǎo)影像文件時(shí)傳遞的參數(shù),
  LILO: linux ether=5,0x240,eth0 ether=7,0x300,eth1
  這種方法也同樣能夠使linux系統(tǒng)配置好兩個(gè)網(wǎng)卡.類似的,在使用三個(gè)以上網(wǎng)卡的時(shí)候,也可以依照同樣的方法.
  在配置好網(wǎng)卡之后,就應(yīng)該配置TCP/IP的參數(shù),在一般情況下,在安裝linux系統(tǒng)的同時(shí)就會(huì)提示你配置網(wǎng)絡(luò)參數(shù).但是之后如果我們想要修改網(wǎng)絡(luò)設(shè)置,可以使用如下的命令:
  #ifconfig eth0 A.B.C.D netmask E.F.G.H
  A.B.C.D 是eth0的IP地址,E.F.G.H是網(wǎng)絡(luò)掩碼.
  其實(shí),在linux系統(tǒng)中我們可以給一塊網(wǎng)卡設(shè)置多個(gè)ip地址,例如下面的命令:
  #ifconfig eth0:1 202.112.11.218 netmask 255.255.255.192
  然后,使用命令#ifconfig -a 就可以看到所有的網(wǎng)絡(luò)接口的界面:
  eth0   Link encap:Ethernet HWaddr 00:90:27:58:AF:1A
       inet addr:202.112.13.204 Bcast:202.112.13.255 Mask:255.255.255.192
       UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
       RX packets:435510 errors:0 dropped:0 overruns:0 frame:2
       TX packets:538988 errors:0 dropped:0 overruns:0 carrier:0
       collisions:318683 txqueuelen:100
       Interrupt:10 Base address:0xc000

  eth0:1  Link encap:Ethernet HWaddr 00:90:27:58:AF:1A
       inet addr:202.112.11.218 Bcast:202.112.11.255 Mask:255.255.255.192
       UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
       Interrupt:10 Base address:0xc000

  lo    Link encap:Local Loopback
       inet addr:127.0.0.1 Mask:255.0.0.0
       UP LOOPBACK RUNNING MTU:3924 Metric:1
       RX packets:2055 errors:0 dropped:0 overruns:0 frame:0
       TX packets:2055 errors:0 dropped:0 overruns:0 carrier:0
       collisions:0 txqueuelen:0
  我們看到網(wǎng)絡(luò)接口有三個(gè),eth0 , eth0:1,lo,eth0是真實(shí)的以太網(wǎng)絡(luò)接口,eth0:1和eth0是同一塊網(wǎng)卡,只不過(guò)綁定了另外的一個(gè)地址,lo是會(huì)送地址。eth0和eth0:1可以使用不同網(wǎng)段的ip地址,這在同一個(gè)物理網(wǎng)段卻使用不同的網(wǎng)絡(luò)地址的時(shí)候十分有用。
  另外,網(wǎng)卡有一種模式是混雜模式(prosimc),在這個(gè)模式下,網(wǎng)卡將會(huì)接收網(wǎng)絡(luò)中所有的數(shù)據(jù)包,一些linux下的網(wǎng)絡(luò)****工具例如tcpdump,snort等等都是把網(wǎng)卡設(shè)置為混雜模式.
  ifconfig命令可以在本次運(yùn)行的時(shí)間內(nèi)改變網(wǎng)卡的ip地址,但是如果系統(tǒng)重新啟動(dòng),linux仍然按照原來(lái)的默認(rèn)的設(shè)置啟動(dòng)網(wǎng)絡(luò)接口。這時(shí)候,可以使用netconfig或netconf命令來(lái)重新設(shè)置默認(rèn)網(wǎng)絡(luò)參數(shù)。netconfig 命令是重新配置基本的tcp/ip參數(shù),參數(shù)包括是否配置為動(dòng)態(tài)獲得ip地址(dhcpd和bootp),網(wǎng)卡的ip地址,網(wǎng)絡(luò)掩碼,缺省網(wǎng)關(guān)和首選的域名服務(wù)器地址。netconf命令可以詳細(xì)的配置所有網(wǎng)絡(luò)的參數(shù),分為客戶端任務(wù),服務(wù)器端任務(wù)和其他的配置三個(gè)部分,在客戶端的配置中,主要包括基本主機(jī)的配置(主機(jī)名,有效域名,網(wǎng)絡(luò)別名,對(duì)應(yīng)相應(yīng)網(wǎng)卡的ip地址,網(wǎng)絡(luò)掩碼,網(wǎng)絡(luò)設(shè)備名,網(wǎng)絡(luò)設(shè)備的內(nèi)核驅(qū)動(dòng)程序),DNS地址配置,缺省網(wǎng)關(guān)的地址配置,NIS地址配置,ipx接口配置,ppp/slip的配置等等。在服務(wù)器端配置中,主要包括NFS的配置,DNS的配置,ApacheWebServer配置,Samba的配置和Wu-ftpd的配置。在其他的配置選項(xiàng)中,一個(gè)是關(guān)于/etc/hosts文件中的主機(jī)配置,一個(gè)是關(guān)于/etc/networks文件中的網(wǎng)絡(luò)配置信息,最后是關(guān)于使用linuxconf配置的信息。
  在linuxconf命令下,同樣也可以配置網(wǎng)絡(luò)信息,但是大家可以發(fā)現(xiàn),linuxconf程序是調(diào)用netconf來(lái)進(jìn)行網(wǎng)絡(luò)配置的。
  另外,在/etc/sysconfig/network-scripts目錄下存放著系統(tǒng)關(guān)于網(wǎng)絡(luò)的配置文件,范例如下:

  ifcfg-eth0*  ifdown-post*  ifup-aliases*  ifup-ppp*
  ifcfg-eth1*  ifdown-ppp*   ifup-ipx*    ifup-routes*
  ifcfg-lo*   ifdown-sl*   ifup-plip*    ifup-sl*
  ifdown@    ifup@      ifup-post*    network-functions

  ifcfg-eth0是以太口eth0的配置信息,它的內(nèi)容如下:

  DEVICE="eth0"              /*指明網(wǎng)絡(luò)設(shè)備名稱*/
  IPADDR="202.112.13.204"         /*指明網(wǎng)絡(luò)設(shè)備的ip地址*/
  NETMASK="255.255.255.192"        /*指明網(wǎng)絡(luò)掩碼*/
  NETWORK=202.112.13.192         /*指明網(wǎng)絡(luò)地址*/
  BROADCAST=202.112.13.255         /*指明廣播地址*/
  ONBOOT="yes"               /*指明在系統(tǒng)啟動(dòng)時(shí)是否激活網(wǎng)卡*/
  BOOTPROTO="none"             /*指明是否使用bootp協(xié)議*/
  
  所以,我們也可以修改這個(gè)文件來(lái)進(jìn)行l(wèi)inux下網(wǎng)絡(luò)參數(shù)的改變。

網(wǎng)絡(luò)服務(wù)的配置:

  在這一部分,我們并不是詳細(xì)的介紹具體的網(wǎng)絡(luò)服務(wù)器(DNS,FTP,WWW,SENDMAIL)的配置(那將是巨大的篇幅),而是介紹一下與linux網(wǎng)絡(luò)服務(wù)的配置相關(guān)的文件.

1. LILO的配置文件
  在linux系統(tǒng)中,有一個(gè)系統(tǒng)引導(dǎo)程序,那就是lilo(linux loadin),利用lilo可以實(shí)現(xiàn)多操作系統(tǒng)的選擇啟動(dòng).它的配置文件是/etc/lilo.conf.在這個(gè)配置文件中,lilo的配置參數(shù)主要分為兩個(gè)部分,一個(gè)是全局配置參數(shù),包括設(shè)置啟動(dòng)設(shè)備等等.另一個(gè)是局部配置參數(shù),包括每個(gè)引導(dǎo)影像文件的配置參數(shù).在這里我就不詳細(xì)介紹每個(gè)參數(shù),特別的僅僅說(shuō)明兩個(gè)重要的參數(shù)--------password和restricted選項(xiàng),password選項(xiàng)為每個(gè)引導(dǎo)的影像文件加入口令保護(hù).我們都知道,在linux系統(tǒng)中有一個(gè)運(yùn)行模式是單用戶模式,在這個(gè)模式下,用戶是以超級(jí)用戶的身份登錄到linux系統(tǒng)中.人們可以通過(guò)在lilo引導(dǎo)的時(shí)候加入?yún)?shù)(linux single 或linux init 0)就可以不需要口令直接進(jìn)入單用戶模式的超級(jí)用戶環(huán)境中,這將是十分危險(xiǎn)的.所以在lilo.conf中增加了password的配置選項(xiàng)來(lái)為每個(gè)影像文件增加口令保護(hù).你可以在全局模式中使用password選項(xiàng)(對(duì)所有影像文件都加入相同的口令),或者為每個(gè)單獨(dú)的影像文件加入口令.這樣一來(lái),在每次系統(tǒng)啟動(dòng)時(shí),都會(huì)要求用戶輸入口令.也許你覺(jué)得每次都要輸入口令很麻煩,可以使用restricted選項(xiàng),它可以使lilo僅僅在linux啟動(dòng)時(shí)輸入了參數(shù)(例如 linux single)的時(shí)候才會(huì)檢驗(yàn)密碼.這兩個(gè)選項(xiàng)可以極大的增加系統(tǒng)的安全性,建議在lilo.conf文件中設(shè)置它們.由于password在/etc/lilo.conf文件是以明文存放的,所以必須要將/etc/lilo.conf文件的屬性改為僅僅root可讀(0400).
  另外,在lilo的早期版本中,存在著引導(dǎo)扇區(qū)必須存放到前1024柱面的限制,在lilo的2.51版本中已經(jīng)突破了這個(gè)限制,同時(shí)引導(dǎo)界面也變成了圖形界面更加直觀.最新版本的下載站點(diǎn):
  ftp://166.111.136.3/pub/linux/lilo/lilo-2.51.tar.gz
  下載解壓后,使用命令make install即可完成安裝.
  注意: 物理安全才是最基本的安全,即使在lilo.conf中增加了口令保護(hù),如果沒(méi)有物理安全,惡意闖入者可以使用啟動(dòng)軟盤啟動(dòng)linux系統(tǒng).

2. 域名服務(wù)的配置文件
  (1)/etc/HOSTNAME 在這個(gè)文件中保存著linux系統(tǒng)的主機(jī)名和域名.范例文件

  ice.xanet.edu.cn

  這個(gè)文件表明了主機(jī)名ice,域名是xanet.edu.cn
  (2)/etc/hosts和/etc/networks文件 在域名服務(wù)系統(tǒng)中,有著主機(jī)表機(jī)制,/etc/hosts和/etc/networks就是主機(jī)表發(fā)展而來(lái)在/etc/hosts中存放著你不需要DNS系統(tǒng)查詢而得的主機(jī)ip地址和主機(jī)名的對(duì)應(yīng),下面是一個(gè)范例文件:
  # ip 地址 主機(jī)名 別名
  127.0.0.1      localhosts        loopback
  202.117.1.13    www.xjtu.edu.cn     www
  202.117.1.24     ftp.xjtu.edu.cn      ftp

  在/etc/networks 中,存放著網(wǎng)絡(luò)ip地址和網(wǎng)絡(luò)名稱的一一對(duì)應(yīng).它的文件格式和/etc/hosts是類似的
  (3)/etc/resolv.conf 這個(gè)文件是DNS域名解析器的主要配置文件,它的格式十分簡(jiǎn)單,每一行由一個(gè)主關(guān)鍵字組成./etc/resolv.conf的關(guān)鍵字主要有:
  domain   指明缺省的本地域名,
  search   指明了一系列查找主機(jī)名的時(shí)候搜索的域名列表,
  nameserver 指明了在進(jìn)行域名解析時(shí)域名服務(wù)器的ip地址.下面給出一個(gè)范例文件:

  #/etc/resolv.conf
  domain    xjtu.edu.cn
  search    xjtu.edu.cn edu.cn
  nameserver  202.117.0.20
  nameserver  202.117.1.9

  (4)/etc/host.conf 在系統(tǒng)中同時(shí)存在著DNS域名解析和/etc/hosts的主機(jī)表機(jī)制時(shí),由文件/etc/host.conf來(lái)說(shuō)明了解析器的查詢順序.范例文件如下:

  #/etc/host.conf
  order hosts,bind     #解析器查詢順序是文件/etc/hosts,然后是DNS
  multi on         #允許主機(jī)擁有多個(gè)ip地址
  nospoof on        #禁止ip地址欺騙

3. DHCP的配置文件
  /etc/dhcpd.conf是DHCPD的配置文件,我們可以通過(guò)在/etc/dhcpd.conf文件中的配置來(lái)實(shí)現(xiàn)在局域網(wǎng)中動(dòng)態(tài)分配ip地址,一臺(tái)linux主機(jī)設(shè)置為dhcpd服務(wù)器,通過(guò)鑒別網(wǎng)卡的MAC地址來(lái)動(dòng)態(tài)的分配ip地址.范例文件如下:

  option domain-name "chinapub.com";
  use-host-decl-names off;
  subnet 210.27.48.0 netmask 255.255.255.192 {
      filename "/tmp/image";
      host dial_server {
           hardware ethernet 00:02:b3:11:f2:30;
           fixed-address 210.27.48.8;
           filename "/tmp/image";
      }
  }

  在這個(gè)文件中,最主要的是通過(guò)設(shè)置的硬件地址來(lái)鑒別局域網(wǎng)中的主機(jī),并分配給它指定的ip地址,hardware ethernet 00:02:b3:11:f2:30指定要?jiǎng)討B(tài)分配ip的主機(jī)得網(wǎng)卡的MAC地址,fixed-address 210.27.48.8指定分配其ip地址。filename "/tmp/image"是通過(guò)tftp服務(wù),主機(jī)所要得到的影像文件,可以通過(guò)得到的影像文件來(lái)引導(dǎo)主機(jī)啟動(dòng)。

4. 超級(jí)守候進(jìn)程inetd的配置
  在linux系統(tǒng)中有一個(gè)超級(jí)守候進(jìn)程inetd,inetd****由文件/etc/services指定的服務(wù)的端口,inetd根據(jù)網(wǎng)絡(luò)連接請(qǐng)求,調(diào)用相應(yīng)的服務(wù)進(jìn)程來(lái)相應(yīng)請(qǐng)求.在這里有兩個(gè)文件十分重要,/etc/inetd.conf和/etc/services,文件/etc/services定義linu系統(tǒng)中所有服務(wù)的名稱,協(xié)議類型,服務(wù)的端口等等信息,/etc/inetd.conf是inetd的配置文件,由它來(lái)指定那些服務(wù)可以由inetd來(lái)****,以及相應(yīng)的服務(wù)進(jìn)程的調(diào)用命令.首先介紹一下/etc/services文件,/etc/services文件是一個(gè)服務(wù)名和服務(wù)端口對(duì)應(yīng)的數(shù)據(jù)庫(kù)文件,如下面所示:
# /etc/services:
# $Id: services,v 1.4 2000/01/23 21:03:36 notting Exp $
#
# Network services, Internet style
#
# Note that it is presently the policy of IANA to assign a single well-known
# port number for both TCP and UDP; hence, most entries here have two entries
# even if the protocol doesn't support UDP operations.
# Updated from RFC 1700, ``Assigned Numbers'' (October 1994). Not all ports
# are included, only the more common ones.
#名稱    端口/協(xié)議     別名        注釋
tcpmux    1/tcp                # TCP port service multiplexer
echo     7/tcp
echo     7/udp
discard   9/tcp      sink null
discard   9/udp      sink null
systat   11/tcp      users
daytime   13/tcp
daytime   13/udp
netstat   15/tcp
qotd     17/tcp      quote
msp     18/tcp                 # message send protocol
msp     18/udp                 # message send protocol
chargen   19/tcp     ttytst source
chargen   19/udp     ttytst source
ftp-data   20/tcp
ftp     21/tcp
fsp    21/udp      fspd
ssh     22/tcp                 # SSH Remote Login Protocol
ssh    22/udp                 # SSH Remote Login Protocol
telnet   23/tcp
# 24 - private
smtp    25/tcp      mail
# 26 - unassigned
time    37/tcp     timserver
time    37/udp      timserver
rlp     39/udp      resource         # resource location
nameserver 42/tcp      name           # IEN 116
whois    43/tcp      nicname
re-mail-ck  50/tcp                  # Remote Mail Checking Protocol
re-mail-ck 50/udp                   # Remote Mail Checking Protocol
domain    53/tcp     nameserver         # name-domain server
domain   53/udp     nameserver
mtp     57/tcp                   # deprecated
bootps    67/tcp                   # BOOTP server
bootps    67/udp
bootpc    68/tcp                   # BOOTP client
bootpc    68/udp
tftp     69/udp
gopher    70/tcp # Internet Gopher
gopher    70/udp
rje     77/tcp netrjs
finger    79/tcp
www     80/tcp     http             # WorldWideWeb HTTP
www     80/udp                    # HyperText Transfer Protocol
link     87/tcp     ttylink
kerberos   88/tcp     kerberos5 krb5        # Kerberos v5
kerberos   88/udp     kerberos5 krb5        # Kerberos v5
supdup   95/tcp
# 100 - reserved
hostnames  101/tcp     hostname           # usually from sri-nic
iso-tsap  102/tcp     tsap             # part of ISODE.
csnet-ns  105/tcp     cso-ns             # also used by CSO name server
csnet-ns  105/udp     cso-ns
rtelnet   107/tcp                    # Remote Telnet
rtelnet   107/udp
pop2     109/tcp    pop-2 postoffice        # POP version 2
pop2     109/udp    pop-2
pop3     110/tcp    pop-3              # POP version 3
pop3     110/udp    pop-3
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
nntp     119/tcp    readnews untp          # USENET News Transfer Protocol
ntp      123/tcp
ntp      123/udp                   # Network Time Protocol
netbios-ns   137/tcp                   # NETBIOS Name Service
netbios-ns   137/udp
netbios-dgm   138/tcp                   # NETBIOS Datagram Service
netbios-dgm   138/udp
netbios-ssn   139/tcp                   # NETBIOS session service
netbios-ssn   139/udp
imap2      143/tcp   imap               # Interim Mail Access Proto v2
imap2      143/udp   imap

(實(shí)際上,以上僅僅是/etc/services的一部分,限于篇幅沒(méi)有全部寫出)
在這個(gè)文件中,為了安全考慮,我們可以修改一些常用服務(wù)的端口地址,例如我們可以把telnet服務(wù)的端口地址改為52323,www的端口改為8080,ftp端口地址改為2121等等,這樣僅僅需要在應(yīng)用程序中修改相應(yīng)的端口即可.這樣可以提高系統(tǒng)的安全性.
/etc/inetd.conf文件是inetd的配置文件, 首先要了解一下linux服務(wù)器到底要提供哪些服務(wù)。一個(gè)很好的原則是" 禁止所有不需要的服務(wù)",這樣黑客就少了一些攻擊系統(tǒng)的機(jī)會(huì)./etc/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
#          NETD process a SIGHUP signal.
#
# Version:    @(#)/etc/inetd.conf   3.10   05/27/93
#
# Authors:    Original taken from BSD UNIX 4.3/TAHOE.
#         Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
#
# Modified for Debian Linux by Ian A. Murdock <imurdock@shell.portal.com>
#
# Modified for RHS Linux by Marc Ewing <marc@redhat.com>
#
# <service_name> <sock_type> <proto> <flags> <user> <server_path> <args>
#服務(wù)名 socket類型 協(xié)議 動(dòng)作 擁有者 服務(wù)進(jìn)程路徑名 掉用參數(shù)
#nowait 表示在相應(yīng)一個(gè)網(wǎng)絡(luò)連接之后,服務(wù)進(jìn)程在釋放舊的聯(lián)接之前可以接受
#新的連接請(qǐng)求,wait 則表示必須在舊連接清除之后才能接收新的連接.
# Echo, discard, daytime, and chargen are used primarily for testing.
# To re-read this file after changes, just do a 'killall -HUP inetd'
#
#echo  stream  tcp  nowait  root  internal
#echo  dgram   udp  wait   root  internal
#discard    stream  tcp  nowait  root  internal
#discard    dgram   udp  wait   root  internal
#daytime stream  tcp   nowait   root   internal
#daytime dgram  udp   wait    root   internal
#chargen     stream  tcp   nowait  root  internal
#chargen     dgram  udp  wait   root   internal
#time   stream   tcp   nowait   root  internal
#time   dgram   udp   wait   root   internal
#
# These are standard services.
#
ftp   stream   tcp   nowait   root   /usr/sbin/tcpd   in.wuftpd -l -a
telnet stream   tcp   nowait   root   /usr/sbin/tcpd   in.telnetd
#
# Shell, login, exec, comsat and talk are BSD protocols.
#
#shell  stream  tcp  nowait  root   /usr/sbin/tcpd   in.rshd
#login  stream  tcp  nowait  root   /usr/sbin/tcpd   in.rlogind
#exec  stream  tcp  nowait  root   /usr/sbin/tcpd   in.rexecd
#comsat dgram  udp  wait   root   /usr/sbin/tcpd   in.comsat
#talk  dgram  udp  wait   root   /usr/sbin/tcpd   in.talkd
#ntalk  dgram  udp wait   root   /usr/sbin/tcpd   in.ntalkd
#dtalk  stream tcp  waut   nobody  /usr/sbin/tcpd   in.dtalkd
# Pop and imap mail services et al
#
#pop-2 stream tcp nowait root /usr/sbin/tcpd ipop2d
#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
#
# Tftp service is provided primarily for booting. Most sites
# run this only on machines acting as "boot servers." Do not uncomment
# this unless you *need* it.
#
#tftp  dgram  udp  wait  root  /usr/sbin/tcpd  in.tftpd
#bootps dgram  udp  wait  root  /usr/sbin/tcpd  bootpd
# 
# Finger, systat and netstat give out user information which may be
# valuable to potential "system crackers." Many sites choose to disable
# some or all of these services to improve security.
#
#finger stream  tcp   nowait   root   /usr/sbin/tcpd   in.fingerd
#cfinger stream  tcp   nowait   root   /usr/sbin/tcpd   in.cfingerd
#systat stream  tcp   nowait   guest   /usr/sbin/tcpd /bin/ps -auwwx
#netstat stream  tcp   nowait   guest   /usr/sbin/tcpd /bin/netstat  -f inet
#
# Authentication
#
#auth    stream  tcp  nowait  nobody  /usr/sbin/in.identd in.identd -l -e -o
#linuxconf stream   tcp  wait   root   /bin/linuxconf linuxconf -http

  大家看到的這個(gè)文件已經(jīng)修改過(guò)的文件,除了telnet 和ftp服務(wù),其他所有的服務(wù)都被禁止了.在修改了/etc/inetd.conf之后,使用命令kill -HUP (inetd的進(jìn)程號(hào)),使inetd重新讀取配置文件并重新啟動(dòng)即可.

5. ip route的配置
  利用linux,一臺(tái)普通的微機(jī)也可以實(shí)現(xiàn)高性價(jià)比的路由器.首先讓我們了解一下linux的查看路由信息的命令:
  [root@ice /etc]# route -n
  Kernel IP routing table
  Destination    Gateway    Genmask     Flags Metric Ref   Use Iface
  202.112.13.204  0.0.0.0    255.255.255.255 UH  0  0  0     eth0
  202.117.48.43   0.0.0.0    255.255.255.255 UH  0  0  0     eth1
  202.112.13.192  202.112.13.204 255.255.255.192 UG  0  0  0     eth0
  202.112.13.192  0.0.0.0    255.255.255.192 U  0  0  0      eth0
  202.117.48.0   202.117.48.43 255.255.255.0  UG  0  0  0     eth1
  202.117.48.0   0.0.0.0     255.255.255.0  U  0  0  0     eth1
  127.0.0.0    0.0.0.0     255.0.0.0     U  0  0  0     lo
  0.0.0.0     202.117.48.1   0.0.0.0     UG  0  0  0     eth1
  命令netstat -r n 得到輸出結(jié)果和route -n是一樣的.它們操作的都是linux 內(nèi)核的路由表.
  命令cat /proc/net/route的輸出結(jié)果是以十六進(jìn)制表示的路由表.
[root@ice /etc]# cat /proc/net/route
Iface  Destination   Gateway  Flags  RefCnt  Use   Metric Mask
eth0  CC0D70CA     00000000 0005  0   0    0     FFFFFFF
eth1  2B3075CA     00000000 0005  0   0    0     FFFFFFF
eth0  C00D70CA     CC0D70CA 0003  0   0    0     C0FFFFF
eth0  C00D70CA     00000000 0001  0   0    0     C0FFFFF
eth1  003075CA     2B3075CA 0003  0   0    0     00FFFFF
eth1  003075CA     00000000 0001  0   0    0     00FFFFF
lo   0000007F      00000000 0001  0   0    0    000000F
eth1   00000000      013075CA 0003  0  0    0     0000000
  通過(guò)計(jì)算可以知道,下面的這個(gè)路由表(十六進(jìn)制)和前面的路由表(十進(jìn)制)是一致的.
  我們還可以通過(guò)命令route add (del )來(lái)操作路由表,增加和刪除路由信息.
除了上面的靜態(tài)路由,linux還可以通過(guò)routed來(lái)實(shí)現(xiàn)rip協(xié)議的動(dòng)態(tài)路由.我們只需要打開(kāi)linux的路由轉(zhuǎn)發(fā)功能,在/proc/sys/net/ipv4/ip_forward文件中增加一個(gè)字符1.

三.網(wǎng)絡(luò)的安全設(shè)置

  在這一部分,再次強(qiáng)調(diào)一定要修改/etc/inetd.conf,安全的策略是禁止所有不需要的服務(wù).除此之外,還有以下幾個(gè)文件和網(wǎng)絡(luò)安全相關(guān).

  (1)./etc/ftpusers ftp服務(wù)是一個(gè)不太安全的服務(wù),所以/etc/ftpusers限定了不允許通過(guò)ftp訪問(wèn)linux主機(jī)的用戶列表.當(dāng)一個(gè)ftp請(qǐng)求傳送到ftpd,ftpd首先檢查用戶名,如果用戶名在/etc/ftpusers中,則ftpd將不會(huì)允許該用戶繼續(xù)連接.范例文件如下:

# /etc/ftpusers - users not allowed to login via ftp
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody
nadmin

  (2)/etc/securetty 在linux系統(tǒng)中,總共有六個(gè)終端控制臺(tái),我們可以在/etc/securetty中設(shè)置哪個(gè)終端允許root登錄,所有其他沒(méi)有寫入文件中的終端都不允許root登錄.范例文件如下:

# /etc/securetty - tty's on which root is allowed to login
tty1
tty2
tty3
tty4

(3)tcpd的控制登錄文件/etc/hosts.allow和/etc/hosts.deny
  在tcpd服務(wù)進(jìn)程中,通過(guò)在/etc/hosts.allow和/etc/hosts.deny中的訪問(wèn)控制規(guī)則來(lái)控制外部對(duì)linux主機(jī)的訪問(wèn).它們的格式都是
  service-list : hosts-list [ : command]
  服務(wù)進(jìn)程的名稱 : 主機(jī)列表 可選,當(dāng)規(guī)則滿足時(shí)的操作
  在主機(jī)表中可以使用域名或ip地址,ALL表示匹配所有項(xiàng),EXCEPT表示除了某些項(xiàng), PARANOID表示當(dāng)ip地址和域名不匹配時(shí)(域名偽裝)匹配該項(xiàng).
  范例文件如下:

#
# hosts.allow This file describes the names of the hosts which are
# allowed to use the local INET services, as decided
# by the '/usr/sbin/tcpd' server.
#
ALL : 202.112.13.0/255.255.255.0
ftpd: 202.117.13.196
in.telnetd: 202.117.48.33
ALL : 127.0.0.1

  在這個(gè)文件中,網(wǎng)段202.112.13.0/24可以訪問(wèn)linux系統(tǒng)中所有的網(wǎng)絡(luò)服務(wù),主機(jī)202.117.13.196只能訪問(wèn)ftpd服務(wù),主機(jī)202.117.48.33只能訪問(wèn)telnetd服務(wù).本機(jī)自身可以訪問(wèn)所有網(wǎng)絡(luò)服務(wù).
  在/etc/hosts.deny文件中禁止所有其他情況:
  #/etc/hosts.deny
  ALL : DENY : spawn (/usr/bin/finger -lp @%h | /bin/mail -s "Port Denial noted in %d-%h" root)

  在/etc/hosts.allow中,定義了在所有其他情況下,linux所應(yīng)該執(zhí)行的操作.spawn選項(xiàng)允許linux系統(tǒng)在匹配規(guī)則中執(zhí)行指定的shell命令,在我們的例子中,linux系統(tǒng)在發(fā)現(xiàn)無(wú)授權(quán)的訪問(wèn)時(shí),將會(huì)發(fā)送給超級(jí)用戶一封主題是"Port Denial noted in %d-%h"的郵件,在這里,我們先要介紹一下allow和deny文件中的變量擴(kuò)展.  

  (4)/etc/issue和/etc/issue.net
  在我們登錄linux系統(tǒng)中的時(shí)候,我們常??梢钥吹轿覀僱inux系統(tǒng)的版本號(hào)等敏感信息.在如今的網(wǎng)絡(luò)攻擊行為中,許多黑客首先要收集目標(biāo)系統(tǒng)的信息,版本號(hào)等就是十分重要的信息,所以在linux系統(tǒng)中一般要把這些信息隱藏起來(lái)./etc/issue和/etc/issue.net就是存放這些信息的文件.我們可以修改這些文件來(lái)隱藏版本信息.
另外,在每次linux重新啟動(dòng)的時(shí)候,都會(huì)在腳本/etc/rc.d/rc.local中再次覆蓋上面那兩個(gè)文件./etc/rc.d/rc.local文件的范例如下:

# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

if [ -f /etc/redhat-release ]; then
R=$(cat /etc/redhat-release)

arch=$(uname -m)
a="a"
case "_$arch" in
_a*) a="an";;
_i*) a="an";;
esac

NUMPROC=`egrep -c "^cpu[0-9]+" /proc/stat`
if [ "$NUMPROC" -gt "1" ]; then
SMP="$NUMPROC-processor "
if [ "$NUMPROC" = "8" -o "$NUMPROC" = "11" ]; then
a="an"
else
a="a"
fi
fi

# This will overwrite /etc/issue at every boot. So, make any changes you
# want to make to /etc/issue here or you will lose them when you-reboot.
#echo "" > /etc/issue
#echo "$R" >> /etc/issue
# echo "Kernel $(uname -r) on $a $SMP$(uname -m)" >> /etc/issue

cp -f /etc/issue /etc/issue.net
echo >> /etc/issue

  在文件中黑體的部分就是得到系統(tǒng)版本信息的地方.一定要將他們注釋掉.

  (5)其他配置
  在普通微機(jī)中,都可以通過(guò)ctl+alt+del三鍵的組合來(lái)重新啟動(dòng)linux.這樣是十分不安全的,所以要在    /etc/inittab文件中注釋該功能:
  # Trap CTRL-ALT-DELETE
  #ca::ctrlaltdel:/sbin/shutdown -t3 -r now

 

相關(guān)文章

最新評(píng)論