VMware ESXi – 解決 Kali Linux 安裝到硬碟之後無法上網的問題

1. 網路上有 DHCP Server,但無法上網,似乎沒有抓到網路卡
    # ifconfig

2. 但 /etc/network/interface 中有網路卡的設定
     # cat /etc/network/interface

[@more@]3. 檢查一下系統開機抓到的網路卡,發現是 eth0
    # dmesg | grep eth

4. 將 ens192 改成 eth0
    # sed -i ‘s/ens192/eth0/’ /etc/network/interface

5. 重新啟動網路或重新開機,就可以正常抓到網路了!

VMware ESXi – 安裝 macOS Sierra 10.12.4

因為在 ESXi Server 上看到虛擬機器有支援 Mac,所以試裝了一下。
參考網頁:
Create a macOS/OS X VM on VMware ESXi 6.5 & VMware Workstation 12.x | iThinkVirtual™

1. 先找法子找到 unlocker2.09 RC,並上傳到 ESXi Server 的 datastore1 中。

2. 以 ssh 登入 ESXi Server

[@more@]
3. 切換目錄
[root@esxi:~] cd /vmfs/volumes/datastore1/unlocker-master/
[root@esxi:/vmfs/volumes/58b7a487-5cd95750-6e9c-000c290b06b0/unlocker-master] chmod 711 esxi-install.sh
[root@esxi:/vmfs/volumes/58b7a487-5cd95750-6e9c-000c290b06b0/unlocker-master] ./esxi-install.sh
VMware Unlocker 2.0.9
===============================
Copyright: Dave Parsons 2011-16
Installing local.sh
Adding useVmxSandbox
Saving current state in /bootbank
Clock updated.
Time: 03:03:40   Date: 04/10/2017   UTC
Success – please now restart the server!

4. 將在 App Store 下載的 macOS Sierra 10.12.4 dmg

5. 參考下面網址將 dmg 檔轉成  iso 檔
http://www.insanelymac.com/forum/topic/315967-how-to-create-a-bootable-sierra-iso-for-vmware/
路徑要輸入 InstallESD.dmg 所在的完整檔案路徑

6. 上傳到 ISO 檔到 ESXi Server

7. 建立虛擬機器

8. 開機開始安裝

雖然上面寫 12 分鐘,但其實時間蠻長的

終於安裝完成!

9. 安裝 VMware Tools

10. 改變螢幕解析度

cd Downloads/VMware-Fix-resolution/
chmod +x vmware-resolutionSet
./vmware-resolutionSet 1440 900

VMware ESXi – 新增 iSCSI 磁碟機 – VMware vSphere Client

參考網站:
在 VMWare ESXi 上設定連接 iSCSI | WordPress

1. 選擇 主機 / 組態

2. 選擇 儲存裝置介面卡

[@more@]3. 選擇 新增

4. 選擇 新增軟體 iSCSI 介面卡(I)

5. 選擇 確定

6. 可以看到新增的介面卡

7. 按滑鼠右鍵,選擇 內容

8. 選擇 一般 / 設定

9. 輸入 iSCSI 名稱,勾選 已啟用,然後按 確定

10. 選擇 動態探索 / 新增

11. 輸入 iSCSI 伺服器 ,選擇 CHAP(C)

12. 輸入相關資料

13. 選擇 確定

14. 選擇 靜態探索 / 關閉

15. 選擇 是(Y)

16. 新增的 iSCSI 介面

17. 新增 iSCSI 資料存放區,選擇 儲存區

18. 選擇  新增儲存區

19. 新增過程

20. 新增完成

VMware ESXi – 忘了 root 密碼

參考網頁:
Changing a forgotten root password on an ESX/ESXi host (1317898) | VMware KB
How to Reset Forgotten VMware ESXi Root Password with Ubuntu Live CD

如果忘了 ESXi root 密碼

依官方的說法,唯一的方式是重新安裝。

[@more@]解決方式:
1. 找一片 LiveCD,使用 LiveCD 光碟開機

2. 選擇 應用程式 / 系統工具 / MATE 終端機

3. 查看硬碟分割
     $ sudo fdisk -l

檔案在 /dev/sda5

4. 建立掛載目錄
    $ sudo mkdir /mnt/sda5

5. 掛載分割區
    $ sudo mount /dev/sda5 /mnt/sda5

6. 列出檔案
    $ ls /mnt/sda5

7. 複製檔案到使用者目錄
    $ cp /mnt/sda5/state.tgz ~

8. 目錄切換回使用者根目錄
    $ cd ~

9. 解壓縮
    $ tar xvzf state.tgz
    $ tar xvzf local.tgz

10. 修改 etc/shadow
      $ vi etc/shadow

11. 把第一個 : 和第二個 : 之間的字元刪除

12. 刪除原檔
      $ rm -rf local.tgz state.tgz

13. 把 etc 目錄壓縮成 local.tgz
      $ tar czf local.tgz etc

14. 把 local.tgz 壓縮成 state.tgz
      $ tar czf state.tgz local.tgz

15. 刪除原檔
      $ sudo rm -rf /mnt/sda5/state.tgz

16. 複製修改好的檔案回原目錄
      $ sudo cp state.tgz /mnt/sda5

17. 卸載目錄
      $ sudo umount /mnt/sda5

18. 重新啟動電腦

19. 按 F2 進入設定

20. 密碼不用輸入

21. 選擇 Configuration Password,可以看出來目前密碼還未設定

22. 設定新的密碼,要注意的是,這裡的密碼要求比較高,不像在安裝時,設定密碼強度要求比較寬鬆

23. 設定成功!

VMware ESXi – ghettoVCB 還原 ESXi 虛擬機器

參考網站:
ghettoVCB 還原 ESXI Guest OS

1. VM 備份檔的位置

2. 刪除 VM

[@more@]
3. 建立要還原的 VM 虛擬機器清單
[root@esxi:~]  vi /vmfs/volumes/ST500G/vm_to_restore.lst
# DISK_FORMATS
# 1 = zeroedthick  (一次給足全部的硬碟大小,需要時才初使化未使用的空間)
# 2 = 2gbsparse  (將硬碟分割成多個 2G 的硬碟)
# 3 = thin  (隨著使用量而增加硬碟大小,達到設定上限時就不會在增加)
# 4 = eagerzeroedthick  (一次給足全部的硬碟大小,全部初始化可直接使用)
# 格式,以 ; 做分隔
# “VM 備份檔所在的完整路徑;還原後的 VM 要存放的完整路徑;還原時硬碟的格式”

“/vmfs/volumes/SynologyNAS/CentOS 7 Base/CentOS 7 Base-2017-04-05_12-33-10;/vmfs/volumes/ST500G;3”

4. 進行復原
[root@esxi:~] /opt/ghettovcb/bin/ghettoVCB-restore.sh -c /vmfs/volumes/ST500G/vm_to_restore.lst -l /vmfs/volumes/ST500G/ghettoVCB_log/ghettoVCB-restore.$(date +%F)

################## Restoring VM: CentOS 7 Base  #####################
Start time: Wed Apr  5 23:40:28 CST 2017
Restoring VM from: “/vmfs/volumes/SynologyNAS/CentOS 7 Base/CentOS 7 Base-2017-04-05_12-33-10”
Restoring VM to Datastore: “/vmfs/volumes/ST500G” using Disk Format: “thin”
Creating VM directory: “/vmfs/volumes/ST500G/CentOS 7 Base” …
Copying “CentOS 7 Base.vmx” file …
Restoring VM’s VMDK(s) …
Updating VMDK entry in “CentOS 7 Base.vmx” file …
Option –adaptertype is deprecated and hence will be ignored
Destination disk format: VMFS thin-provisioned
Cloning disk ‘/vmfs/volumes/SynologyNAS/CentOS 7 Base/CentOS 7 Base-2017-04-05_12-33-10/CentOS 7 Base_0.vmdk’…
Clone: 100% done.
Registering CentOS 7 Base …
33
End time: Thu Apr  6 00:04:58 CST 2017
################## Completed restore for CentOS 7 Base! #####################

Start time: Wed Apr  5 23:40:28 CST 2017
End   time: Thu Apr  6 00:04:58 CST 2017
Duration  : 24.50 Minutes

—————————————————————————————————————

5. 更多 ghettoVCB-restore.sh 指令用法
[root@esxi:~]  /opt/ghettovcb/bin/ghettoVCB-restore.sh
###############################################################################
#
# ghettoVCB-restore for ESX/ESXi 3.5, 4.x, 5.x & 6.x
# Author: William Lam
# http://www.virtuallyghetto.com/
# Documentation: http://communities.vmware.com/docs/DOC-8760
# Created: 08/18/2009
# Last modified: 2015_04_04_1
#
###############################################################################

Usage: /opt/ghettovcb/bin/ghettoVCB-restore.sh -c [VM_BACKUP_UP_LIST] -l [LOG_FILE] -d [DRYRUN_DEBUG_INFO]

OPTIONS:
   -c     VM backup list
   -l     File ot output logging
   -d     Dryrun/Debug Info [1|2]

(e.g.)

Output will go to stdout
        /opt/ghettovcb/bin/ghettoVCB-restore.sh -c vms_to_restore

Output will log to /tmp/ghettoVCB-restore.log
        /opt/ghettovcb/bin/ghettoVCB-restore.sh -c vms_to_restore -l /tmp/ghettoVCB-restore.log

Dryrun/Debug Info (dryrun only)
        /opt/ghettovcb/bin/ghettoVCB-restore.sh -c vms_to_restore -d 1
        /opt/ghettovcb/bin/ghettoVCB-restore.sh -c vms_to_restore -d 2

VMware ESXi – ghettoVCB 排程備份

1. 備份 /var/spool/cron/crontabs/root/vmfs/volumes/ST500G/crontabsroot
[root@esxi:~] cp /var/spool/cron/crontabs/root /vmfs/volumes/ST500G/crontabsroot

2. 進行修改
[root@esxi:~] cat /vmfs/volumes/ST500G/crontabsroot
#min hour day mon dow command
1    1    *   *   *   /sbin/tmpwatch.py
1    *    *   *   *   /sbin/auto-backup.sh
0    *    *   *   *   /usr/lib/vmware/vmksummary/log-heartbeat.py
*/5  *    *   *   *   /bin/hostd-probe.sh ++group=host/vim/vmvisor/hostd-probe/stats/sh
00   1    *   *   *   localcli storage core device purge
30   1    *   *   *   /opt/ghettovcb/bin/ghettoVCB.sh -g /opt/ghettovcb/ghettoVCB.conf -f /vmfs/volumes/ST500G/ghetto.lst > /dev/null 2>&1[@more@]
3. 建立 /vmfs/volumes/ST500G/crondtab.sh
[root@esxi:~] vi /vmfs/volumes/ST500G/crondtab.sh
#!/bin/sh
#add backup crond shell
/bin/kill $(cat /var/run/crond.pid)
cp /vmfs/volumes/ST500G/crontabsroot /var/spool/cron/crontabs/root
/usr/lib/vmware/busybox/bin/busybox crond

4. 更改檔案權限
[root@esxi:~] chmod 755 /vmfs/volumes/ST500G/crondtab.sh

5. 將 crondtab.sh 加入開機設定檔 /etc/rc.local.d/local.sh
[root@esxi:~] vi /etc/rc.local.d/local.sh
#backup crond
/vmfs/volumes/ST500G/crondtab.sh
# 時區設定
if [ -e /etc/localtime ];then
     rm -rf /etc/localtime
     cp /vmfs/volumes/ST500G/localtime /etc
else
     cp /vmfs/volumes/ST500G/localtime /etc
fi

VMware ESXi – ghettoVCB 備份 ESXi 虛擬機器

參考網站:
ghettoVCB 備份 ESXI Guest OS
ESXi 5.1 / 5.5 定期排程備份線上VM;NFS、sendmail-ghettoVCB | Mr. 沙先生
Backing up VMware ESXi VMs with ghettoVCB – Miscellaneous Knowledge

虛擬機器不用先關機,ghettoVCB.sh 會先為虛擬機器建立快照,然後進行備份,當備份完成之後會刪除快照。

1.下載 ghettoVCB

2. 上傳到 資料存放區

3. 開啟 ESXi 伺服器可安裝非原廠的額外套件
[root@esxi:~] esxcli software acceptance set –level=CommunitySupported
Host acceptance level changed to ‘CommunitySupported’.

4. 進行安裝 ghettoVCB,似乎沒有進行第 3 步驟,也可以進行安裝
[root@esxi:~] esxcli software vib install -v /vmfs/volumes/ST500G/vghetto-ghettoVCB.vib  -f
Installation Result
   Message: Operation finished successfully.
   Reboot Required: false
   VIBs Installed: virtuallyGhetto_bootbank_ghettoVCB_1.0.0-0.0.0
   VIBs Removed:
   VIBs Skipped:

檔案安裝位置
[root@esxi:~] ls -l /opt/ghettovcb/bin/*
-r-xr-xr-x    1 root     root         17555 Jan 11 14:31 /opt/ghettovcb/bin/ghettoVCB-restore.sh
-r-xr-xr-x    1 root     root         65458 Jan 11 14:31 /opt/ghettovcb/bin/ghettoVCB.sh[@more@]
5. 建立 ghettoVCB.conf 設定檔
[root@esxi:~] vi /opt/ghettoVCB/ghettoVCB.conf
# 備份到 SynologyNAS
VM_BACKUP_VOLUME=/vmfs/volumes/SynologyNAS
# 備份虛擬機格式,採用精簡建
DISK_BACKUP_FORMAT=thin
# 定義備份保留的數量
VM_BACKUP_ROTATION_COUNT=3
# 虛擬機器 POWER OFF 時不會要求 snapshottting
POWER_VM_DOWN_BEFORE_BACKUP=0
# 定義沒有安裝 VMware Tools 的虛擬機器是否可以在硬碟 POWER OFF 時啟用
ENABLE_HARD_POWER_OFF=0
# 如果啟用 ENABLE_HARD_POWER_OFF,將強制執行關閉時會侄數運算,時間是 3 分鐘
ITER_TO_WAIT_SHUTDOWN=3
# 設定 POWER DOWN 的時間,等待關閉時,VM 會放棄或忽略特定的 VM 備份。時間是 5 分鐘
POWER_DOWN_TIMEOUT=5
# 不進行壓縮
ENABLE_COMPRESSION=0
# 不啟用 VM 虛擬機器的快照記憶體
VM_SNAPSHOT_MEMORY=0
# 不啟用對停止的 VM 虛擬機器使用快照(需要有安裝 VMware Tools)
VM_SNAPSHOT_QUIESCE=0
ALLOW_VMS_WITH_SNAPSHOTS_TO_BE_BACKEDUP=0
# 開啟 NFS
ENABLE_NON_PERSISTENT_NFS=1
# 執行完畢就 unmount
UNMOUNT_NFS=0
# NFS Server IP
NFS_SERVER=xxx.xxx.xxx.xxx
# NFS 版本
NFS_VERSION=nfs
# NFS Host 掛載目錄
NFS_MOUNT=/volume1/homes/test/Server/esxi
NFS_LOCAL_NAME=SynologyNAS
NFS_VM_BACKUP_DIR=mybackups

6. 建立 log 檔存放目錄
[root@esxi:~] mkdir /vmfs/volumes/ST500G/ghettoVCB_log

7. 修改 /opt/ghettovcb/bin/ghettoVCB.sh
[root@esxi:~] vi /opt/ghettovcb/bin/ghettoVCB.sh
找到
    #if no logfile then provide default logfile in /tmp
    if [[ -z “${LOG_OUTPUT}” ]] ; then
        LOG_OUTPUT=”/tmp/ghettoVCB-$(date +%F_%H-%M-%S)-$$.log”
        echo “Logging output to “${LOG_OUTPUT}” …”
    fi
修改成
    #if no logfile then provide default logfile in /tmp
    if [[ -z “${LOG_OUTPUT}” ]] ; then
        LOG_OUTPUT=”//vmfs/volumes/ST500G/ghettoVCB_log/ghettoVCB-$(date +%F_%H-%M-%S)-$$.log”
        echo “Logging output to “${LOG_OUTPUT}” …”
    fi

8. 列出安裝的虛擬機器
[root@esxi:~] vim-cmd vmsvc/getallvms
Vmid             Name                                            File                                       Guest OS         Version                                                                                                                                                                                                                                                       Annotation                                                                                                                                                                                                                                                   
1      OB2D Linux 2017 1.0         [ST500G] ob2d/ob2d.vmx                                             other26xLinux64Guest   vmx-13                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
2      Custom CentOS 7.x           [ST500G] Custom CentOS 7.x/Custom CentOS 7.x.vmx                   centos7_64Guest        vmx-13                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
21     OpenNMS                     [ST500G] OpenNMS/OpenNMS.vmx                                       centos7_64Guest        vmx-13                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
22     Nginx                       [ST500G] Nginx/Nginx.vmx                                           centos7_64Guest        vmx-13                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
24     Ubuntu 16.04.2              [ST500G] Ubuntu 16.04.2/Ubuntu 16.04.2.vmx                         ubuntu64Guest          vmx-13                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
25     ArchLinux                   [ST500G] ArchLinux/ArchLinux.vmx                                   other26xLinux64Guest   vmx-13                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
26     Windows 10 1607 14393.0     [ST500G] Windows 10 1607 14393.969/Windows 10 1607 14393.969.vmx   windows9_64Guest       vmx-13
31     Photon OS                   [ST500G] Photon OS/Photon OS.vmx                                   other3xLinux64Guest    vmx-13                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
32     CentOS 7 Base               [ST500G] CentOS 7 Base/CentOS 7 Base.vmx                           centos7_64Guest        vmx-13

9. 進行備份
備份 CentOS 7 Base
[root@esxi:~] /opt/ghettovcb/bin/ghettoVCB.sh -g /opt/ghettovcb/ghettoVCB.conf -m “CentOS 7 Base” -l /vmfs/volumes/ST500G/ghettoVCB_log/ghettoVCB-backup.$(date +%F)

備份全部
[root@esxi:~] /opt/ghettovcb/bin/ghettoVCB.sh -g /opt/ghettovcb/ghettoVCB.conf -a -l /vmfs/volumes/ST500G/ghettoVCB_log/ghettoVCB-backup.$(date +%F)

備份清單
[root@esxi:~] cat /vmfs/volumes/ST500G/vm_to_backup.lst
OpenNMS
Nginx
ArchLinux
[root@esxi:~] /opt/ghettovcb/bin/ghettoVCB.sh -g /opt/ghettovcb/ghettoVCB.conf -f /vmfs/volumes/ST500G/vm_to_backup.lst -l /vmfs/volumes/ST500G/ghettoVCB_log/ghettoVCB-backup.$(date +%F)

10. ghettoVCB.sh 指令用法
[root@esxi:~] /opt/ghettovcb/bin/ghettoVCB.sh
###############################################################################
#
# ghettoVCB for ESX/ESXi 3.5, 4.x+, 5.x & 6.x
# Author: William Lam
# http://www.virtuallyghetto.com/
# Documentation: http://communities.vmware.com/docs/DOC-8760
# Created: 11/17/2008
# Last modified: 2016_11_20 Version 1
#
###############################################################################

Usage: ghettoVCB.sh [options]

OPTIONS:
   -a     Backup all VMs on host(備份所有的 VM)
   -f     List of VMs to backup(備份清單中的 VM,一行一個 VM)
   -m     Name of VM to backup (overrides -f)(備份 VM)
   -c     VM configuration directory for VM backups
   -g     Path to global ghettoVCB configuration file(ghettoVCB.conf 設定檔位置)
   -l     File to output logging(log 檔位置)
   -w     ghettoVCB work directory (default: /tmp/ghettoVCB.work)
   -d     Debug level [info|debug|dryrun] (default: info)

(e.g.)

Backup VMs stored in a list
        /opt/ghettovcb/bin/ghettoVCB.sh -f vms_to_backup

Backup a single VM
        /opt/ghettovcb/bin/ghettoVCB.sh -m vm_to_backup

Backup all VMs residing on this host
        /opt/ghettovcb/bin/ghettoVCB.sh -a

Backup all VMs residing on this host except for the VMs in the exclusion list
        /opt/ghettovcb/bin/ghettoVCB.sh -a -e vm_exclusion_list

Backup VMs based on specific configuration located in directory
        /opt/ghettovcb/bin/ghettoVCB.sh -f vms_to_backup -c vm_backup_configs

Backup VMs using global ghettoVCB configuration file
        /opt/ghettovcb/bin/ghettoVCB.sh -f vms_to_backup -g /global/ghettoVCB.conf

Output will log to /tmp/ghettoVCB.log (consider logging to local or remote datastore to persist logs)
        /opt/ghettovcb/bin/ghettoVCB.sh -f vms_to_backup -l /vmfs/volume/local-storage/ghettoVCB.log

Dry run (no backup will take place)
        /opt/ghettovcb/bin/ghettoVCB.sh -f vms_to_backup -d dryrun

VMware ESXi – 利用 Photon OS 虛擬機建立 Docker 環境

參考網站:
用ESXi建Photon OS虛擬機 打造超輕量Docker環境 – 專題報導 – 網管人NetAdmin
Basic Commands for VMware Photon and Docker | Virten.net

1. 執行內建的 Nginx 網站
連上網路下載
-d 以 Daemonized 形式執行
# docker run -d -p 80:80 vmwarecna/nginx
Unable to find image ‘vmwarecna/nginx:latest’ locally
latest: Pulling from vmwarecna/nginx
a3ed95caeb02: Pull complete
b6f2388a20dd: Pull complete
a305e4b888ce: Pull complete
80596a504ef3: Pull complete
99c028eff2a4: Pull complete
a1cee46bc434: Pull complete
9bd9868012b9: Pull complete
6fa7100a2613: Pull complete
Digest: sha256:f73bbae0f31823c06478b1fa5efb4957bc25239802fd5ea94e4442c0a6090d23
Status: Downloaded newer image for vmwarecna/nginx:latest
085923c591c6b63b477d3267e4f42945a02ea8ebf828e030740b4c299f0e6d57[@more@]執行之後,會新增 docker0 網路介面
# ifconfig docker0
docker0   Link encap:Ethernet  HWaddr 02:42:fa:50:60:86
          inet addr:172.17.0.1  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::42:faff:fe50:6086/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:69 errors:0 dropped:0 overruns:0 frame:0
          TX packets:90 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:101690 (101.6 KB)  TX bytes:7392 (7.3 KB)

防火牆部分也會新增規則
# iptables -L DOCKER -n
Chain DOCKER (1 references)
target     prot opt source               destination
ACCEPT     tcp  —  0.0.0.0/0            172.17.0.2           tcp dpt:80

2. 開啟瀏覽器,輸入 Photon OS IP

3. Docker 版本
# docker version
Client:
 Version:      1.11.0
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   4dc5990
 Built:        Wed Apr 13 19:36:04 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.11.0
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   4dc5990
 Built:        Wed Apr 13 19:36:04 2016
 OS/Arch:      linux/amd64

#Download a Docker container (https://registry.hub.docker.com/)
docker pull vmwarecna/nginx

#Display local stored Docker images
docker images

#Start Docker Container
# -d       – Run the container in the background
# -p 80:80 – Publish the container’s port to the host
docker run -d -p 80:80 vmwarecna/nginx

#List running Docker Containers
docker ps

#Display the public-facing port that is NAT-ed to the container
#(Container ID from docker ps command)
docker port 5f6b0e03c6de

#Stop Docker Container
docker stop 5f6b0e03c6de

#Automatically start Docker containers at boot time
#To start a container at boot time the restart policy parameter is used. 
docker run –restart=always -d -p 80:80 vmwarecna/nginx

VMware ESXi – 安裝 Photon OS 虛擬機器

Photon OS 官方網站:https://vmware.github.io/photon/

1. 下載 Photon OS,這裡下載的是 Full ISO

[@more@]2. 先把 ISO 檔上傳到 ESXi Server 資料存放區

3. 建立虛擬機器

4. 進行安裝
    選擇 Install   

  
    選擇 Accept

    選擇 Yes

    選擇安裝的方式,詳細可以參考 用ESXi建Photon OS虛擬機 打造超輕量Docker環境 – 專題報導 – 網管人NetAdmin

    設定主機名稱

    設定 root 密碼

    確認 root 密碼

    按任意鍵重新開機

5. 開機畫面

    登入畫面

    登入完成

6. 進行設定
SSH Server 設定
# cp /etc/ssh/sshd_config /etc/ssh/sshd_config.$(date +%F)
# sed -i ‘s/PermitRootLogin no/PermitRootLogin yes/’ /etc/ssh/sshd_config
# systemctl restart sshd.service

7. 設定網路
# sed -i ‘s/DHCP=yes/DHCP=no/’ /etc/systemd/network/10-dhcp-en.network

# networkctl | grep configured
  2 eth0             ether              routable    configured

設定網路
# vim /etc/systemd/network/10-static-en.network
[Match]
Name=eth0

[Network]
Address=192.168.1.134/24
Gateway=192.168.1.2
Address=2001:288:a229:1::134/64
Gateway=2001:288:a229:1::ffff
DNS=8.8.8.8
DNS=168.95.1.1

Domains=photon.local

# chmod 644 /etc/systemd/network/10-static-en.network

重新啟動網路
# systemctl restart systemd-networkd.service

測試 DNS 查詢是否正常
# ping -c 3 www.ilc.edu.tw
PING www.ilc.edu.tw (140.111.66.96) 56(84) bytes of data.
64 bytes from server96.ilc.edu.tw (140.111.66.96): icmp_seq=1 ttl=126 time=1.06 ms
64 bytes from server96.ilc.edu.tw (140.111.66.96): icmp_seq=2 ttl=126 time=1.16 ms
64 bytes from server96.ilc.edu.tw (140.111.66.96): icmp_seq=3 ttl=126 time=0.983 ms

# ping6 -c 3 www.ilc.edu.tw
PING www.ilc.edu.tw(2001:288:a201::66:96) 56 data bytes
64 bytes from 2001:288:a201::66:96: icmp_seq=1 ttl=126 time=1.67 ms
64 bytes from 2001:288:a201::66:96: icmp_seq=2 ttl=126 time=1.68 ms
64 bytes from 2001:288:a201::66:96: icmp_seq=3 ttl=126 time=1.53 ms

8. 設定防火牆
# vim /etc/systemd/scripts/iptables

iptables -A INPUT -p tcp –dport 22 -j ACCEPT
修改成
iptables -A INPUT -p tcp -s 192.168.1.0/24 –dport 22 -j ACCEPT

# systemctl restart iptables.service
# iptables -L -n
Chain INPUT (policy DROP)
target     prot opt source               destination
ACCEPT     all  —  0.0.0.0/0            0.0.0.0/0
ACCEPT     all  —  0.0.0.0/0            0.0.0.0/0            ctstate RELATED,ESTABLISHED
ACCEPT     tcp  —  192.168.1.0/24      0.0.0.0/0            tcp dpt:22

Chain FORWARD (policy DROP)
target     prot opt source               destination

Chain OUTPUT (policy DROP)
target     prot opt source               destination
ACCEPT     all  —  0.0.0.0/0            0.0.0.0/0

9. 設定時區
# rm -rf /etc/localtime
# ln -s /usr/share/zoneinfo/Asia/Taipei /etc/localtime
# date
Fri Mar 31 17:57:10 CST 2017

10. 設定開機時啟動 docker
# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
# systemctl start docker.service