Skip to content

Instantly share code, notes, and snippets.

@tangzero
Last active November 4, 2022 18:25
Show Gist options
  • Save tangzero/9862c4458be6b5ce20f9cbf3f21b58f3 to your computer and use it in GitHub Desktop.
Save tangzero/9862c4458be6b5ce20f9cbf3f21b58f3 to your computer and use it in GitHub Desktop.

Caso 1

SW1, SW2, SW3

basic config

<HUAWEI> sys
[HUAWEI] undo terminal monitor
[HUAWEI] sysname SW_

create vlans

[SW_] vlan batch 10 50 90 130 
[SW_] display vlan
[SW_] vlan 100 # native vlan
[vlan100] description NATIVA
[vlan100] quit

assign interfaces to vlan

[SW_] display port vlan
[SW_] port-group group-member <interface-from> <port-from> [to] <interface-to> <port-to>
[port-group] port link-type access // change to access mode  
[port-group] port default vlan <id> // assign interfaces to a vlan
[port-group] display port vlan // validate changes
[port-group] quit

create trunks

[SW_] port-group group-member <interface-from> <port-from> [to] <interface-to> <port-to>
[port-group] port link-type trunk // change to trunk
[port-group] port trunk allow-pass vlan <ids> ... // ex. 10 20 50 etc 
[port-group] port trunk pvid vlan 100 // native vlan
[port-group] display port vlan // validate changes
[port-group] quit

disable unused ports

[SW_] port-group group-member <interface-from> <port-from> [to] <interface-to> <port-to>
[port-group] shutdown
[port-group] port link-type access
[port-group] port default vlan 100 // native vlan or any unused vlan
[port-group] display this
[port-group] quit

save changes

<SW_> save

R1, R2

basic config

<HUAWEI> sys
[HUAWEI] undo terminal monitor
[HUAWEI] sysname R_

start the vlan interface

[R_] int <interface> <port>
[int] undo shutdown
[int] quit

create subinterfaces

[R_] int <interface> <port>.<vlan-id> // ex. int GigabitEthernet 0/0/0.10
[int] dot1q termination vid <vlan-id> // dot1q encapsulation
[int] ip address <ip> <mask> // ex. ip address 192.168.10.1 24
[int] arp broadcast enable
[int] display this
[int] quit

default route to ISP

[R_] int <interface> <port> // interface connected to ISP
[int] ip address <ip> <mask>
[int] undo shutdown
[int] display this
[int] quit
[R_] ip route-static 0.0.0.0 0.0.0.0 <isp-ip>

DHCP by interface

[R_] dhcp enable 
[R_] int <interface> <port>
[int] dhcp server excluded-ip-address <from-ip> <to-ip> 
[int] dhcp select interface // enable dhcp on this interface
[int] dhcp server dns-list 8.8.8.8
[int] display this
[int] quit

DHCP with pool

[R_] ip pool <name> // ip pool VLAN_90
[ip-pool] network <ip> mask <mask>
[ip-pool] gateway-list <ip>
[ip-pool] dns-list <ip>
[ip-pool] excluded-ip-address <from-ip> <to-ip> 
[ip-pool] display this
[ip-pool] int <interface> <port>
[int] dhcp select global
[int] quit

OSPF (process)

[R_] ospf <process> router-id <id> // ex. ospf 800 router-id 2.2.2.2
[ospf-800] area 0 // only one area
[ospf-800-area-0] network <ip> <wildcard> // network 50.50.50.8 0.0.0.7
[ospf-800-area-0] display this
[ospf-800-area-0] quit
[R_] display ospf interface broadcast

OSPF (interface)

[R_] ospf <process> router-id <id> // ex. ospf 800 router-id 3.3.3.3
[ospf-800] area 0 // only one area
[ospf-800-area-0] quit
[R_] int <interface> <port>
[int ip address ...
[int] no sh
[int] ospf enable <process> <area>
[int] display ospf peer brief // show neighbors

fake route to google

[ISP3] interface loopback 1
[loopback] ip address 8.8.8.8 32
[loopback] quit
[ISP3] ip route-static 0.0.0.0 0.0.0.0 loopback 1 
[ISP3] display ip routing-table
[ISP3] ospf <process>
[ospf-800] default-route-advertise

route to echo reply

[ISP2] ip route-static 192.168.0.0 16 200.13.48.9
[ISP2] ospf 200
[ospf-800] import-route static

Misc Commands

[port] shutdown # shutdown the interface
[port] no shutdown # starts the interface

[HUAWEI] display ip interface brief
[HUAWEI] display ip routing-table protocol ospf

[HUAWEI] reset ospf process
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment