大樹kingmax的隨手筆記

拉哩啦紮一大堆
  • 首頁

Azure 設定 reverse DNS

shtzeng Posted in Research,Tags: azure, azure cli, azure login, azure reverse dns, reverse dns
29 9 月 2016
0

查了網路上的文章
其實不是很詳盡
所以自己來寫一份了 orz

PART I – 安裝 Azure Cli

這部份可以參考官網文章
基本上就是跑下面指令就可以了

sudo npm install azure-cli -g

裝完可以打 azure 指令測試看看

shtzeng@jump [~] [08:36:22] $ azure                                                                                                                                                                                                                                        [8/8]
info:             _    _____   _ ___ ___
info:            /_\  |_  / | | | _ \ __|
info:      _ ___/ _ \__/ /| |_| |   / _|___ _ _
info:    (___  /_/ \_\/___|\___/|_|_\___| _____)
info:       (_______ _ _)         _ ______ _)_ _
info:              (______________ _ )   (___ _ _)
info:
info:    Microsoft Azure: Microsoft's Cloud Platform
info:
info:    Tool version 0.10.5
help:
help:    Display help for a given command
help:      help [options] [command]
help:
help:    Log in to an Azure subscription using Active Directory or a Microsoft account identity.
help:      login [options]
help:
help:    Log out from Azure subscription using Active Directory. Currently, the user can log out only via Microsoft organizational account
help:      logout [options] [username]
help:
help:    Open the portal in a browser
help:      portal [options]
help:
help:    Manages the data collection preference.
help:      telemetry [options]
help:
help:    Commands:
help:      account          Commands to manage your account information and publish settings
help:      acs              Commands to manage your container service.
help:      ad               Commands to display Active Directory objects
help:      appserviceplan   Commands to manage your Azure appserviceplans
help:      availset         Commands to manage your availability sets.
help:      batch            Commands to manage your Batch objects
help:      cdn              Commands to manage Azure Content Delivery Network (CDN)
help:      config           Commands to manage your local settings
help:      datalake         Commands to manage your Data Lake objects
help:      feature          Commands to manage your features
help:      group            Commands to manage your resource groups
help:      hdinsight        Commands to manage HDInsight clusters and jobs
help:      insights         Commands related to monitoring Insights (events, alert rules, autoscale settings, metrics)
help:      iothub           Commands to manage your Azure IoT hubs
help:      keyvault         Commands to manage key vault instances in the Azure Key Vault service
help:      lab              Commands to manage your DevTest Labs
help:      location         Commands to get the available locations
help:      network          Commands to manage network resources
help:      policy           Commands to manage your policies on ARM Resources.
help:      powerbi          Commands to manage your Azure Power BI Embedded Workspace Collections
help:      provider         Commands to manage resource provider registrations
help:      quotas           Command to view your aggregated Azure quotas
help:      rediscache       Commands to manage your Azure Redis Cache(s)
help:      resource         Commands to manage your resources
help:      role             Commands to manage role definitions
help:      servermanagement Commands to manage Azure Server Managment resources
help:      servicefabric    Commands to manage your Azure Service Fabric
help:      storage          Commands to manage your Storage objects
help:      tag              Commands to manage your resource manager tags
help:      usage            Command to view your aggregated Azure usage data
help:      vm               Commands to manage your virtual machines
help:      vmss             Commands to manage your virtual machine scale sets.
help:      vmssvm           Commands to manage your virtual machine scale set vm.
help:      webapp           Commands to manage your Azure webapps
help:
help:    Options:
help:      -h, --help     output usage information
help:      -v, --version  output the application version
help:
help:    Current Mode: arm (Azure Resource Management)
shtzeng@jump [~] [08:36:26] $

建議啟用 TAB 自動完成
 

azure --completion >> ~/azure.completion.sh
echo 'source ~/azure.completion.sh' >> ~/.bash_profile

PART II – 登入 Azure

這部份可以參考官網文章
透過輸入 azure login 會得到一組 token,再到 http://aka.ms/devicelogin 輸入 token 後再輸入帳號密碼,然後跳到一頁說明可以關掉這頁面時,azure cli 工具應該就顯示登入成功了。

shtzeng@jump [~] [02:59:02] $ azure login
info:    Executing command login
|info:    To sign in, use a web browser to open the page https://aka.ms/devicelogin. Enter the code XXXX to authenticate.
-info:    Added subscription AAAA
info:    Added subscription BBBB
info:    Setting subscription "AAAA" as default
+
info:    login command OK
shtzeng@jump [~] [03:19:07] $

這邊可以看到我有兩個 subscription,然後預設是 AAAA。
這時候下 azure vm list 會發現空無一物,因為選錯 subscription 了,要自己切換 subscription。

shtzeng@jump [~] [03:31:04] $ azure vm list
info:    Executing command vm list
+ Getting virtual machines
info:    No VMs found
info:    vm list command OK
shtzeng@jump [~] [03:31:45] $ azure account list
info:    Executing command account list
data:    Name                         Id                                    Current  State
data:    ---------------------------  ------------------------------------  -------  -------
data:    AAAA                         xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx  true     Enabled
data:    BBBB                         yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy  false    Enabled
info:    account list command OK
shtzeng@jump [~] [03:42:07] $ azure account set "BBBB"
info:    Executing command account set
info:    Setting subscription to "BBBB" with id "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy".
info:    Changes saved
info:    account set command OK
shtzeng@jump [~] [03:42:36] $

如此一來就可以查到東西了
 

shtzeng@jump [~] [03:42:45] $ azure vm list                                                                                                                                                                                                                            [236/826]
info:    Executing command vm list
+ Getting virtual machines
data:    ResourceGroupName  Name                              ProvisioningState  PowerState  Location    Size
data:    -----------------  --------------------------------  -----------------  ----------  ----------  -----------
data:    VA                 nat-virginia                      Succeeded          VM running  eastus2     Standard_A1
data:    NL                 nat-netherlands                   Succeeded          VM running  westeurope  Standard_A1
info:    vm list command OK
shtzeng@jump [~] [03:43:35]

PART III – 設定 reverse DNS

這邊就是其他文章沒寫清楚的地方了
可以參考官網文章
我這邊已經有了 Public IP 了,想為它設定反查,首先要查出來該 IP 的名稱

shtzeng@jump [~] [03:49:35] $ azure network public-ip list HK
info:    Executing command network public-ip list
+ Getting the public ip addresses
data:    Name                              Location  Resource group  Provisioning state  Allocation method  IP version  IP Address      Idle timeout, minutes  FQDN
data:    --------------------------------  --------  --------------  ------------------  -----------------  ----------  --------------  ---------------------  -----------------------------------------
data:    ip-vm-1                           eastasia  HK              Succeeded           Static             IPv4        257.257.257.257   4
info:    network public-ip list command OK
shtzeng@jump [~] [03:49:41] $


有了名稱才可以下指令

shtzeng@jump [~] [04:05:56] $ azure network public-ip set -n ip-vm-1 -g HK -f vm-1.xxx.yyy.zzz
info:    Executing command network public-ip set
+ Looking up the public ip "ip-vm-1"
+ Updating public ip address "ip-vm-1"
data:    Id                              : /subscriptions/yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy/resourceGroups/HK/providers/Microsoft.Network/publicIPAddresses/ip-vm-1
data:    Name                            : ip-vm-1
data:    Type                            : Microsoft.Network/publicIPAddresses
data:    Location                        : eastasia
data:    Provisioning state              : Succeeded
data:    Allocation method               : Static
data:    IP version                      : IPv4
data:    Idle timeout in minutes         : 4
data:    IP Address                      : 257.257.257.257
data:    IP configuration id             : /subscriptions/yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy/resourceGroups/HK/providers/Microsoft.Network/networkInterfaces/ip-vm-1234/ipConfigurations/ipconfig1
data:    Domain name label               : ip-vm-1
data:    FQDN                            : ip-vm-1.eastasia.cloudapp.azure.com
info:    network public-ip set command OK
shtzeng@jump [~] [04:06:49] $

這樣就完成 reverse DNS 設定了
以下是說明
-n 這裡指定哪個 IP 做設定,就是 azure network public-ip list HK 列出來的 Name 部分
-g 指定 resource group,我們是縮寫 HK 代表香港機器們
-f 是指設定這個 IP 的反解為何,這裡設定成 vm-1.xxx.yyy.zzz

  • 月曆

    2016 年 9 月
    一 二 三 四 五 六 日
     1234
    567891011
    12131415161718
    19202122232425
    2627282930  
    « 8 月   10 月 »
  • 近期文章

    • OpenVPN with Ubuntu 20.04 LTS
    • ubuntu munin network traffic no data
    • GCP computer engine ubuntu disk size increase
    • Ubuntu 更新 ip 的方法
    • date 轉換時間格式在 ubuntu 及 macOS 的不同
  • 近期迴響

    • 「shtzeng」於〈久久來一篇〉發佈留言
    • 「shtzeng」於〈科科〉發佈留言
    • 「shtzeng」於〈又升級了〉發佈留言
    • 「Petite」於〈又升級了〉發佈留言
    • 「klandor」於〈又升級了〉發佈留言
  • 管理

    • 登入
    • 訂閱網站內容的資訊提供
    • 訂閱留言的資訊提供
    • WordPress.org 台灣繁體中文
Powered By WordPress 6.7.1, Theme(Ink and wash) Design By Arne.