異世界


2013年11月16日 星期六

手動重建 網卡

虛擬機上有四張NICs Adapter,在 ESXi 上移植OS 後,發生網卡驅動不支持現象。

看不懂又找不到問題,最後決定手動重建。

1.  到 CentOS 作業系統中刪除檔案 70-persistent-net.rules

     rm -rf  /etc/udev/rules.d/70-persistent-net.rules 

2. 修改 /etc/sysconfig/network-scripts 下的四個檔案 ifcfg-eth0、ifcfg-eth1、ifcfg-eth2、ifcfg-eth3 (remove MAC address)

    vi /etc/sysconfig/network-scripts/ifcfg-eth0

   1: DEVICE=eth0
   2: TYPE=Ethernet
   3: UUID=8c1b4007-428f-4fb3-89df-8a699b4b8947
   4: ONBOOT=yes
   5: NM_CONTROLLED=yes
   6: BOOTPROTO=none
   7: DEFROUTE=yes
   8: IPV4_FAILURE_FATAL=yes
   9: IPV6INIT=no
  10: IPADDR=192.168.0.100
  11: PREFIX=24
  12: LAST_CONNECT=1383997776

 




3. 關閉該OS


    sync
    sync
    init 0


           4. 重建VM 的 Network Adapter,給予正確的Adapter Type (E1000)
           image



5. 開啟  OS,並檢視 Network Adapter 是否正常



# 使用 ifconfig ,經過濾器,檢出包含 "eth" 的Line
ifconfig |grep eth 
# 使用 ifconfig ,經過濾器,檢出包含 "inet" 的Line
ifconfig |grep inet 
# 檢視 eth0~3 狀態
mii-tool eth0 eth1 eth2 eth3
  eth0: negotiated 100baseTx-FD, link ok
eth1: negotiated 100baseTx-FD, link ok
eth2: negotiated 100baseTx-FD, link ok
eth3: negotiated 100baseTx-FD, link ok
 6. 重啟網路
/etc/init.d/network restart
  

2013年11月14日 星期四

CentOS 實作 2 WAN

q我的 Server 背板位置
image
  • 將實際網路位置、MAC與CentOS 作業系統的NICs 名稱完成對應(以下是在ESXi上實現,故多了一層對應)
    vmnic
    MAC
    Func
    Name
    Network
    Adapter
    MAC
    (vmOS)
    eth
    name
    IP-Address
    說明

    0
    xx:40
    M1
    1
    78
    eth0
    10.20.13.101/24
    GW:10.20.13.1
    接WAN1的Router LAN

    1
    xx:41
    M2
    2
    82
    eth1
    10.21.13.101/24
    GW:10.21.13.1
    接WAN2的Router LAN

    2
    xx:67
    MC
    3
    8c
    eth2
    10.30.13.100/24


    3
    xx:98
    ST
    4
    96
    eth3
    10.40.13.101/24


    4
    xx:99
    x
    x
    x
    x
    x



  • 永久停用 NetworkManager
chkconfig NetworkManager offservice NetworkManager stop

# 重啟網路 #
service network restart
image
  • 永久關閉防火牆
chkconfig –level 35 iptables off/etc/init.d/iptables stopiptables –P INPUT DROP
  •  ##Create 2 route table, only fist time need execute bellow command: echo “wan1” >> /etc/iproute2/rt_tables
    echo “wan2” >> /etc/iproute2/rt_tables

    PS: 檔案 /etc/iproute2/rt_tables 將增加兩行如下圖
    image
  • 修改 檔案 /etc/rc.d/rc.local 讓開機時自動建立雙WAN

    修改前:
    image
    加入指令:
       1: ##Add routing ip address write to routing table. 

       2: ##Add route table of wan2

       3: ip route add 10.21.13.0/24 dev eth1 src 10.21.13.101 table wan2

       4: ip route add 127.0.0.1/8 dev lo scope link table wan2

       5: ip route add default via 10.21.13.1 dev eth1 table wan2

       6:  

       7: ##Add route table of wan1

       8: ip route add 10.20.13.0/24 dev eth0 src 10.20.13.101 table wan1

       9: ip route add 127.0.0.1/8 dev lo scope link table wan1

      10: ip route add default via 10.20.13.1 dev eth0 table wan1

      11:  

      12: ##Add rule to route table wan1 and wan2:

      13: ip rule add from 10.21.13.101 table wan2

      14: ip rule add from 10.20.13.101 table wan1

      15:  

      16: ##Replace default route ip address.

      17: ip route add default scope global nexthop via 10.20.13.1 dev eth0 weight 1 nexthop via 10.21.13.1 dev eth1 weight 1

      18:  






  • 設定DNS

  • ping google.com.tw

    無回應時,代表沒設定DNS

    互動試設定指令 :  system-config-network

    參考文章 : CentOS 基礎設定(上)







2013年11月9日 星期六

ESXi 虛擬機

  1. ESXi  虛擬機 VMware vSphere Hypervisor (ESXi) : 下載點 : https://my.vmware.com/web/vmware/downloads 介紹文章: ESXi簡易介紹。【備忘】ESXi Mapping Physical Disk to vmdk http://portable.easylife.tw/1807

  2. vSphere Client: 下載點 :https://my.vmware.com/web/vmware/downloads
    介紹文章: 如何透過vSphere Client遠端操控藏身在區域網路內的ESX主機?

  3. Trilead VM Explorer :
           但是這套軟體還是沒辦法跟 VMWare 的vCenter 比較, 除了可以控制基本的開關機外, 主要是看上他可以很快速做檔案控制 ESXi Server 上的DataStore, 以及整台 VM 的備份或 Clone.更重要的是他是免費的版本。
    下載點 : www.trilead.com/Download/ 
    介紹文章: VMX Trilead VM Explorer

    問題:  a) 備份的VM 還原後,NICs錯亂問題的解決 How do you automatically detect a new network card in CentOS 6 / RedHat?

    About how to remove old NIC setting of CentOS 6.4.

     

    1.    Go into /etc/udev/rules.d and delete the 70-persistent-net.rules file.

    2.    edit /etc/sysconfig/network-scripts/ifcfg-eth0 remove MAC address then save configurations.

    3.    Reboot system.  Done

     

     



    b) VMWare ESXi 開機,自動啟動 VM   
        http://net1981.pixnet.net/blog/post/44617301

    imageimage




  4. 一個簡單的WEB 管理程式
    下載點: https://github.com/weikinhuang/esxi-simple-web
    簡介文: http://www.tuicool.com/articles/mINNz2
       a) RVTools 3.1
       b)
    LIDlabs OPS1 1.2
      
    c) Veeam Monitor 5.0 Free Edition   d) SolarWinds VM Monitor 1.1 



  5. 用免費工具管理vSphere/ESXi : http://www.ithome.com.tw/itadm/article.php?c=68723

    簡易安裝使用,請參考 : [PDF]VMware vSphere Hypervisor 5 建置與管理研習講義福陽國小沈....

    ** 在 Maintenance Mode 中,無法 進入 Edit Setting… 選項,須離開 該模式
    image  image




  6.  

2013年11月5日 星期二

Linux 常用指令 備忘

watch  定時執行後面指令,預設2Sec
watch -d netstat -i 定時顯示網路流量, -d 與上次執行不同的地方反白出來
ifconfig 網路介面
tcpdump 文字介面封包擷取器
tail 最大的用處就是來看log檔
   
   
   
   
   
   
   

linux指令大全(完整篇)

永遠的UNIX

別人的學習筆記 : Anote hcsLinux System 與與國國際際證證照

 

 

文字介面封包擷取器: tcpdump

[root@www ~]# tcpdump [-AennqX] [-i 介面] [-w 儲存檔名] [-c 次數] \
[-r 檔案] [所欲擷取的封包資料格式]
選項與參數:
-A :封包的內容以 ASCII 顯示,通常用來捉取 WWW 的網頁封包資料。
-e :使用資料連接層 (OSI 第二層) 的 MAC 封包資料來顯示;
-nn:直接以 IP 及 port number 顯示,而非主機名與服務名稱
-q :僅列出較為簡短的封包資訊,每一行的內容比較精簡
-X :可以列出十六進位 (hex) 以及 ASCII 的封包內容,對於監聽封包內容很有用
-i :後面接要『監聽』的網路介面,例如 eth0, lo, ppp0 等等的介面;
-w :如果你要將監聽所得的封包資料儲存下來,用這個參數就對了!後面接檔名
-r :從後面接的檔案將封包資料讀出來。那個『檔案』是已經存在的檔案,
並且這個『檔案』是由 -w 所製作出來的。
-c :監聽的封包數,如果沒有這個參數, tcpdump 會持續不斷的監聽,
直到使用者輸入 [ctrl]-c 為止。
所欲擷取的封包資料格式:我們可以專門針對某些通訊協定或者是 IP 來源進行封包擷取,
那就可以簡化輸出的結果,並取得最有用的資訊。常見的表示方法有:
'host foo', 'host 127.0.0.1' :針對單部主機來進行封包擷取
'net 192.168' :針對某個網域來進行封包的擷取;
'src host 127.0.0.1' 'dst net 192.168':同時加上來源(src)或目標(dst)限制
'tcp port 21':還可以針對通訊協定偵測,如 tcp, udp, arp, ether 等
還可以利用 and 與 or 來進行封包資料的整合顯示呢!

# 範例一:以 IP 與 port number 捉下 eth0 這個網路卡上的封包,持續 3 秒
[root@www ~]# tcpdump -i eth0 -nn
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
17:01:47.360523 IP 192.168.1.101.1937 > 192.168.1.100.22: Flags [.], ack 196, win 65219,
17:01:47.362139 IP 192.168.1.100.22 > 192.168.1.101.1937: Flags [P.], seq 196:472, ack 1,
17:01:47.363201 IP 192.168.1.100.22 > 192.168.1.101.1937: Flags [P.], seq 472:636, ack 1,
17:01:47.363328 IP 192.168.1.101.1937 > 192.168.1.100.22: Flags [.], ack 636, win 64779,
<==按下 [ctrl]-c 之後結束
6680 packets captured <==捉下來的封包數量
14250 packets received by filter <==由過濾所得的總封包數量
7512 packets dropped by kernel <==被核心所丟棄的封包

2013年11月2日 星期六

Centos : webmin for Route Table

  1. webmin : http://www.webmin.com/rpm.html
  2. 安裝 webmin:
    於 CenOs 安裝,使用 RPM  ( Installing the RPM ):
    完成後預設的 URL http://localhost:10000
    wget http://prdownloads.sourceforge.net/webadmin/webmin-1.660-1.noarch.rpm
    rpm -U webmin-1.660-1.noarch.rpm
     

  3. 若未安裝Apache 最簡單的方式=> 安裝LAMP  、 安裝 LAMP - 在 CentOS 6.3

    // 安裝
    yum  -y  install  httpd  php  php-mysql  mysql  mysql-server
     
    // 啟動 MySQL
    sudo chkconfig mysqld on
    /etc/init.d/mysqld start 
     
    // 啟動 Apache
    chkconfig httpd on
    /etc/init.d/httpd start
     
     
     

  4. 開啟 webmin (進入後,記得先備份)
    image 
  5. webmin 教學網
    吳老師的實戰世界 =>  Linux 最強圖像管理套件---- Webmin
    ohyeah's blog => http://www.ohyeah.tw/?p=351
  6. 很多選項會用到 re-pppoe : 安裝 RE-PPPOE => # yum install re-pppoe

  7. ???? 下一步要學會 Route Table 如何運作 ........?????



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


A) 實做多條 WAN 線路 NAT 主機 
B) 網中人寫的『頻寬負載平衡』:http://www.study-area.org/tips/multipath.htm