2 분 소요

1. 서론

    오늘은 파이썬 수업 마지막이었다.

2. 본론

1. Python

# 1. Sort
import operator

trainDic = {'Tomas':'토마스', 'Edward':'에드워드', 'Henry':'헨리', 'Gothen':'고든', 'James':'제임스'}

trainList = sorted(trainDic.items(), key=operator.itemgetter(0))

print(trainList)

# 2. 사전형 활용
foodMatching = {'파전':'전통주', '치킨':'맥주', '삼겹살':'소주', '피자':'와인'}

while(True):
    choice=input(str(list(foodMatching.keys())) + '중 좋아하는 음식은? \n 끝내고 싶으면 "끝" 을 입력해주세요. ')
    if choice in foodMatching.keys():
        print(f'{choice}과 궁합이 좋은 술은 {foodMatching[choice]}입니다.')
    elif choice == '끝':
        break
    else:
        print('선택하신 음식은 궁합 리스트에 없습니다. 다시한번 확인해 보세요')

# 3. set
myset = {1, 2, 3, 3, 3, 4, 4}
print(myset)
myset = [1, 2, 3, 3, 3, 4, 4]
print(myset)
print(set(myset))
myset1 = {1, 2, 3, 4}
myset2 = {4, 5, 6, 7}
# 교집합
print(myset1 & myset2)
# 합집합
print(myset1 | myset2)
# 차집합
print(myset1 - myset2)
# 대칭차집합
print(myset1 ^ myset2)

# 4. List Comprehension
numList = [num for num in range(1,101) if num % 3 == 0]
print(numList)

# 5. Zip
num1 = ['1', '2', '3', '4', '5', '6']
num2 = ['7', '8', '9']
tupList = list(zip(num1, num2))
dic = dict(zip(num1, num2))
print(tupList)
print(dic)

# 6-1. Shallow copy(메모리 공유)
num1 = ['1', '2', '3', '4', '5', '6']
num3 = num1
num3[0] = 10
num3.append(100)
print(num1)

# 6-2. Deep copy
num1 = ['1', '2', '3', '4', '5', '6']
num3 = num1[:]
num3[0] = 10
num3.append(100)
print(num1)
print(num3)

# 7. 함수활용
ss = "이제곧주말"
sslen = len(ss)
for i in range(0, sslen):
    print(ss[i] + "$", end='')

# 8. 로또
import random
def getNum():
    return random.randrange(1, 46)

lotto = []
num = 0

while True:
    num = getNum()

    if lotto.count(num) == 0:
        lotto.append(num)

    if len(lotto) >= 6:
        lotto.sort()
        break

print(f"추첨된 로또 번호는 {lotto}입니다.")

# 9. Python with mysql
import pymysql

con, cur = None, None
memberID, memberName, memberAddress = "", "", ""
sql = ""

con = pymysql.connect(
    host="127.0.0.1",
    user="root",
    port=3306,
    passwd="1234",
    db="shopdb",
    charset="utf8")
cur = con.cursor()

while True:
    memberID = input("사용자ID : ")
    if memberID == '':
        break
    memberName = input("사용자이름 : ")
    memberAddress = input("사용자주소 : ")

    sql = f"INSERT INTO memberTbl VALUES ({memberID}, {memberName}, {memberAddress})"
    cur.execute(sql)

con.commit()

cur.execute("SELECT * FROM memberTbl")

while True :
    row = cur.fetchone()
    if row == None :
        break
    memberID = row[0]
    memberName = row[1]
    memberAddress = row[2]
    print(f"{memberID}, {memberName}, {memberAddress}")

con.close()

2. Network

1. privilege 레벨별 명령어 설정
//ASW1
# line c 0
# no privilege level 15
!
# enable secret ccie
# enable secret level 2 ccie2
# enable secret level 3 ccie3
# privilege exec level 2 show running-configure
# privilege exec level 3 configure terminal
# privilege exec level 3 interface
# privilege exec level 3 ip address

2. 콘솔 로그인시 유저네임 설정
# line c 0
# login local
!
# username admin2 privilege 2 password ccna2

3. telnet 접속시 유저네임 설정
# vlan 230
!
# int vlan 230
# ip add 192.168.10.11 255.255.255.0
!
# line vty 0 4
# login local

4. SSH
//DSW1
# ip domain-name kedu.edu
# crypto key generate rsa
# ip ssh version 2
!
# line vty 0 4
# transport input ssh
# login local
!
# line c 0
# login local
!
# username admin password cisco

5. AAA(Authentication, Authorization, and Accounting) with TACACS+
//Win2016
Administration Control -> admin -> Set Password + Grant all -> submit
Network Configuration -> Add AAA Client -> Authenticate using(TACACS+) + Single Connect TACACS+ AAA Client

//DSW1
# aaa new-model
# tacacs-server host 192.168.50.103 single-connection key 1234
# aaa authentication login default tacacs+ group local
!
# test aaa group tacacs+ admin100 1234 legacy
!
# no aaa authentication login default group tacacs+ group local
# aaa authentication login VTY_ACC group tacacs+ group local
!
# line vty 0 4
# login authentication VTY_ACC
# username admin15 privilege 15 password cisco123
!
# aaa authorization exec VTY_PRI group tacacs+ local
# aaa authorization command 15 VTY_PRI group tacacs+ local
!
# line vty 0 4
# authorization exec VTY_PRI
# authorization commands 15 VTY_PRI

//Win2016
Interface Configuration -> TACACS+ -> Shell(exec) on User(Check)
Interface Configuration -> Advanced Options -> Per-user TACACS+/RADIUS Attributes(Check)
User Setup -> admin100 -> TACACS+ Settings -> Shell(exec) + Privilege level(15)
                       -> Shell Command Authorization Set -> Per User Command Authorization(permit)
User Setup -> monitor -> command에 체크하고 configure 추가

//DSW1
# aaa accounting exec ACC start-stop group tacacs+
# aaa accounting commands 15 ACC start-stop group tacacs+
!
# line cty 0 4
# accounting exec ACC
# accounting commands 15 ACC

3. 결론

    벌써 주말이다.

4. 참고자료

1. Cisco Docs

  1. ARP
  2. CDP / VLAN
  3. Frame Relay
  4. Static Routing
  5. VLAN
  6. VTP
  7. Routed Port
  8. AD
  9. Route Selection
  10. FHRP
  11. HSRP
  12. DHCP
  13. DNS
  14. STP
  15. NAT
  16. EtherChannel
  17. DTP
  18. RIP
  19. NTP
  20. Offset List
  21. Password Encryption
  22. ACL
  23. CAR Attack
  24. Broadcast
  25. Port Assignments
  26. IPv6 Static Routing
  27. HSRP for IPv6
  28. Clock Rate
  29. DHCPv6 Guard
  30. EIGRP
  31. Express Forwarding
  32. Routing and Switching
  33. Load Balancing
  34. Ping, Traceroute
  35. Load Balancing
  36. Fast Switching
  37. CEF
  38. DNS
  39. SSH
  40. Regular Expression
  41. OSPF
  42. EIGRP’s SIA
  43. NSSA
  44. AAA

2. Linux

  1. rhel9’s docs
  2. Linux Directory Structure
  3. File Types in Linux
  4. fstab
  5. Vim Cheat Sheet
  6. Protecting GRUB with a password
  7. SELinux
  8. DNS
  9. Samba as a server
  10. DHCP
  11. NFS
  12. SSH
  13. VNC

3. Web

  1. HTML’s Elements
  2. Emmet
  3. JavaScript
  4. Anchor Tag
  5. Post, Get
  6. Block, Inline Elements
  7. Semantic Web
  8. Semantic Elements
  9. CSS
  10. Viewport_meta_tag
  11. Media_queries
  12. JavaScript

4. DB

  1. MySQL

클라우드 엔지니어를 꿈꾸며 공부를 시작한 초보 엔지니어입니다. 틀린점 또는 조언해주실 부분이 있으시면 친절하게 댓글 부탁드립니다. 방문해 주셔서 감사합니다 :)

댓글남기기