• 產品與解決方案
  • 行業解決方案
  • 服務
  • 支持
  • 合作夥伴
  • BOB登陆 人才研學中心
  • 關於我們

H3C VSR1000虛擬路由器典型配置舉例-6W100

目錄

36-H3C VSR1000虛擬路由器Tcl腳本典型配置舉例

本章節下載 36-H3C VSR1000虛擬路由器Tcl腳本典型配置舉例  (134.56 KB)

36-H3C VSR1000虛擬路由器Tcl腳本典型配置舉例

H3C VSR1000虛擬路由器Tcl腳本典型配置舉例

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

H3C_彩色.emf

 



1  簡介

本文檔介紹VSR1000虛擬路由器使用Tcl腳本語言的典型配置舉例。

2  配置前提

本文檔不嚴格與具體軟件版本對應,如果使用過程中與產品實際情況有差異,請參考相關產品手冊,或以設備實際情況為準。

本文檔中的配置均是在實驗室環境下進行的配置和驗證,配置前設備的所有參數均采用出廠時的缺省配置。如果您已經對設備進行了配置,為了保證配置效果,請確認現有配置和以下舉例中的配置不衝突。

本文檔假設您已了解Tcl腳本語言的特性。

3  使用Tcl腳本的For語句批量配置子接口地址配置舉例

3.1  組網需求

圖1所示,路由器Router連接配置主機,現要求:使用For語句的Tcl腳本,為接口GigabitEthernet2/0創建子接口GigabitEthernet2/0.1~GigabitEthernet2/0.4,並配置相應的IP地址和VLAN終結。

圖1 配置組網圖

 

3.2  使用版本

本舉例是在E0301版本上進行配置和驗證的。

3.3  配置注意事項

·     輸入Tcl腳本命令,不支持輸入?鍵獲得在線幫助和Tab鍵補全功能。

·     已經成功執行的Tcl腳本命令不會記錄在曆史命令緩衝區中,不能用上下光標鍵對命令進行調用。

·     在循環體執行過程中,任何操作命令無效。

3.4  配置步驟

# 進入Tcl配置視圖。

<Router> Tclsh

# 進入係統視圖。

<Router-Tcl> system-view

# 編寫For語句的Tcl腳本。

[Router-Tcl] for {set i 1} {$i <= 4} {incr i 1} {

set j [expr $i+99]

# 配置子接口GigabitEthernet2/0.1地址為1.1.1.1,GigabitEthernet2/0.2~GigabitEthernet2/0.4的子接口地址依次按序遞增。

interface gigabitethernet 2/0.$i

ip add $i.1.1.1 24

# 配置子接口GigabitEthernet2/0.1終結的VLAN ID為VLAN 100,GigabitEthernet2/0.2~GigabitEthernet2/0.4終結的VLAN ID均依次按序遞增。

vlan-type dot1q vid $j}

[Router-Tcl-GigabitEthernet2/0.4] quit

3.5  驗證配置

# 顯示接口的概要信息,有對應的子接口生成,並配置相應的IP地址。

[Router] display interface brief

Brief information on interface(s) under route mode:

Link: ADM - administratively down; Stby - standby

Protocol: (s) - spoofing

Interface            Link Protocol Main IP         Description

Aux0                 UP   --       --

GE1/0                UP   UP       192.168.100.66

GE2/0                UP   UP       --

GE2/0.1              UP   UP       1.1.1.1

GE2/0.2              UP   UP       2.1.1.1

GE2/0.3              UP   UP       3.1.1.1

GE2/0.4              UP   UP       4.1.1.1

GE3/0                UP   UP       --

InLoop0              UP   UP(s)    --

NULL0                UP   UP(s)    --

REG0                 DOWN --       --

# 通過display current-configuration interface命令,以GigabitEthernet2/0.1為例,觀察到VLAN終結配置成功。

[Router] display current-configuration interface gigabitethernet 2/0.1

#

interface GigabitEthernet2/0.1

 ip address 1.1.1.1 255.255.255.0

 vlan-type dot1q vid 100

#

return

3.6  配置文件

Router的For語句:

for {set i 1} {$i <= 4} {incr i 1} {

set j [expr $i+99]

interface gigabitethernet 2/0.$i

ip add $i.1.1.1 24

vlan-type dot1q vid $j}

4  使用Tcl腳本的While語句批量配置子接口地址配置舉例

4.1  組網需求

圖2所示,路由器Router連接配置主機,現要求:編寫一個使用While語句的Tcl腳本,為接口GigabitEthernet2/0創建子接口GigabitEthernet2/0.1~GigabitEthernet2/0.4,並配置相應的IP地址和VLAN終結。

圖2 配置組網圖

 

4.2  使用版本

本舉例是在E0301版本上進行配置和驗證的。

4.3  配置注意事項

·     While語句必須在語句前預定義變量值。

·     輸入Tcl腳本命令,不支持輸入?鍵獲得在線幫助和Tab鍵補全功能。

·     已經成功執行的Tcl腳本命令不會記錄在曆史命令緩衝區中,不能用上下光標鍵對命令進行調用。

·     在循環體執行過程中,任何操作命令無效。

4.4  配置步驟

# 進入Tcl配置視圖。

<Router> Tclsh

# 進入係統視圖。

<Router-Tcl> system-view

# 編寫While語句的Tcl腳本,預定義變量i的值為1。

[Router-Tcl] set i 1

1

[Router-Tcl] while {$i <= 4} {

set j [expr $i+99]

# 配置子接口GigabitEthernet2/0.1地址為1.1.1.1,GigabitEthernet2/0.2~GigabitEthernet2/0.4的子接口地址依次按序遞增。

interface gigabitethernet 2/0.$i

ip address $i.1.1.1 24

# 配置子接口GigabitEthernet2/0.1終結的VLAN ID為100,GigabitEthernet2/0.2~GigabitEthernet2/0.4終結的VLAN ID均依次按序遞增。

vlan-type dot1q vid $j

incr i}

[Router-Tcl-GigabitEthernet2/0.4] quit

4.5  驗證配置

# 顯示接口的概要信息,有對應的子接口生成,並配置相應的IP地址。

[Router] display interface brief

Brief information on interface(s) under route mode:

Link: ADM - administratively down; Stby - standby

Protocol: (s) - spoofing

Interface            Link Protocol Main IP         Description

GE1/0                UP   UP       192.168.100.66

GE2/0                UP   UP       --

GE2/0.1              UP   UP       1.1.1.1

GE2/0.2              UP   UP       2.1.1.1

GE2/0.3              UP   UP       3.1.1.1

GE2/0.4              UP   UP       4.1.1.1

GE3/0                UP   UP       --

InLoop0              UP   UP(s)    --

NULL0                UP   UP(s)    --

REG0                 DOWN --       --

# 通過display current-configuration interface命令,以GigabitEthernet2/0.1為例,觀察到VLAN終結配置成功。

[Router] display current-configuration interface gigabitethernet 2/0.1

#

interface GigabitEthernet2/0.1

 ip address 1.1.1.1 255.255.255.0

 vlan-type dot1q vid 100

#

return

4.6  配置文件

Router的While語句:

set i 1

while {$i <= 4} {

set j [expr $i+99]

interface gigabitethernet 2/0.$i

ip address $i.1.1.1 24

vlan-type dot1q vid $j

incr i}

5  相關資料

·     《H3C VSR1000虛擬路由器配置指導》中的“基礎配置指導”

·     《H3C VSR1000虛擬路由器命令參考》中的“基礎配置命令參考”

不同款型規格的資料略有差異, 詳細信息請向具體銷售和400谘詢。H3C保留在沒有任何通知或提示的情況下對資料內容進行修改的權利!

BOB登陆
官網
聯係我們