歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Unix知識 >> 關於Unix >> RedHatLinux網絡和基本服務的配置

RedHatLinux網絡和基本服務的配置

日期:2017/3/6 15:47:12   编辑:關於Unix
(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)要啟動的服務;下面介紹如何
  (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/ftpaclearcase/" target="_blank" >ccess 用#將以下兩行注釋掉,
  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

Copyright © Linux教程網 All Rights Reserved