Friday, February 23, 2018

Per-VLAN Spanning Tree (PVST+)

**** diagram

sw1 --------->sw2
|                       |
---------sw3--------

os version
Cisco IOS Software, 3700 Software (C3745-ADVENTERPRISEK9-M), Version 12.4(18), RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2007 by Cisco Systems, Inc.
Compiled Fri 30-Nov-07 22:31 by prod_rel_team

ROM: ROMMON Emulation Microcode
ROM: 3700 Software (C3745-ADVENTERPRISEK9-M), Version 12.4(18), RELEASE SOFTWARE (fc1)


- there're 3 vlans
2---> sw1 as root bridge
3--- > sw2 as root bridge
4---> sw3 as root bridge


1- configuration of those switch

- sw1

vlan database
vlan 2
vlan 3
vlan 4
apply
exit


spanning-tree vlan 2 priority 80
vtp file nvram:vlan.dat


interface FastEthernet0/0
 description *** Unused for Layer2 SW ***
 no ip address
 no ip route-cache
 shutdown
 duplex auto
 speed auto
!
interface FastEthernet0/1
 description *** Unused for Layer2 SW ***
 no ip address
 no ip route-cache
 shutdown
 duplex auto
 speed auto
!
interface FastEthernet1/0
 switchport mode trunk
 duplex full
 speed 100
!
interface FastEthernet1/1
 switchport mode trunk
 duplex full
 speed 100
!
interface FastEthernet1/2
 switchport mode trunk
 duplex full
 speed 100







- sw2

vlan database
vlan 2
vlan 3
vlan 4
apply
exit 


spanning-tree vlan 3 priority 80
vtp file nvram:vlan.dat

interface FastEthernet0/0
 description *** Unused for Layer2 SW ***
 no ip address
 no ip route-cache
 shutdown
 duplex auto
 speed auto
!
interface FastEthernet0/1
 description *** Unused for Layer2 SW ***
 no ip address
 no ip route-cache
 shutdown
 duplex auto
 speed auto
!
interface FastEthernet1/0
 switchport mode trunk
 duplex full
 speed 100
!
interface FastEthernet1/1
 switchport mode trunk
 duplex full
 speed 100



- sw3

vlan database
vlan 2
vlan 3
vlan 4
apply
exit

spanning-tree vlan 4 priority 80
vtp file nvram:vlan.dat

interface FastEthernet0/0
 description *** Unused for Layer2 SW ***
 no ip address
 no ip route-cache
 shutdown
 duplex auto
 speed auto
!
interface FastEthernet0/1
 description *** Unused for Layer2 SW ***
 no ip address
 no ip route-cache
 shutdown
 duplex auto
 speed auto
!
interface FastEthernet1/0
 duplex full
 speed 100
!
interface FastEthernet1/1
 switchport mode trunk
 duplex full
 speed 100
!
interface FastEthernet1/2
 switchport mode trunk
 duplex full
 speed 100




2- show command
-sw1
#show interfaces trunk

Port      Mode         Encapsulation  Status        Native vlan
Fa1/0     on           802.1q         trunking      1
Fa1/2     on           802.1q         trunking      1

Port      Vlans allowed on trunk
Fa1/0     1-1005
Fa1/2     1-1005

Port      Vlans allowed and active in management domain
Fa1/0     1-4
Fa1/2     1-4

Port      Vlans in spanning tree forwarding state and not pruned
Fa1/0     1-4
Fa1/2     1-4


------------------------

#show spanning-tree brief

VLAN1
  Spanning tree enabled protocol ieee
  Root ID    Priority    32768
             Address     c407.23ae.0000
             This bridge is the root
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32768
             Address     c407.23ae.0000
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300

Interface                                   Designated
Name                 Port ID Prio Cost  Sts Cost  Bridge ID            Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/0      128.41   128    19 FWD     0 32768 c407.23ae.0000 128.41
FastEthernet1/2      128.43   128    19 FWD     0 32768 c407.23ae.0000 128.43

         
VLAN2
  Spanning tree enabled protocol ieee
  Root ID    Priority    80
             Address     c407.23ae.0001
             This bridge is the root
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    80
             Address     c407.23ae.0001
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300

Interface                                   Designated
Name                 Port ID Prio Cost  Sts Cost  Bridge ID            Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/0      128.41   128    19 FWD     0    80 c407.23ae.0001 128.41
FastEthernet1/2      128.43   128    19 FWD     0    80 c407.23ae.0001 128.43

         
VLAN3
  Spanning tree enabled protocol ieee
  Root ID    Priority    80
             Address     c408.23ae.0002
             Cost        19
             Port        41 (FastEthernet1/0)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32768
             Address     c407.23ae.0002
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300

Interface                                   Designated
Name                 Port ID Prio Cost  Sts Cost  Bridge ID            Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/0      128.41   128    19 FWD     0    80 c408.23ae.0002 128.41
FastEthernet1/2      128.43   128    19 FWD    19 32768 c407.23ae.0002 128.43

         
VLAN4
  Spanning tree enabled protocol ieee
  Root ID    Priority    80
             Address     c409.23ae.0003
             Cost        19
             Port        43 (FastEthernet1/2)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32768
             Address     c407.23ae.0003
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300

Interface                                   Designated
Name                 Port ID Prio Cost  Sts Cost  Bridge ID            Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/0      128.41   128    19 FWD    19 32768 c407.23ae.0003 128.41
FastEthernet1/2      128.43   128    19 FWD     0    80 c409.23ae.0003 128.43 


--------------------------
#show spanning-tree summary
Root bridge for: VLAN1, VLAN2.
PortFast BPDU Guard is disabled
UplinkFast is disabled
BackboneFast is disabled

Name                 Blocking Listening Learning Forwarding STP Active
-------------------- -------- --------- -------- ---------- ----------
VLAN1                0        0         0        2          2        
VLAN2                0        0         0        2          2        
VLAN3                0        0         0        2          2        
VLAN4                0        0         0        2          2        
-------------------- -------- --------- -------- ---------- ----------
             4 VLANs 0        0         0        8          8        



-sw2
#show interfaces trunk

Port      Mode         Encapsulation  Status        Native vlan
Fa1/0     on           802.1q         trunking      1
Fa1/1     on           802.1q         trunking      1

Port      Vlans allowed on trunk
Fa1/0     1-1005
Fa1/1     1-1005

Port      Vlans allowed and active in management domain
Fa1/0     1-4
Fa1/1     1-4

Port      Vlans in spanning tree forwarding state and not pruned
Fa1/0     1-3
Fa1/1     1-4


----------------------------------------
#  show spanning-tree brief

VLAN1
  Spanning tree enabled protocol ieee
  Root ID    Priority    32768
             Address     c407.23ae.0000
             Cost        19
             Port        41 (FastEthernet1/0)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32768
             Address     c408.23ae.0000
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300

Interface                                   Designated
Name                 Port ID Prio Cost  Sts Cost  Bridge ID            Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/0      128.41   128    19 FWD     0 32768 c407.23ae.0000 128.41
FastEthernet1/1      128.42   128    19 FWD    19 32768 c408.23ae.0000 128.42

         
VLAN2
  Spanning tree enabled protocol ieee
  Root ID    Priority    80
             Address     c407.23ae.0001
             Cost        19
             Port        41 (FastEthernet1/0)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32768
             Address     c408.23ae.0001
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300

Interface                                   Designated
Name                 Port ID Prio Cost  Sts Cost  Bridge ID            Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/0      128.41   128    19 FWD     0    80 c407.23ae.0001 128.41
FastEthernet1/1      128.42   128    19 FWD    19 32768 c408.23ae.0001 128.42

         
VLAN3
  Spanning tree enabled protocol ieee
  Root ID    Priority    80
             Address     c408.23ae.0002
             This bridge is the root
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    80
             Address     c408.23ae.0002
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300

Interface                                   Designated
Name                 Port ID Prio Cost  Sts Cost  Bridge ID            Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/0      128.41   128    19 FWD     0    80 c408.23ae.0002 128.41
FastEthernet1/1      128.42   128    19 FWD     0    80 c408.23ae.0002 128.42

         
VLAN4
  Spanning tree enabled protocol ieee
  Root ID    Priority    80
             Address     c409.23ae.0003
             Cost        19
             Port        42 (FastEthernet1/1)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32768
             Address     c408.23ae.0003
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300

Interface                                   Designated
Name                 Port ID Prio Cost  Sts Cost  Bridge ID            Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/0      128.41   128    19 BLK    19 32768 c407.23ae.0003 128.41
FastEthernet1/1      128.42   128    19 FWD     0    80 c409.23ae.0003 128.42



--------------------------------------------------------------------
#  show spanning-tree summary
Root bridge for: VLAN3.
PortFast BPDU Guard is disabled
UplinkFast is disabled
BackboneFast is disabled

Name                 Blocking Listening Learning Forwarding STP Active
-------------------- -------- --------- -------- ---------- ----------
VLAN1                0        0         0        2          2        
VLAN2                0        0         0        2          2        
VLAN3                0        0         0        2          2        
VLAN4                1        0         0        1          2        
-------------------- -------- --------- -------- ---------- ----------
             4 VLANs 1        0         0        7          8   


Thursday, February 22, 2018

how to configure atm on cisco

**** diagram

r1 -------> atm switch <-------r2

- os version and router serie
Cisco IOS Software, 7200 Software (C7200-JK9S-M), Version 12.4(13b), RELEASE SOFTWARE (fc3)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2007 by Cisco Systems, Inc.
Compiled Wed 25-Apr-07 03:18 by prod_rel_team


ROM: ROMMON Emulation Microcode
BOOTLDR: 7200 Software (C7200-JK9S-M), Version 12.4(13b), RELEASE SOFTWARE (fc3)


1- on atm switch

- the mapping
port:vdi:vci                  port:vdi:vci
1:0:100                        10:0:200


so we mapping port 1 to port 10 using vdi 0 and one router use vci 100 and other uses vci 200.


-2- router r1 configuration file
interface FastEthernet0/0
 no ip address
 shutdown
 duplex half
!
interface ATM1/0
 no ip address
 no atm ilmi-keepalive
!
interface ATM1/0.100 point-to-point
 ip address 1.1.1.1 255.255.255.0
 no snmp trap link-status
 pvc 0 0/100
 !

!

3- router r2 configuration
interface FastEthernet0/0
 no ip address
 shutdown
 duplex half
!
interface ATM1/0
 no ip address
 no atm ilmi-keepalive
!
interface ATM1/0.200 point-to-point
 ip address 1.1.1.2 255.255.255.0
 no snmp trap link-status
 pvc 0 0/200
 !

!

Sunday, February 18, 2018

isolate vm using vlan with openvswitch

**** information
 vm1 connect to tap0 using vlan 100
vm2 connect to tap1 using vlan 101


1- create br0
$ sudo ovs-vsctl add-br br0


2- create tap devices

$ sudo tunctl
$ sudo tunctl

3- add tap0 and tap1 with vlan tag
$ sudo ovs-vsctl add-port br0 tap0 tag=100
$ sudo ovs-vsctl add-port br0 tap1 tag=101


4- run vm using tap device

-vm1
$ sudo qemu-system-x86_64  -m 1024 -enable-kvm  -hda /home/vm1.qcow2 -net nic,macaddr=DE:AD:B0:EF:E0:01 -net tap,ifname=tap0 

-vm2
$ sudo qemu-system-x86_64  -m 1024 -enable-kvm  -hdc /home/vm2.qcow2 -net nic,macaddr=DE:AD:B0:EF:E0:02 -net tap,ifname=tap1 


 5- if we to make the two vm able to reach each other, we need to create vlan0 on br0 and assign vlan

 $ sudo modprobe 8021q
$ vconfig add br0 100
$ sudo ifconfig br0.100 192.168.22.22/24up




$ vconfig add br0 101
$ sudo ifconfig br0.101 192.168.23.22/24up



then add ip_forwarding
$ sudo sysctl -w net.ipv4.ip_forward=1

Saturday, February 17, 2018

pocketsphinx, Speech recognition tool

1- install packages
$ sudo apt-get install  pocketsphinx pocketsphinx-en-us

2- convert audio file to wav format
$ ffmpeg  -i inputfile.aac output.wav
or
$ ffmpeg  -i inputfile.mp3 output.wav



the program need   ono 16000 Hz

so we can use command below
$ ffmpeg -i sphinx.wav -acodec pcm_s16le -ac 1 -ar 16000 out.wav

3- we can use pocketsphinx to recognize the speed the the microphone
 $ pocketsphinx_continuous -hmm   /usr/share/pocketsphinx/model/en-us/en-us  -lm /usr/share/pocketsphinx/model/en-us/en-us.lm.bin -dict /usr/share/pocketsphinx/model/en-us/cmudict-en-us.dict -inmic yes



4- or we recognize from the input file
$ pocketsphinx_continuous -hmm   /usr/share/pocketsphinx/model/en-us/en-us  -lm /usr/share/pocketsphinx/model/en-us/en-us.lm.bin -dict /usr/share/pocketsphinx/model/en-us/cmudict-en-us.dict -infile out.wav  | tee sphinxout




Saturday, February 10, 2018

hostapd' dynamic vlan

*** info
- radius server ip : 192.168.22.5
- hostapd ip address: 192.168.22.100

1- freeradius server (version 3)
- add the following line to /etc/freeradius/3.0/clients.conf
client perhost1 {
        ipaddr = 192.168.22.100
        secret          = radius
        require_message_authenticator = no
}


- add the following line to /etc/freeradius/3.0/users
"user1"     Cleartext-Password := "password1"
"user2"     Cleartext-Password := "password1"
    Tunnel-Type=13,
    Tunnel-Medium-Type=6,
    Tunnel-Private-Group-ID=2357










- restart freeradius service
 $ sudo /etc/init.d/freeradius restart

2- hostapd
- configuration file ap.conf
interface=wlan0
ssid=HWSim
driver=nl80211
hw_mode=g
channel=11
ieee8021x=1
wpa=3
wpa_key_mgmt=WPA-EAP
dynamic_vlan=1
vlan_file=/vlan.db
eap_reauth_period=3600
own_ip_addr=192.168.22.100
nas_identifier=ap.wired.com
auth_server_addr=192.168.22.5
auth_server_port=1812
auth_server_shared_secret=radius
acct_server_addr=192.168.22.5
acct_server_port=1813
acct_server_shared_secret=radius


- /vlan.db
10       wlan0.10
11       wlan0.11
2357       wlan0.2357
3393       wlan0.3393



- start hostapd
$ sudo hostapd -dd ap.conf


3- client
- copy  /etc/ssl/certs/ssl-cert-snakeoil.pem from freeradius server to client at /cert.pem

- client.conf  file
 network={
    ssid="HWSim"
    key_mgmt=WPA-EAP
    eap=PEAP
    identity="user3"
    password="password1"
    ca_cert="/cert.pem"
    phase1="peaplabel=1"
    phase2="auth=MSCHAPV2"
    priority=10
}


- start client
$   sudo wpa_supplicant -Dnl80211 -i wlan1 -c client.conf