顯示具有 switch 標籤的文章。 顯示所有文章
顯示具有 switch 標籤的文章。 顯示所有文章

星期四, 12月 05, 2024

HPE Aruba Switch 6100 排程設定

 HPE Aruba Switch 6100 24g CL4可以在console模式下設定job排程,但firmware要先更新到PL.10.10以上的版本,如果要下載新版的firmware,需要先到
https://networkingsupport.hpe.com/
註冊會員,才能下載









下載新的firmware後,登入交換器的web-UI後到System->Firmware Update,上傳新的firmware,上傳時選擇要取代Primary image 或Secondary image,然後按「上傳」,上傳完畢後,選擇【Reboot】,系統重啟前會提醒將會以目前的設定檔running config重開機

以下指令請參考原廠的command line
https://www.arubanetworks.com/techdocs/AOS-CX/10.11/HTML/cli_832x/Content/fir-int3.htm

以及AOS-CX 10.11 Job Scheduler Guide
https://www.arubanetworks.com/techdocs/AOS-CX/10.11/PDF/job_scheduler.pdf

重開機後,登入console


switch# config 

switch(config)# job ? =〉列出job 指令的用法

  JOB_NAME  Specify a name for the job. The maximum length is 64 characters

            consisting of alphanumeric and '_' characters only.

會列出job指令的相關參數

若有列出,代表此版本的firmware有支援job scheduler

##############################################

以下開始建立一個名為POE_PORT1_down的job(工作),此job要設定port 1的poe不供電

switch(config)# job  POE_PORT1_down     =〉建立一個排程名稱(自訂)

switch(config-job-PTog1)# desc port 1/1/1 poe funtion down =〉建立一個此排程的描述   

switch(config-job-PTog1)# 10 cli config  =〉進入指令設定模式

switch(config-job-PTog1)# 20 cli interface 1/1/1  =〉進入第1埠,如果指定連續Port例如17-20port,則下interface 1/1/17-1/1/20

switch(config-job-PTog1)# 30 cli no power-over-ethernet   =〉設定poe down

switch(config-job-PTog1)# 40 cli end =〉跳脫設定模式

switch(config-job-PTog1)# exit

以上根據AOS-CX 10.11 Job Scheduler Guide做出的一個job,上述命令的數字10,20,30,40,我的理解是可以視為命令的執行列或順序,如果你30 cli no power-over-ethernet,這個設錯了,就重新輸入30 cli [新的指令],即可取代原本位於30的指令內容

根據手冊,job有一些限制:

  • 每個job最多20個指令,可下show capacities job查看
  • job必須在5分鐘內完整執行,否則5分鐘後,會被強制停止
  • 如果job的指令下達前需要先等待某個時間再執行,則下delay,  
    例如:
    • switch(config)# job PTog1
    • switch(config-job-PTog1)# desc Toggle port 1/1/1
    • switch(config-job-PTog1)# 10 cli config
    • switch(config-job-PTog1)# 20 cli interface 1/1/1
    • switch(config-job-PTog1)# 30 cli shutdown
    • switch(config-job-PTog1)# 40 delay 10 cli no shutdown
    • switch(config-job-PTog1)# 50 cli end
    • switch(config-job-PTog1)# exit
    • switch(config)#

switch(config)# show POE_PORT1_down  =〉show出job POE_PORT1_down的內容

如果要把POE_PORT1_down這個job刪除

switch(config)# no job POE_PORT1_down  

再執行show job看是否這個job還存在

###########################################################

接著定義一段POE_PORT1_down執行的時間

switch(config)# schedule POE_PORT1_down_worktime =>名稱自訂

switch(config-schedule-POE_PORT1_down_worktime)# desc 22:20 everyday

switch(config-schedule-POE_PORT1_down_worktime)# 10 job POE_PORT1_down =〉此schedule時間是由哪個job執行,必須在job中有定義的工作名稱,我們在前面是以POE_PORT1_down為例

switch(config-schedule-POE_PORT1_down_worktime)# trigger on 22:20 daily count 7 start 2024-12-05 =〉trigger即代表要執行的時間,時間的定義及使用方式如下方所述

switch(config-schedule-POE_PORT1_down_worktime)# exit  =〉離開schedule定義模式

時間的定義格式(參考 Job Scheduler Guide第14頁)
[no] trigger on HH:MM {daily | weekly <1-7> | monthly <1-31>}
[count <1-1000>] [start YYYY-MM-DD]


switch(config)# show schedule  POE_PORT1_down_worktime

=〉列出 POE_PORT1_down_worktime的schedule 

若要取消這個 schedule則下此指令

switch(config)# no schedule  POE_PORT1_down_worktime

#########################################

接著定義第2個job,把port 1的poe啟用

switch(config)# job  POE_PORT1_UP     =〉建立一個排程名稱

switch(config-job-PTog1)# desc port 1/1/1 poe funtion UP =〉建立一個此排程的描述   

switch(config-job-PTog1)# 10 cli config  =〉進入指令設定模式

switch(config-job-PTog1)# 20 cli interface 1/1/1  =〉進入第1埠

switch(config-job-PTog1)# 30 cli  power-over-ethernet   =〉設定poe 啟用

switch(config-job-PTog1)# 40 cli end =〉跳脫設定模式

switch(config-job-PTog1)# exit

定義一段POE_PORT1_UP執行的時間

switch(config)# schedule POE_PORT1_UP_worktime =〉名稱自訂

switch(config-schedule-POE_PORT1_UP_worktime)# desc 23:30 everyday

switch(config-schedule-POE_PORT1_UP_worktime)# 10 job POE_PORT1_UP 

switch(config-schedule-POE_PORT1_UP_worktime)# trigger on 23:30 daily count 7 start 2024-12-05 

switch(config-schedule-POE_PORT1_UP_worktime)# exit

如此,就可設定port 1的poe功能,於每日22:20停止供電,23:30恢復供電







星期日, 10月 25, 2015

DHCP snooping 與 IP Source Guard

###############################################

※關於dhcp snooping的觀念,請參考「防堵私自架設DHCP伺服器」這一篇文章
關於底下將提到的ip source guard觀念,請參考「建構自我防禦不可不知-以交換器為基礎之安全防護觀念
###############################################

身為網路管理人員,區域網路的環境中,如果有未經許可的路由器放在區網中,而此路由器又將DHCP Server功能開啟,對網管人員而言簡直是惡夢一場,因為區域網路中的電腦會租用到非法或不對的ip、gateway及dns資料,造成使用人員反應網路不通或有問題, 現在的Layer2交換器大多內建dhcp snooping功能,可將連接到正確及安全的dhcp server來源埠綁定為trust(信任),這樣在此交換器所不允許的埠下(設為untrust),只要是DHCP伺服器才會發送的【DHCPOffer】或【DHCPAck】這兩種訊息在Untrust介面下都會被攔阻下來,只允許透過Trust介面傳送。這樣,就不用擔心網路上私自架設的DHCP伺服器干擾內部網路的正常運作。
#############################################################
SMC 8126L2啟用 dhcp snooping  指令

ip dhcp snooping vlan 1
ip dhcp snooping vlan 2
ip dhcp snooping -- 大開關
UP-link Port 或是接 DHCP Server .. Port 要設定 TRUST
SW#1(config)#interface ethernet 1/24  - 接 DHCP Server01
SW#1(config-if)#ip dhcp snooping trust
若要取消dhcp snooping則下no ip dhcp snooping

###############################################
實例:
若交換器有切vlan id 11,22,33,44,第24埠上接dhcp server來源
則dhcp snooping啟用的步驟如下
Vty-0#configure
Vty-0(config)#ip dhcp snooping vlan 11 =>指定在vlan id 11啟用ip dhcp snooping
Vty-0(config)#ip dhcp snooping vlan 22
Vty-0(config)#ip dhcp snooping vlan 33
Vty-0(config)#ip dhcp snooping vlan 44
以上所有界面為untrust,即若有人架dhcp server則dhcp 送的【DHCPOffer】或【DHCPAck】訊息會被阻擋下來
我們必須加入至少一個dhcp server來源界面為trust
##本例設第24埠為trust界面
Vty-0(config)#interface ethernet 1/24
Vty-0(config-if)#ip dhcp snooping trust
Vty-0(config)#exit
Vty-0#show ip dhcp snooping =>顯示dhcp snooping資訊
Global DHCP Snooping status: disable
DHCP Snooping Information Option Status: disable
DHCP Snooping Information Policy: replace
DHCP Snooping is configured on the following VLANs:
   1,   11,   22,   33,   44,   55,   66,   77,   88,   99,  101,
Verify Source Mac-Address: enable
Interface           Trusted
----------          ----------
Eth 1/1             No
Eth 1/2             No
Eth 1/3             No
Eth 1/4             No
Eth 1/5             No
........
........
Eth 1/23            No
Eth 1/24            Yes
Eth 1/25            No
Eth 1/26            No



上面的Global DHCP Snooping status: 若為disable,則需開啟dhcp snooping 的大開關
開啟後,Switch會自動將DHCP分配到Client端的IP,建立一份表單(dhcp snooping binding table),有了這份表單,當我們之後要用到IP Source Guard的功能時,Switch就會根據Client端的IP及Mac Address是否在這份表單中來當作放行的依據,否則,Switch就不給上,這可以用來防止未經授權的使用者私自設定IP上網。

以下先設定Global DHCP Snooping status為Enabled

Vty-0#configure
Vty-0(config)#ip dhcp snooping
按「enter」
Vty-0(config)#exit
Vty-0#show ip dhcp snooping
看是否出現以下訊息
Global DHCP Snooping status: enabled
DHCP Snooping Information Option Status: enabled


Vty-0#show ip dhcp snooping binding  =>show出dhcp snooping是否有在學習紀錄dhcp配出來的ip及MAC對映

MAC Address       IP Address      Lease(sec) Type                 VLAN Interface
----------------- --------------- ---------- -------------------- ---- ---------
00-xx-xx-xx-a5-59 172.20.x.1--         86330 dhcp-snooping          77 Eth 1/18
00-xx-xx-xx-c3-63 172.20.x.1--         86360 dhcp-snooping          77 Eth 1/13

以上先啟用後,之後若是啟用ip source guard功能,則可限制使用者只能拿到DHCP Server發的IP,若使用者自行設定IP是不能上的,若有額外必須設固定IP, 則需要手動加ip及mac到binding table中。
ip source guard 啟用後,每一埠有限制筆數(5-16筆,視交換器廠牌類型),因此若此埠下還有接網路交換器,而使用者多的話,則此埠最好不要開ip source guard以免底下使用者要不到IP

ip source-guard 啟用步驟(以port20啟用為例)

SW1(config)#interface ethernet 1/1-20
SW1(config-if)#ip source-guard sip-mac (需要IP和MAC在Binding Table中有資料且一致才行)
SW1(config-if)#exit

加入一筆資料mac為 11-11-11-11-11-11 IP為172.20.1.99,在port2的位置可接受固定IP

Vty-0(config)#ip source-guard binding 11-11-11-11-11-11 vlan 11 172.20.1.99  interface ethernet 1/2



###################################################################
LINUX  DHCP Server  搭配交換器的 DHCP Option 82功能 .   可以控制用戶端的 DHCP IP 取得,例如我們可以設定使用者從哪個埠連上來,我就給哪個IP或哪個區段的IP。或是同一網段下,我們可以設定交換器第1埠給哪一個IP,第2埠給給哪一組的IP。也可以經由DHCP Server的LOG檔中看到使用者使用哪一台MAC Address裝置從哪一埠,哪一組vlan連上來。對於管理者管理內部網路是很有用的工具之一,log紀錄檔可參考下圖:


##################################################
Linux DHCP Server dhcpd.conf

###################################################
#
# Sample configuration file for ISC dhcpd for Debian
#
# Attention: If /etc/ltsp/dhcpd.conf exists, that will be used as
# configuration file instead of this file.
#
#

# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages ('none', since DHCP v2 didn't
# have support for DDNS.)
ddns-update-style none;

# option definitions common to all supported networks...
option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;

default-lease-time 600;
max-lease-time 7200;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.

#subnet 10.152.187.0 netmask 255.255.255.0 {
#}

# This is a very basic subnet declaration.

#subnet 10.254.239.0 netmask 255.255.255.224 {
#  range 10.254.239.10 10.254.239.20;
#  option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
#}

# This declaration allows BOOTP clients to get dynamic addresses,
# which we don't really recommend.

#subnet 10.254.239.32 netmask 255.255.255.224 {
#  range dynamic-bootp 10.254.239.40 10.254.239.60;
#  option broadcast-address 10.254.239.31;
#  option routers rtr-239-32-1.example.org;
#}

# A slightly different configuration for an internal subnet.
#subnet 10.5.5.0 netmask 255.255.255.224 {
#  range 10.5.5.26 10.5.5.30;
#  option domain-name-servers ns1.internal.example.org;
#  option domain-name "internal.example.org";
#  option routers 10.5.5.1;
#  option broadcast-address 10.5.5.31;
#  default-lease-time 600;
#  max-lease-time 7200;
#}

# Hosts which require special configuration options can be listed in
# host statements.   If no address is specified, the address will be
# allocated dynamically (if possible), but the host-specific information
# will still come from the host declaration.

#host passacaglia {
#  hardware ethernet 0:0:c0:5d:bd:95;
#  filename "vmunix.passacaglia";
#  server-name "toccata.fugue.com";
#}

# Fixed IP addresses can also be specified for hosts.   These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP.   Hosts for which no fixed address is specified can only
# be booted with DHCP, unless there is an address range on the subnet
# to which a BOOTP client is connected which has the dynamic-bootp flag
# set.
#host fantasia {
#  hardware ethernet 08:00:07:26:c0:a5;
#  fixed-address fantasia.fugue.com;
#}

# You can declare a class of clients and then do address allocation
# based on that.   The example below shows a case where all clients
# in a certain class get addresses on the 10.17.224/24 subnet, and all
# other clients get addresses on the 10.0.29/24 subnet.

#class "foo" {
#  match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
#}

#shared-network 224-29 {
#  subnet 10.17.224.0 netmask 255.255.255.0 {
#    option routers rtr-224.example.org;
#  }
#  subnet 10.0.29.0 netmask 255.255.255.0 {
#    option routers rtr-29.example.org;
#  }
#  pool {
#    allow members of "foo";
#    range 10.17.224.10 10.17.224.250;
#  }
#  pool {
#    deny members of "foo";
#    range 10.0.29.10 10.0.29.230;
#  }
#}
 class "by-oui-mac" {
 match if (binary-to-ascii (16,8,":",substring(hardware, 0, 4)) = "1:20:6a:8a")
 or (binary-to-ascii (16,8,":",substring(hardware, 0, 4)) = "1:0:3:6b")
 or (binary-to-ascii (16,8,":",substring(hardware, 0, 4)) = "1:0:7:eb");
 log (info, (binary-to-ascii (16,8,":",substring(hardware, 0, 4))));
 }

class "other" {
 match if not (binary-to-ascii (16,8,":",substring(hardware, 0, 4)) = "1:20:6a:8a")
 and not (binary-to-ascii (16,8,":",substring(hardware, 0, 4)) = "1:0:3:6b")
 and not (binary-to-ascii (16,8,":",substring(hardware, 0, 4)) = "1:0:7:eb");
 log (info, concat("other-mac",(binary-to-ascii (16,8,":",substring(hardware, 0, 4)))));
 }


 class "No_AID"{
        match if  not exists agent.remote-id;  }

 class "fixed6"{
        match if  binary-to-ascii(16, 8, ":", substring(option agent.remote-id, 2, 6)) = "70:72:cf:95:aa:5c" and binary-to-ascii (10, 8, "/", suffix ( option agent.circuit-id, 2)) = "1/5";
  }

  class "fixed7"{
        match if  binary-to-ascii(16, 8, ":", substring(option agent.remote-id, 2, 6)) = "70:72:cf:95:aa:5c"
and binary-to-ascii (10, 8, "/", suffix ( option agent.circuit-id, 2)) = "1/6";
  }

class "port4"{ match if binary-to-ascii (10, 8, "/", suffix ( option agent.circuit-id, 2)) = "1/4"; }

# Test01
subnet 192.168.2.0 netmask 255.255.255.0 {
    pool{
range 192.168.2.6;
        allow members of "fixed6";
  }

  pool{
        range 192.168.2.7;
        allow members of "fixed7";
  }

 pool{
        range 192.168.2.4;
        allow members of "port4";
  }

 pool{
        range 192.168.2.210  192.168.2.220;
        option routers 192.168.2.2;
        allow members of "by-oui-mac";
  }


pool{
        range 192.168.2.141 192.168.2.150;
        allow members of "No_AID";
      # MyNotebook
host E10089 {
hardware ethernet 20:6A:99:6F:2C:70;
fixed-address 192.168.2.33;
}

  }

  }
     
if exists agent.circuit-id
{
  log (info, concat("Lease for ",
                binary-to-ascii (10, 8, ".", leased-address),
                " is connected to interface ",
                binary-to-ascii (10, 8, "/",
                suffix ( option agent.circuit-id, 2)),
                " (add 1 to port number!), VLAN ",
                binary-to-ascii (10, 16, "",
                substring( option agent.circuit-id, 2, 2)),
                " on switch ",
                binary-to-ascii(16, 8, ":",
                substring( option agent.remote-id, 2, 6))));
  log (info, concat("Lease for ",
                binary-to-ascii (10, 8, ".", leased-address),
                " raw option-82 info is CID: ",
                binary-to-ascii (10, 8, ".", option agent.circuit-id),
                " AID: ",
                binary-to-ascii(16, 8, ".", option agent.remote-id)));
}
else { log (info, "client is neither known no agent-id"); }

###############################################
說明:
substring(option agent.circuit-id,2,2)   代表偏移量2, 長度2. 這個表達式取出了Option 82中的VID部分
binary-to-ascii(10,16,"",substring(option agent.circuit-id,2,2))   10表示十進制, 16表示16個bit. 這個表達式的結果就是把Option 82種的VLAN ID轉成10進制.
以上參考:Linux平臺上支持Option82的DHCP服務器配置




##################################################
參考資料:

  1. DHCP snooping的觀念與運作方式及 IP source guard的設定
  2. 防堵私自架設DHCP伺服器
  3. Linux DHCP Option 82 設定
  4. How to configure Option 82 aware DHCP Server(Zyxel)
  5. Static Addressing Within a DHCP Structure
  6. ISC DHCP and option 82
  7. How to use DHCP option 82 on ECS4110-28T for assign different DHCP IP pools to clients?(Edge-Core KW)
  8. Sample configuration file for ISC dhcpd using Option 82
  9. DHCP Option 82, Cisco switches and routers and the ISC DHCP server
  10. Use DHCP Snooping, Option 82  and Filtering on AT-8800, AT-8600, AT-8700XL
  11. Linux平臺上支持Option82的DHCP服務器配置
  12. 測試DHCP Option82 設定了好久的dhcpd.conf
  13. Understand DHCP relay option 82 Agent Circuit ID (Zyxel KW)
  14. Rogue DHCP (wikipedia)
  15. ISC-DHCP-Server的文件
  16. 瞭解DHCP Snooping,IPsource Guard的好文章



星期一, 1月 26, 2015

3com SMC的switch 校時設定

3com 4210 交換器的ntp server 校時設定

<4210>system view
[4210]ntp-service unicast-server "NTP SERVER的IP"
[4210]quit
<4210>clock timezone t8 add 08:00:00 (註:t8可自訂名稱,例如taiwan,taipei等)
<4210>display clock
12:12:03 t8 Mon 01/26/2015
Time Zone : t8 add 08:00:00
<4210>display ntp-service status
 Clock status: synchronized
 Clock stratum: 12
 Reference clock ID: NTP SERVER的IP
 Nominal frequency: 100.0000 Hz
 Actual frequency: 99.9999 Hz
 Clock precision: 2^18
 Clock offset: 0.0000 ms
 Root delay: 16.06 ms
 Root dispersion: 563.47 ms
 Peer dispersion: 11.43 ms
 Reference time: 04:12:10.612 UTC Jan 26 2015(D8703D1A.9CB8E086)
<4210>

SMC 8126L2交換器校時設定
***************************************************************


Vty-0#configure
Vty-0(config)#sntp server 172.20.1.242
Vty-0(config)#clock timezone taiwan hours 8 minute 0 after-UTC (註:taiwan這個名稱可以自訂)
Vty-0(config)#exit
Vty-0#show sntp
Current Time:  Jul  7 21:51:35 2015
Poll Interval: 16
Current  Mode: unicast
SNTP Status:   Enabled
SNTP Server:    172.20.1.242 0.0.0.0 0.0.0.0
                                                 Current Server: 172.20.1.242
Vty-0#

















星期六, 11月 01, 2014

RouterOS如何設定Vlan並和EdgeCore Es4308連接

當初NGN擴大內需配發一台Edgecore Es4308 POE8 埠交換器,近來各校都陸續改成MikroTik的RouterOS當作防火牆,有部學校是使用Rb450G或是利用一般的PC自己架設,但是有時會遇到內部網路或無線網路需要切割網段,但是又買不起Layer3的交換器,因此就測試如何利用RouterOS的某一埠,利用Vlan切割成不同的網段,再將這一埠的下層接到ES4308交換器,這樣就可以利用這台剩下的7埠作不同的網段運用。
本次環境以RouterOS的第10埠作為範例,使用者可以套用到RouterOS其他埠。
RouterOS:第10埠=>ether10,切成3個vlan,名稱分別為vlan111,vlan222,vlan333。

  • vlan111規畫為192.168.1.0/24的網段,VLAN ID為111,interface ip為192.168.1.1,此當作這個.1.0網段的gateway。
  • vlan222規畫為192.168.2.0/24的網段,VLAN ID為222,interface ip為192.168.2.1,此當作這個.2.0網段的gateway。
  • vlan333規畫為192.168.3.0/24的網段,VLAN ID為333,interface ip為192.168.3.1,此當作這個.3.0網段的gateway。
我們規畫的網路類似以下這樣:



步驟一:新增ROS的vlan界面


  • 進入Ros->Interfaces->VLAN,我們新增一個VLAN,Name為vlan111,VLAN ID為111,Interface為ether10。
  • VLAN ID只能設數字,這是定義你的封包通過這個VLAN時,封包的表頭會加入一個VLAN ID為111的資料,讓交換器判斷這是屬於哪個VLAN的封包,所以ID可以自行設定不一定設111,但只能設定數字,通常設定的值範圍為1-4096,而一般VLAN ID:1是保留為交換器初始預設的VLAN,所以最好不能再設1。
  • Name是VLAN的名稱,這是給自己看的,所以VLAN ID為111,Name不一定要設vlan111,你也可以設v111,v01…等,只要自己看得懂就好。
  • Interface:因為是利用ROS的第10埠來做,所以設ether10,如果你是用第5埠則要選ether5。




第二個VLAN ID我是設222,名稱設vlan222,Interface因為是與vlan111共用同一實體埠(ether10),所以一樣選ether10。接著VLAN 333,名稱:vlan333,interface選ether10。


到這個步驟為此我們已將實體的第10埠切成3個vlan的虛擬埠。




步驟二:設定vlan界面的IP
點選IP->Address->【+】,新增Interface:vlan111,vlan222,vlan333的address及Network,設定值如下:

Address:192.168.1.1/24
Network:192.168.1.0
Interface:vlan111

Address:192.168.2.1/24
Network:192.168.2.0
Interface:vlan222

Address:192.168.3.1/24
Network:192.168.3.0
Interface:vlan333



步驟三:配置DHCP(此步驟為假設動態分配IP是由ROS來分配)
(1)點選ip->pool->【+】,這邊我們要規畫三組DHCP Server可以分配的IP範圍,到時根據不同的VLAN給予不同的IP區段。vlan111預設由dhcp分配192.168.1.10-192.168.1.200,vlan222預設由dhcp分配192.168.2.10-192.168.2.200,vlan333預設由dhcp分配192.168.3.10-192.168.3.200。這邊的Name請自取,我是設定vlan1_pool~vlan3_pool。



(2)設定DHCP Server:我們設定
  1. vlan1_pool的IP區段分配給Interface vlan111。
  2. vlan2_pool的IP區段分配給Interface vlan222。
  3. vlan3_pool的IP區段分配給Interface vlan333。
點選IP->DHCP Server->【+】,Name自訂,我們這邊以vlan1_dhcp為示範,Ingterface選vlan111,Address Pool選vlan1_pool(這是我們之前自行定義的ip分配區段),其他的設定選項如:Lease Time、Authoritative等先照預設,再點按【Apply】。
vlan2_dhcp和vlan3_dhcp,則依此設定方式進行設定。


(3)接著要設定DHCP Server分配的IP要帶哪些資料
點選IP->DHCP Server->Networks->【+】,分別加入192.168.1.0/24,192.168.2.0/24,192.168.3.0/24,及這三段分配IP的gateway,netmask,dns等。

步驟四:設定路由

再來要設定3個vlan 界面的路由,讓3個網段能彼此互通:
點按IP->Routes->Routes->【+】,增加3條路由
第1條路由:
Dst. Address:192.168.1.0/24,gateway:vlan111
第2條路由:
Dst. Address:192.168.2.0/24,gateway:vlan222
第3條路由:
Dst. Address:192.168.3.0/24,gateway:vlan333



步驟五:設定NAT對外連線

新增3條NAT規則,讓這3個網段能對外連線
語法如下:

/ip firewall nat
add action=src-nat chain=srcnat comment=vlan111 out-interface=依自身設定而定 \
    src-address=192.168.1.0/24 to-addresses=163.23.XXX.YY1
add action=src-nat chain=srcnat comment=vlan222 out-interface=依自身設定而定 \
    src-address=192.168.2.0/24 to-addresses=163.23.XXX.YY2
add action=src-nat chain=srcnat comment=vlan333 out-interface=依自身設定而定 \
    src-address=192.168.3.0/24 to-addresses=163.23.XXX.YY3
#############################################################################
以上為RouterOS新增3個VLAN並由ROS本身的DHCP Server提供的動態分配IP、路由及NAT的設定範例。

以下將示範EdgeCore ES4308的VLAN設定範例,
我們假設ES4308的port2和前述ROS的port10(ether10)對接,Es4308的port3要設為vlan111,下面接行政電腦,port4要設vlan222,下接電腦教室電腦,port5要設vlan333,下接教學區電腦。
首先要連進Es4308,根據原廠手冊說明(Edge-core Es4308 POE 使用手冊),該設備預設的IP為192.168.2.10,密碼為admin,但請注意,這個192.168.2.10雖然看起來和我們vlan222是同一網段,但不代表這個網段就可以連得進去,因為他們的vlan是不一樣的,所以你必須要找一台電腦先設與ES4308同一網段,再對接,這裡我們將電腦A與ES4308的port1對接再連入設備中進行以下的相關設定。

為了方便觀察設定是否生效,建議再找另一台電腦B接到es4308的port4,以觀察是否能順利取得vlan222所配的IP,及是否能正常連線。

電腦A連進ES4308的設定畫面後,點按VLANS->VLAN Membership,一般而言所有網管交換器都會至少有一個Vlan ID=1的設定,所以這台交換器的IP是vlan id=1的網段,因此和vlan id=222的網段是不同的,所以電腦B是連不進來這台的。
我們加入新的VLAN ID:222(這裡的ID:222和ROS vlan222的id:222是相同的,也就是封包都是帶vlan tag 222,也因此才能互通),以下所稱的vlan id:222會簡稱為VID:222


加入VID:222後,要再設定哪些埠是屬於VID:222,我們設定port2和port4,因為port2上面接ROS(這裡因為上面要接ROS或網管型的設備的埠,所以之後要設VID:222,tagged only),port4下面接電腦教室(這個port我們會設定VID:222 untagged,所以只能接電腦或無網管交換器),設定完後,點按【APPLY】


如果設定完後,還要再修改VID:222加入其他埠時,則點按VLAN Membership->222->Modify,就可再修改不同的埠號。


點按VLAN Port Config,這個設定是關鍵,PORT2的PacketType要選Tagged Only,PVID要選None,這樣Es4308的port2和ROS的port10的所有帶VID:222的封包才會互通,但其他VID的呢?因為我們剛剛在VLAN Membership只有設VLAN 222,當然目前只有這個vlan的會通,你可以如同前的步驟在port2加上VID 111和VID 333。
Port4因為要接電腦或無網交換器,所以Packet Type選All,然後PVID選222,如果設定無誤的話,接這個port的電腦B將會拿到ROS vlan 222所設定的IP區段的Ip。這時ROS->DHCP Server的Leases看是否有釋出192.168.2.0這個網段的Ip。



如果Port3所接的電腦要拿到ROS所配的192.168.1.0的網段,ES4308的VLAN Membership要再加上VLAN ID:111,群組的port要選擇port2和port3。
因為port我們已經在vlan port config設定Packet Type為Tagged Only,PVID為None。所以這裡我們只要設Port3的Packet Type為All,PVID為111,這樣Port3的電腦就會拿到ROS配的192.168.1.0的網段IP。

#################################################################################

前面提到這台交換器預設的IP為192.168.2.10,我們進入SYSTEM->LAN Settings,Management VLAN為1,所以它不屬於VLAN ID:111或222或333,因此一定要有一台電腦A接到PVID為1的埠才能管理。


但這樣如果上機架或機櫃時無法達到遠端管理,所以我們要修改這台交換器的Management VLAN 讓它可以加入到我們環境運作的VLAN中,因為原有IP是192.168.2.10,剛好和我們VLAN 222是同一網段,因此我們就修改為如下:

Switch IP Address:192.168.2.10
Subnet Mask 255.255.255.0
Gateway IP Address:192.168.1.1
Management VLAN:222




因為我們已經設定VLAN 111,VLAN222,VLAN 333這三個LAN的網段可以互相路由,所以不管我們在192.168.1.0或192.168.2.0或192.168.3.0的網段,都可以打開瀏覽器連到192.168.2.10這個交換器進行管理或修改設定。

如下圖,我將交換器IP設為192.168.1.10,gateway:192.168.1.1,Management VLAN:111,我們電腦是接Es4308的Port4,也就是PVID設定為222,所以是屬於192.168.2.0的網段,經測試是可以直接連到192.168.1.10的交換器進行管理。

#################################################################################

根據前面的網路規畫圖,192.168.2.10這台交換器VLAN設定會是如下:

192.168.2.10的PORT8所接的192.168.2.11這台交換器的VLAN 設定會是如下:

#############################################################################

星期三, 9月 24, 2014

SMC 8126L2 交換器不通,如何在交換器中下指令偵錯

一天早上,學校反應有一棟樓網路不通,第一反應是看機房主交換器的光纖是否有問題,這一棟的光纖當初因為主交換器的port不夠用,所以接到機房後,先接一台3com 4500交換器的光纖埠,再從3com 4500 的UTP埠接到上層主交換器。

因為機房光纖埠燈號有亮,所以這邊沒問題,接著到不通的那一棟機櫃看,裡頭的SMC 8126L2 光纖燈號也是亮著,直接接到switch,設定管理IP,可以直接連到該交換器的ip,但是切換回來,雖然直接接交換器,就是無法得到dhcp所分配的ip,再設固定IP也無法ping上一層。要深入瞭解原因,只能以console進交換器,才能知道,因為telnet進得去,所以就直接用telnet進交換器

首先,測試第24埠光纖埠的資料,看設定是是否有跑掉!

Vty-0#show interfaces switchport ethernet 1/24
Information of Eth 1/24
 Broadcast Threshold:           Enabled, 500 packets/second
 Multicast Threshold:           Disabled
 Unknown Unicast Threshold:     Disabled
 LACP Status:                   Disabled
 Ingress Rate Limit:            Disabled, 1000 Mbits per second
 Egress Rate Limit:             Disabled, 1000 Mbits per second
 VLAN Membership Mode:          Trunk
 Ingress Rule:                  Disabled
 Acceptable Frame Type:         All frames
 Native VLAN:                   1
 Priority for Untagged Traffic: 0
 GVRP Status:                   Disabled
 Allowed VLAN:                     1(t),   2(t),   6(t),,4093(t),
 Forbidden VLAN:
 Private-VLAN Mode:             NONE
 Private-VLAN host-association: NONE
 Private-VLAN Mapping:          NONE
 802.1Q-tunnel Status:          Disable
 802.1Q-tunnel Mode:            NORMAL

 802.1Q-tunnel TPID:            8100(Hex)


再測試是否捉到上層的mac資料:

Vty-0#show mac-address-table
 Interface MAC Address       VLAN Type
 --------- ----------------- ---- -----------------
  Eth 1/ 1 B8-6B-23-72-CD-20   11 Learned
  Eth 1/24 00-16-E0-0B-D6-81    1 Learned
  Eth 1/24 00-1E-C1-F7-E4-81    1 Learned
  Eth 1/24 00-1E-C1-F7-E4-9B    1 Learned

結果有吔,第24埠有學習到mac,再清除一遍,再測試一次
Vty-0#clear mac-address-table dynamic
Vty-0#show mac-address-table
 Interface MAC Address       VLAN Type
 --------- ----------------- ---- -----------------
Vty-0#show mac-address-table
 Interface MAC Address       VLAN Type
 --------- ----------------- ---- -----------------
  Eth 1/24 00-16-E0-0B-D6-81    1 Learned
  Eth 1/24 00-1E-C1-F7-E4-9B    1 Learned
  Eth 1/24 70-62-B8-9E-28-08    1 Learned
  Eth 1/24 00-15-F2-7D-88-6F   11 Learned
  Eth 1/24 00-C0-EE-91-67-6B   11 Learned
  Eth 1/24 74-27-EA-B7-54-AA   11 Learned

有捉到資料,代表,24埠可以學習到上層的mac,也就是光纖埠彼此是通的,這就要再測試上面串接的3com 4500交換器,回到機房端再測試。
ping 不到,web進不去,telnet到一半就沒資料了,可能當機,所以重開機。
再ping 一次,回應時好時壞,web還是連不進去,研判應該是交換壞掉,剛好有一台備用的交換器,趕緊換上,結果就通了!
今天學到了如何在交換器中下指令去確認問題。

星期五, 8月 02, 2013

3com 4500與4210設定範例



環境3com 4500當上層交換器
3com 4210當下層交換器
3com 450026埠接3com 421025
3com 4500 本身ip設定為172.21.1.254/24
Vlan 22 172.21.2.0/24 port 1-4
Vlan 33 172.21.3.0/24 port 5-8
Vlan 44 172.21.4.0/24 port 9-12

3com 4210 本身ip設定為172.21.1.253/24
Vlan 22 port 1-4
Vlan 33 port 5-8
Vlan 44 port 9-12

3com 4500的設定


<4500>
system-view
進入設定

[4500]
INTERFACE VLAN 1
進入vlan1 這個界面,交換器預設一定會有vlan 1

[4500-Vlan-interface1]
IP ADDRESS 172.21.1.254 255.255.255.0
設定vlan 1ip,也就這台交換器的IP

[4500-Vlan-interface1]
quit
跳離設定模式

[4500]
vlan 22
新增一個名為22vlan,並跳入vlan 22

[4500-vlan22]
vlan 33
新增一個名為33vlan,並跳入vlan 33

[4500-vlan33]
vlan 44
新增一個名為44vlan,並跳入vlan 44

[4500-vlan44]
quit
跳離

[4500]
vlan 22
進入vlan 22中設定

[4500-vlan22]
PORT ETHERNET 1/0/1 TO ETHERNET 1/0/4
port 1,2,3,4設定為vlan 22

[4500-vlan22]
vlan 33
進入vlan 33中設定

[4500-vlan33]
PORT ETHERNET 1/0/5 TO ETHERNET 1/0/8
port 5,6,7,8設定為vlan 33

[4500-vlan33]
vlan 44
進入vlan 44中設定

[4500-vlan44]
PORT ETHERNET 1/0/9 TO ETHERNET 1/0/12
port 5,6,7,8設定為vlan 33

[4500-vlan44]
quit


[4500]
display vlan
showvlan的內容


Total 4 VLAN exist(s).
 The following VLANs exist:
  1(default), 22, 33, 44


[4500]
interface Vlan-interface 22
進入vlan 22的設定界面

[4500-Vlan-interface22]
ip add 172.21.2.0 24
設定vlan 22ip

[4500-Vlan-interface22]
interface Vlan-interface 33
進入vlan 33的設定界面

[4500-Vlan-interface33]
ip add 172.21.3.0 24
設定vlan 33ip

[4500-Vlan-interface33]
interface Vlan-interface 44
進入vlan 44的設定界面

[4500-Vlan-interface44]
ip add 172.21.4.0 24
設定vlan 44ip

[4500-Vlan-interface44]
quit


[4500]
dis vlan all
顯示所有的vlan設定

[4500]
save


[4500]
The configuration will be written to the device.
Are you sure?[Y/N]
是否要儲存設定,如果沒問題就是Y

[4500]

3com預設port 27,28up的狀態,也就預設就可以用了,若要將mini gbic插入25,26 則要將27,28 down,將25,26 up

[4500]
interface  GigabitEthernet 1/0/27
因為25-28giga port所以一定要有GigabitEthernet才能進入port 27

[4500 -GigabitEthernet1/0/27]
Shutdown
port 27 shutdown才能讓對映的port 25啟用,但是請注意,下完這個指令後,系統會自動reboot,要小心設定是否己儲存

<4500>
system view


[4500]
interface  GigabitEthernet 1/0/25
如果燈號還是沒亮,這時就必須將其定速

[4500 -GigabitEthernet1/0/25]
speed 1000
定速為1000 Mbps

[4500 -GigabitEthernet1/0/25]
Duplex full
定義為全雙工模式

[4500 -GigabitEthernet1/0/25]
quit










另外下層的4210設定也是如此,只是4210Layer2,無法設定vlan interfaceIP
因為4500port 25要下接4210port26,且4210一樣要切vlan22 vlan33 vlan44 並讓兩部交換器的相同vlan能互相溝通,則port還要再作trunk的動作,且必須再設static route
再者,4210port 26要上接4500port 25,因此4210port 26也要設定啟用,再設定trunk並且 設static route

Port vlan 模式有3
1.      access :port只能屬於一個vlan
2.      hybrid :可以有很多種模式,ex vlan22 可帶tag vlan 33不帶tag
3.      trunk:所有封包帶tag
設定trunk的方式如下


[4500]
interface  GigabitEthernet 1/0/25


[4500 -GigabitEthernet1/0/25]
port link-type trunk


[4500 -GigabitEthernet1/0/25]
port trunk permit vlan 1


[4500 -GigabitEthernet1/0/25]
port trunk permit vlan 22


[4500 -GigabitEthernet1/0/25]
port trunk permit vlan 33


[4500 -GigabitEthernet1/0/25]
port trunk permit vlan 44


[4500 -GigabitEthernet1/0/25]
display ip interface brief

*down: administratively down
(l): loopback
(s): spoofing
 Interface                   IP Address      Physical  Protocol     Description
 Vlan-interface1             172.21.2.254    up     up         Vlan-inte...
 Vlan-interface22            172.21.2.254    up     up         Vlan-inte...
 Vlan-interface33            172.21.3.254    up     up         Vlan-inte...
 Vlan-interface44            172.21.4.254       up     up         Vlan-inte...

可以看到vlan-interface 22,33,44physical protocalup

所以4210trunk模式也是如上的方式設定
接著要設定dhcp relay,讓client可以順利向dhcp server要到ip


[4500]
dhcp-server 1 ip 172.20.1.2
設定group名稱1dhcp server ip172.20.1.2

[4500]
Interface Vlan-Interface 1
進入vlan 1

[4500-Vlan-interface1]
Dhcp-server 1
設定vlan 1dhcp relaydhcp-server 1也就向172.20.1.2ip

[4500-Vlan-interface1]
Interface Vlan-Interface 22
進入vlan 22

[4500-Vlan-interface22]
Dhcp-server 1
設定vlan 22dhcp relaydhcp-server 1也就向172.20.1.2ip

[4500-Vlan-interface22]
Interface Vlan-Interface 33


[4500-Vlan-interface33]
Dhcp-server 1


[4500-Vlan-interface33]
Interface Vlan-Interface 44


[4500-Vlan-interface44]
Dhcp-server 1


Display dhcp-server 1 顯示Dhcp-Server 設定
Display dhcp-server Interface Vlan 2 顯示VLAN 介面的Relay 設定
Display dhcp-security 顯示Dhcp 安全性定義

static route的設定

4210client預設所有的封包均往4500丟,所以
4210static route設定為
Ip route-static 0.0.0.0 0.0.0.0 172.21.1.254  
也就是說不管目的地是那邊,封包均往4500

4500要設定
Ip route-static 172.21.1.0 255.255.255.0 172.20.1.253
Ip route-static 172.21.2.0 255.255.255.0 172.20.1.253
Ip route-static 172.21.3.0 255.255.255.0 172.20.1.253
Ip route-static 172.21.4.0 255.255.255.0 172.20.1.253
也就是說來源封包為172.21.1.0/24172.21.2.0/24172.21.3.0/24172.21.4.0/24這四個網段的ip均往回到172.20.1.253這台交換器


如何消除指定portvlan
ex
[4210-vlan11]display vlan all
 VLAN ID: 11
 VLAN Type: static
 Route Interface: not configured
 Description: VLAN 0011
 Name: VLAN 0011
 Tagged   Ports: none
 Untagged Ports:
  Ethernet1/0/1            Ethernet1/0/2            Ethernet1/0/3
  Ethernet1/0/4            Ethernet1/0/6            Ethernet1/0/13
  Ethernet1/0/14           Ethernet1/0/15           Ethernet1/0/16
  Ethernet1/0/18

如果要除去vlan11 中的ethernet1/0/6 ethernet1/0/18則下以下指令:
[4210]vlan11
[4210-vlan11]
[4210-vlan11]undo port Ethernet 1/0/6
[4210-vlan11]undo port Ethernet 1/0/18
[4210-vlan11]display vlan all
VLAN ID: 11
 VLAN Type: static
 Route Interface: not configured
 Description: VLAN 0011
 Name: VLAN 0011
 Tagged   Ports: none
 Untagged Ports:
  Ethernet1/0/1            Ethernet1/0/2            Ethernet1/0/3
  Ethernet1/0/4            Ethernet1/0/13           Ethernet1/0/14
  Ethernet1/0/15           Ethernet1/0/16