Monday, March 26, 2018

Add static route ໃນ Cent OS



ປົກກະຕິໃນ Cent OS ເຮົາສາມາດ ແອດສະເຕຕິກ ຣູດ ໄດ້ໂດຍການໃຊ້ຄຳສັ່ງ

ip route add 10.5.1.0/28 via 172.23.1.1 dev em3

ແຕ່ວ່າມັນຊິບໍ່ຢູ່ໄດ້ຖາວອນຖ້າເຮົາ ເກີດມີການ restart network device static routing ທີ່ເຮັດຄ້າງໄວ້ກໍ່ຈະຫາຍໄປເຮົາສາມາດແອດມັນໃຫ້ຢູ່ໄດ້ແບບຖາວອນດ້ວຍການໄປເພີ່ມຟາຍໃນ

/etc/sysconfig/network-scripts/route-em3

ແລ້ວແອດແຖວລຸ່ມນີ້ເຂົ້າໄປ

10.5.1.0/28 via 172.23.1.1 dev em3

ລອງ restart ເຊີເວີ້ເບິ່ງກະໄດ້ ແຕ່ຄືຊິບໍ່ຈຳເປັນຕີ້ :p

Wednesday, March 21, 2018

ເພີ່ມ user ໃນ Cent OS


login ເຂົ້າໃນເຄື່ອງທີ່ຕ້ອງການແອດດ້ວຍສິດ root

# adduser username

ຕັ້ງລະຫັດຜ່ານ
# passwd username

ຈະຟ້ອງຂຶ້ນມາໃຫ້ໃສ່ລະຫັດ ໃສ່ໃຫ້ຄືກັນທັງສອງເທື່ອ
Changing password for user username.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

ແອດໃສ່ໃນກຸ່ມ wheel, ຄ່າເລີ່ມຕົ້ນໃນ CentOS, ສະມາຊິກທີ່ຢູ່ໃນ wheel group ຈະມີ sudo privileges.

usermod -aG wheel username

ທົດລອງດ້ວຍການລອງລ໋ອກອິນຜ່ານ ຍູສເຊີ້ ທີ່ສ້າງຂື້ນໃຫມ່

su - username

ຫລັງຈາກນັ້ນກໍ່ລອງຄຳສັ່ງປະເພດທີ່ຕ້ອງການສິດ root

[root@Prime01 ~]# su - smsc

[smsc@Prime01 ~]$ ls /root
ls: cannot open directory /root: Permission denied

[smsc@Prime01 ~]$ sudo ls /root

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for smsc:
anaconda-ks.cfg
[smsc@Prime01 ~]$ exit
logout

ຕັ້ງ username ໃຫ້ອຸປະກອນ Cisco



Switch> enable
Switch# configure terminal
Switch(config)# enable password example102
ຫລື
Switch(config)# enable secret level 1 password zaq1xsw23edcvfr4
Switch(config)# service password-encryption
Switch(config)# end
Switch# copy running-config startup-config


ປິດບໍໃຫ້ສາມາດກູ້ຄືນລະຫັດໄດ້
Switch(config)# system disable password recovery switch all

ພື້ນຖານການເປີດ/ປິດ telnet ແລະ ເປີດ SSH ໃຫ້ອຸປະກອນ Cisco

ເປີດ telnet

router#conf t
router(config)#line vty 0 4
router(config-line)#
router(config-line)#password
router(config-line)#login
router(config-line)#end
router#



ເປີດ SSH

Switch> enable
Switch# configure terminal
Switch(config)# hostname your_hostname
Switch(config)# ip domain-name  your_domain
Switch(config)# crypto key generate rsa
Switch(config)# ip ssh version 1
Switch(config)# ip ssh timeout 90 authentication-retries 2
Switch(config)# aaa new-model
Switch(config)# aaa authentication login default local
Switch(config)# aaa authorization exec local
Switch(config)# aaa authorization network local
Switch(config)# username your_user_name privilege 15 password 7 hehehehehhe
Switch(config)# end
Switch# wr

ປີດ telnet

RT01#     conf t
RT01(config)#line vty 0 4
RT01(config-line)#transport input ssh
RT01(config-line)#exit
RT01(config)#end

Tuesday, March 20, 2018

ຕັ້ງຄ່າ Management IP ໃຫ້ກັບ Router Cisco ASR 1001

ໃນບັນດາ Router ລຸ້ນໃຫມ່ຂອງ Cisco ໄດ້ມີການເພີ່ມຄວາມປອດໄພເພິ່ມເຕີມມາໃຫ້ management port ຄືແຍກອອກມາຈາກ traffic  ຂອງ global config ເຮັດໃຫ້ຕອງໄດ້ອານຸຍາດ routing ແລະ interface policy ຕ່າງຫາກ

ASR 1001:
Router#config t
Router(config)#interface gigabitethernet0
Router(config-if)#ip address A.B.C.D A.B.C.D
ip route vrf Mgmt-intf 0.0.0.0 0.0.0.0  1.1.1.1 (destination IP)

ຫລັງຈາກນັ້ນແມ່ນເຊື່ອມຕໍ່ ສາຍເນັກເວີກເຂົ້າຫາ switch ຜ່ານ vlan ຫລື ໄອພີວົງດຽວກັນ.

Monday, March 12, 2018

ທຳຄວາມເຂົ້າໃຈກັບ ການໃຊ້ prefix list ໃນ Cisco router

ຄຳສັ່ງ prefix list ກໍຄືກັນກັບ access list ທີ່ໃຊ້ສຳຫລັບເລືອກປະກາດ route (prefixes) ຫລືການກັ່ນຕອງ route ຈຸດເດັ່ນຂອງ prefix list ທີ່ເຫນືອກ່ວາ access list ຄືມັນມີຄວາມຍືດຍຸ່ນໃນການກຳຫນົດຄ່າ ip ແລະ network ຕ່າງໆ ລວມເຖິງຂຽນຄຳສັ່ງໄດ້ສັ້ນກ່ວາ ແຕ່ເຮົາກໍຕ້ອງໄດ້ມາທຳຄວາມເຂົ້າໃຈໃນເລື່ອງ syntax ແລະ options ຕ່າງໆ ເພີ່ມເຂົ້າມາຕື່ມ
ການເອົາ prefix list ແລະ access list ໄປໃຊ້ວຽກຕ່າງໆມີຫລາກຫລາຍກັນໄປຕາມຫນ້າງານເຊັ່ນ
  • redistribute route ລະຫວ່າງ routing protocol ຕ່າງໆ
  • route advertisements : ໃຊ້ route-map ເພື່ອປະກາດ route ແລະ filter route ໄປຫາ bgp neighbors ຕ່າງໆ
ຂັ້ນຕອນພື້ນຖານໃນການ match route 
  1. ສ້າງລາຍການ ip prefix-list
  2. ສ້າງເງື່ອນໄຂ route-map ໂດຍອ້າງອີງຈາກ prefix list 
  3. ເອົາ route-map ທີ່ສ້າງຂື້ນໄປ apply ໃຊ້ເພື່ອ control routing ຫລື filter route ຕາມຕ້ອງການ

ຄຳສັ່ງລາຍລະອຽດ syntax ຂອງ prefix list

ຂຽນໃນໂຫມດ Global Configuration
ip prefix-list name [ seq number ] { permit | deny } prefix [ eq length | [ ge length ] [ le length ]]
name – ຊື່ຂອງ IP prefix list ເປັນ alphanumeric string ໄດ້ສູງສຸດ 63 characters.
seq number – (Optional) ລຳດັບ order ຂອງລາຍການໃນ prefix list name ດ້ານເທິງເປັນຄ່າໂຕເລກລະຫວ່າງ 1 ຫາ 4294967294.
permit – ອາຍຸຍາດ routes ຫລື ip packets ທີ່ກົງກັບ prefix ດ້ານລຸ່ມ
deny – ບໍ່ອານຸຍາດ routes ຫລື ip packets ທີ່ກົງກັບ prefix ດ້ານລຸ່ມ
prefix – IP prefix ຮູບແບບຂອງ A.B.C.D/length
eq length – (Optional) ລະບຸຈຳນວນຂອງ prefix length ທີ່ຕ້ອງການ match ເປັນຄ່າຕົວເລກລະຫວ່າງ 1 ຫາ 32
ge length – (Optional) ລະບຸຈຳນວນຂອງ prefix length ທີ່ຕ້ອງການ match ເປັນຄ່າຕົວເລກລະຫວ່າງ 1 ຫາ 32
le length – (Optional) ລະບຸຈຳນວນຂອງ prefix length ທີ່ຕ້ອງການ match ເປັນຄ່າຕົວເລກລະຫວ່າງ 1 ຫາ 32
ກໍລະນີທີ່ບໍ່ມີຫຍັງໃນ prefix-list match ເລີຍມັນຈະເປັນ implicit deny ຫລືອະທິບາຍງ່າຍໆຄືມັນຈະ deny ຫມົດນັ້ນເອງ

Related Commands ກ່ຽວກັບ prefix list

  • clear ip prefix-list ສຳຫລັບ Clears counters ຂອງ prefix list
  • prefix-list ໄວ້ສຳຫລັບ applies a prefix list ໃນ BGP peer.
  • show ip prefix-list ເບິ່ງຂໍ້ມູນກ່ຽວກັບ ip prefix list  ທີ່ປະກາດເອົາໄວ້ທີ່ Global Configuration
ປຽບທຽບການເຮັດ access list ແລະ prefix list ຕອນເອົາໄປໃຊ້

ip access-list extended OSPF_Redist
 deny ip host 10.0.0.0 host 255.255.255.0
 permit ip any any
!
route-map OSPF-to-BGP permit 10
 match ip address OSPF_Redist
ip prefix-list OSPF_Redist seq 5 deny 10.0.0.0/24
ip prefix-list OSPF_Redist seq 10 permit 0.0.0.0/0 le 32
!
route-map OSPF-to-BGP permit 10

 match ip address prefix-list OSPF_Redist


ຈາກຄຳສັ່ງ extended access-list ດ້ານເທິງ ພົບວ່າ
  • deny ip host 10.0.0.0 host 255.255.255.0 ຂຽນໃນຮູບແບບ prefix-list ເປັນ deny 10.0.0.0/24
  • permit ip any any ຂຽນໃນຮູບແບບ prefix-list ເປັນ permit 0.0.0.0/0 le 32

ຕົວະຢ່າງການໃຊ້ Extended ACLs ສຳຫລັບ BGP Filtering

The source portion of the extended ACL is used to match the network portion of the BGP route
and the destination portion of the ACL is used to match the subnet mask of the BGP route.
ດ້ານລຸ່ມນີ້ຄືຄຳອະທິບາຍຕົວຢ່າງການໃຊ້ extended ACL 
access-list 100 permit ip 10.0.0.0  0.0.0.0  255.255.0.0  0.0.0.0
Matches 10.0.0.0/16 – Only
access-list 100 permit ip 10.0.0.0  0.0.0.0  255.255.255.0  0.0.0.0
Matches 10.0.0.0/24 – Only
access-list 100 permit ip 10.1.1.0  0.0.0.0  255.255.255.0  0.0.0.0
Matches 10.1.1.0/24 – Only
access-list 100 permit ip 10.0.0.0  0.0.255.0  255.255.255.0  0.0.0.0
Matches 10.0.X.0/24 – Any number in the 3rd octet of the network with a /24 subnet mask.
access-list 100 permit ip 10.0.0.0  0.255.255.0  255.255.255.0  0.0.0.0
Matches 10.X.X.0/24 – Any number in the 2nd & 3rd octet of the network with a /24 subnet mask.
access-list 100 permit ip 10.0.0.0  0.255.255.255  255.255.255.240  0.0.0.0
Matches 10.X.X.X/28 – Any number in the 2nd, 3rd & 4th octet of the network with a /28 subnet mask.
access-list 100 permit ip 10.0.0.0  0.255.255.255 255.255.255.0  0.0.0.255
Matches 10.X.X.X/24 to 10.X.X.X/32 – Any number in the 2nd, 3rd & 4th octet of the network with a /24 to /32 subnet mask.
access-list 100 permit ip 10.0.0.0  0.255.255.255  255.255.255.128  0.0.0.127
Matches 10.X.X.X/25 to 10.X.X.X/32 – Any number in the 2nd, 3rd & 4th octet of the network with a /25 to /32 subnet mask

ເຮົາມາເບິ່ງ Class A, B, C ວ່າສະມາດຂຽນໃນຮູບແບບ prefix list ໄດ້ແບບໃດ?

ມາໄລ່ເບິ່ງລຳດັບ Octet ຂອງ ipv4 32 bit ໂດຍແບ່ງເປັນ 4 ຊຸດ ຊຸດລະ 8 bit ແລ້ວຄັ້ນດ້ວຍຈຸດຈະໄດ້ດັ່ງນີ້
Class       Octet#1          Octet#2     Octet#3      Octet#4        Subnet Mask
Class A    0xxxxxxxx     Host              Host               Host              255.0.0.0
Class B    10xxxxxxx     Network       Host               Host              255.255.0.0
Class C    110xxxxx       Network        Network        Host             255.255.255.0
ມີຄ່າເປັນເລກຖານສິບ ຫາກເບິ່ງເປັນເລກຖານສິບຈະໄດ້ IP address ທີ່ມີ octet ທຳອິດ
Class A – 1 ຫາ 126 (ຖານສອງ 00000001 – 01111111)
Class B – 128 ຫາ 191 (ຖານສອງ 10000001 – 10111111)
Class C – 192 ຫາ 223 (ຖານສອງ 11000001 – 11011111)
ຂຽນເປັນ classful subnet ໄດ້ດັ່ງນີ້
ip prefix-list CLASS_A permit 0.0.0.0/1 ge 8 le 8
ip prefix-list CLASS_B permit 128.0.0.0/2 ge 16 le 16
ip prefix-list CLASS_C permit 192.0.0.0/3 ge 24 le 24
default route ຂຽນໄດ້ເປັນ 0.0.0.0/0
any routes ( ທຸກໆ route) ຂຽນໄດ້ເປັນ 0.0.0.0/0 le 32 ຄືກວດ 0 bits  ເຊິ່ງແປວ່າບໍ່ກວດຫຍັງເລີຍ subnet mark ເປັນໄດ້ຕັ້ງແຕ່ 32 bits ຫລືນ້ອຍກ່ວາໄລ່ໄປ /31 /30 /29 …

 ອະທິບາຍການໃຊ້ le ແລະ ge ຂອງ prefix-list ເພີ່ມເຕີມ

A.B.C.D/LEN ge GE le LE – ເມື່ອໃຊ້ le ຫລື ge ກໍມີເງື່ອນໄຂທີ່ວ່າ LEN < GE <= LE
ຕົວຢ່າງ
1) ip prefix-list example-1 seq 10 permit 172.16.0.0/16 ge 24 le 26 
– ຈາກຄຳສັ່ງດ້ານເທິງກວດ bit ຂອງ network /16 ວ່າ match ຫລືບໍ່ ?
– ຈາກນັ້ນໄປເບິ່ງ subnet mask ວ່າຢູ່ລະຫວ່າງ 24 ຫາ 26 ຫລືບໍ່ ?
ຄຳອະທິບາຍ
– ເປັນ class B network 172.16.0.0 (172.16.0.0/16) ທີ່ permit ສະເພາະ subnets with a /24, /25 ຫລື /26 mask (ge 24 le 26)

– ສ່ວນ network 172.16.0.0/16 ບໍ່ match ເພາະວ່າບໍ່ໄດ້ມີ mask ເປັນ /24, /25 ຫລື /26.
2) ip prefix-list example-1 seq 10 permit 10.10.10.0/24 ge 28
– ຫາກຄຳສັ່ງມີລະບຸສະເພາະ ge (ບໍ່ມີການລະບຸ le) ຫມາຍເຖິງຫລາຍກ່ວາຫລືເທົ່າກັບຈົນຮອດ /32
– ໃນກໍລະນີທີ່ທຸກ subnet within the 10.10.10.0/24 ທີ່ມີ subnet mask (/28 ถึง /32) ລະຫວ່າງ 255.255.255.240 ຫາ  255.255.255.255
– ສ່ວນ 10.10.10.0/24 ບໍ່ match ເພາະບໍ່ໄດ້ມີ mask ເປັນ /28
3) ip prefix-list example-1 seq 10 permit 10.10.10.0/24 le 28
– ຫາກຄຳສັ່ງມີລະບຸສະເພາະ le (ບໍ່ມີການລະບຸ ge) ຫມາຍວ່າຫນ້ອຍກ່ວາຫລືເທົ່າກັບ ຈົນຮອດ /len ຫລື /24 ໃນກໍລະນີຄຳສັ່ງດ້ານເທິງ
– ໃນກໍລະນີຄືທຸກ subnet within the 10.10.10.0/24 ທີ່ມີ subnet mask (/24 ถึง /28) ລະຫວ່າງ 255.255.255.0 ຫາ 255.255.255.240
– ສ່ວນ 10.10.10.0/24 match ນຳ
4) ກໍລະນີຕ້ອງການລວມ network 172.16.8.x/28 5 networks ຄວນຂຽນ prefix list ແບບໃດ ?
172.16.8.0/28
172.16.8.16/28
172.16.8.32/28
172.16.8.48/28
172.16.8.64/28
ແບ່ງ octet ທີ່ 4 ມາເບິ່ງ
0 — 0 0 0 0 0 0 0 0
16 – 0 0 0 1 0 0 0 0
32 – 0 0 1 0 0 0 0 0
48 – 0 0 1 1 0 0 0 0
64 – 0 1 0 0 0 0 0 0
ຈະໄດ້ 172.16.8.0/25 ge 28 le 28 
ທີ່ເປັນ
 /25 ເພາະບິດທີ່ 25 ຍັງຄືກັນ (172.16.8 ອັນນີ້ຄື 24 ບິດທີ່ຄືກັນ)
ອ້າງອີງຈາກ