[KEDUIT] 클라우드 컴퓨팅과 보안솔루션을 활용한 DC 엔지니어 양성교육 - Day54
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
- ARP
- CDP / VLAN
- Frame Relay
- Static Routing
- VLAN
- VTP
- Routed Port
- AD
- Route Selection
- FHRP
- HSRP
- DHCP
- DNS
- STP
- NAT
- EtherChannel
- DTP
- RIP
- NTP
- Offset List
- Password Encryption
- ACL
- CAR Attack
- Broadcast
- Port Assignments
- IPv6 Static Routing
- HSRP for IPv6
- Clock Rate
- DHCPv6 Guard
- EIGRP
- Express Forwarding
- Routing and Switching
- Load Balancing
- Ping, Traceroute
- Load Balancing
- Fast Switching
- CEF
- DNS
- SSH
- Regular Expression
- OSPF
- EIGRP’s SIA
- NSSA
- AAA
2. Linux
- rhel9’s docs
- Linux Directory Structure
- File Types in Linux
- fstab
- Vim Cheat Sheet
- Protecting GRUB with a password
- SELinux
- DNS
- Samba as a server
- DHCP
- NFS
- SSH
- VNC
3. Web
- HTML’s Elements
- Emmet
- JavaScript
- Anchor Tag
- Post, Get
- Block, Inline Elements
- Semantic Web
- Semantic Elements
- CSS
- Viewport_meta_tag
- Media_queries
- JavaScript
4. DB
클라우드 엔지니어를 꿈꾸며 공부를 시작한 초보 엔지니어입니다. 틀린점 또는 조언해주실 부분이 있으시면 친절하게 댓글 부탁드립니다. 방문해 주셔서 감사합니다 :)
댓글남기기