歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux服務器 >> Linux下的CIPE 服務器配置

Linux下的CIPE 服務器配置

日期:2017/3/2 16:53:35   编辑:Linux服務器
把位於 /usr/share/doc/cipe-version/samples/ 的配置文件范例復制到 /etc/cipe/ 中(這裡的 version 是安裝在你的系統上的 CIPE 版本)。復制完畢後,你將需要編輯 /etc/cipe/options.cipcbx(x 是從0開始的遞增數字,為那些想要在 CIPE 服務器上不止有一個 CIPE 連接的客戶提供)文件來包括你的 LAN 子網地址和可公共選路的防火牆 IP 地址。以下是包括在紅帽企業 Linux CIPE RPM 中的 options 文件范例。在這個例子中,它被重命名為 options.cipbcb0:
  
  # Surprise, this file allows comments (but only on a line by themselves)
  # This is probably the minimal set of options that has to be set
  # Without a "device" line, the device is picked dynamically
  
  # the peer's IP address
  ptpaddr 6.5.4.3
  
  # our CIPE device's IP address
  ipaddr 6.7.8.9
  
  # my UDP address. Note: if you set port 0 here, the system will pick
  # one and tell it to you via the ip-up script. Same holds for IP 0.0.0.0.
  me bigred.inka.de:6789
  
  # ...and the UDP address we connect to. Of course no wildcards here.
  peer blackforest.inka.de:6543
  
  # The static key. Keep this file secret!
  # The key is 128 bits in hexadecimal notation.
  key xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  
  ptpaddr 是遠程 LAN 的 CIPE 地址。ipaddr 是工作站的 CIPE IP 地址。me 地址是客戶的可公共選路的 IP 地址,它通過互聯網發送 UDP 分組。peer 是 CIPE 服務器的可公共選路的 IP 地址。注意,客戶工作站的 IP 地址是 0.0.0.0,因為它使用動態連接。CIPE 客戶將會處理到 CIPE 服務器的連接。key 字段(用 x 代表;你的鑰匙應該是密鑰)是共享靜態鑰匙。這個鑰匙在兩個對端上必須是相同的,否則連接就不能成立。關於如何為你的 CIPE 機器生成共享靜態鑰匙,請參閱第 6.8 節。
  
  這是客戶工作站將會使用的被編輯過的 /etc/cipe/options.cipcb0:
  
  ptpaddr 10.0.1.2
  ipaddr 10.0.1.1
  me 0.0.0.0
  peer LAN.EXAMPLE.COM:6969
  key 123456ourlittlesecret7890shhhh
  
  這是 CIPE 服務器的 /etc/cipe/options.cipcb0 文件:
  
  ptpaddr 10.0.1.1
  ipaddr 10.0.1.2
  me LAN.EXAMPLE.COM:6969
  peer 0.0.0.0
  key 123456ourlittlesecret7890shhhh
  配置客戶的 CIPE
  
  成功地配置了 CIPE 服務器並測試了它的功能後,你現在就可以在客戶機器上使用這種連接了。
  
  CIPE 客戶應該能夠自動地連接和斷開 CIPE 連接。因此,CIPE 包含內建的機制來為個別使用自定設置。例如,遠程職員可以通過鍵入以下命令來連接到 LAN 上的 CIPE 設備:
  
  /sbin/ifup cipcb0
  
  設備應該自動出現;防火牆規則和選路信息也應該和連接一起配置。遠程職員應該能夠使用以下命令來終止連接:
  
  /sbin/ifdown cipcb0
  
  配置客戶需要創建在設備被載入後需運行的腳本。服務配置本身可以通過用戶創建的文件 /etc/sysconfig/network-scripts/ifcfg-cipcb0 來本地配置。這個文件中包含一些參數,如判定 CIPE 連接是否在引導時發生的參數;代表 CIPE 設備名稱的參數等。以下是一個連接到 CIPE 服務器的遠程客戶的 ifcfg-cipcb0 文件:
  
  DEVICE=cipcb0
  ONBOOT=yes
  BOOTPROTO=none
  USERCTL=no
  
  # This is the device for which we add a host route to our CIPE peer through.
  # You may hard code this, but if left blank, we will try to guess from
  # the routing table in the /etc/cipe/ip-up.local file.
  PEERROUTEDEV=
  
  # We need to use internal DNS when connected via cipe.
  DNS=192.168.1.254
  
  CIPE 設備的名稱是 cipcb0。CIPE 設備將會在引導時間被載入(通過 ONBOOT 字段配置),而且將不會使用一種引導協議(如 DHCP)來接收該設備的 IP 地址。PEERROUTEDEV 字段決定連接到客戶的 CIPE 服務器設備名稱。如果這個字段中沒有指定任何設備,在設備被載入後就會為它決定一個。
  
  如果你的內部網絡是在防火牆背後,你需要設置規則來允許客戶機器上的 CIPE 接口發送和接收 UDP 分組。關於為紅帽企業 Linux 配置防火牆的信息請參閱第7章 。我們這個配置例子中使用了 iptables 規則。
  
  注記
  
  
  客戶應該這樣配置,因此所有被本地化的參數都被放在一個用戶創建的叫做/etc/cipe/ip-up.local 的文件中。CIPE 會話被關閉後,應該使用 /etc/cipe/ip-down.local 來還原本地參數。
  
  客戶機器上的防火牆應該被配置接受 CIPE UDP 封裝分組。規則的差距可能會很大,但是對 UDP 分組的基本接受對於 CIPE 連接來說卻是必需的。以下的 iptables 規則允許連接到 LAN 上的遠程客戶機器進行 UDP CIPE 傳輸;最後一條規則添加了 IP 偽裝來允許遠程客戶與 LAN 和互聯網通信。
  
  /sbin/modprobe iptables
  /sbin/service iptables stop
  /sbin/iptables -P INPUT DROP
  /sbin/iptables -F INPUT
  /sbin/iptables -A INPUT -j ACCEPT -p udp -s 10.0.1.1
  /sbin/iptables -A INPUT -j ACCEPT -i cipcb0
  /sbin/iptables -A INPUT -j ACCEPT -i lo
  /sbin/iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE
  
  你必須還在客戶機器上添加用來像訪問本地網絡一樣訪問 CIPE 連接背後的節點的選路規則。這可以通過運行 route 命令來完成。在我們的例子中,客戶工作站需要添加以下網絡路線:
  
  route add -net 192.168.1.0 netmask 255.255.255.0 gw 10.0.1.2
  
  以下顯示了用於客戶工作站的最終 /etc/cipe/ip-up.local 腳本:
  
  #!/bin/bash -v
  if [ -f /etc/sysconfig/network-scripts/ifcfg-{GetProperty(Content)} ] ; then
  . /etc/sysconfig/network-scripts/ifcfg-{GetProperty(Content)}
  else
  cat eth0:lan.example.com | eth1:192.168.1.1| cipcb0:10.0.1.1----->eth0:remote.example.net|cipcd0:10.0.1.2'

Copyright © Linux教程網 All Rights Reserved