| 단계별 | 예제 코드 | 설명 |
| PC 설정 | PC0 IP: 1.1.1.2 subnet mask: 255.255.255.0 GW: 1.1.1.1
PC1 IP: 1.1.1.3 subnet mask: 255.255.255.0 GW: 1.1.1.1
PC2 IP: 2.2.2.2 subnet mask: 255.255.255.0 GW: 2.2.2.1
PC3 IP: 3.3.3.2 subnet mask: 255.255.255.0 GW: 3.3.3.1 | |
| R1 설정 | Router# conf t Router(config)# hostname R1
R1(config)# int gi0/0 R1(config-if)# ip add 1.1.1.1 255.255.255.0 R1(config-if)# no shut R1(config-if)# exit
R1(config)# int s0/2/0 R1(config-if)# ip add 203.230.7.1 255.255.255.252 R1(config-if)# no shut R1(config-if)# exit
R1(config)# int s0/2/1 R1(config-if)# ip add 203.230.7.10 255.255.255.252 R1(config-if)# no shut R1(config-if)# exit
R1(config)# router ospf 1 R1(config-router)# network 1.1.1.1 0.0.0.0 area 0 R1(config-router)# network 203.230.7.1 0.0.0.0 area 0 R1(config-router)# network 203.230.7.10 0.0.0.0 area 0 | |
| R2 설정 | Router# conf t Router(config)# hostname R2
R2(config)# int gi0/0 R2(config-if)# ip add 2.2.2.1 255.255.255.0 R2(config-if)# no shut R2(config-if)# exit
R2(config)# int s0/2/0 R2(config-if)# ip add 203.230.7.5 255.255.255.252 R2(config-if)# no shut R2(config-if)# exit
R2(config)# int s0/2/1 R2(config-if)# ip add 203.230.7.2 255.255.255.252 R2(config-if)# no shut R2(config-if)# exit
R2(config)# router ospf 1 R2(config-router)# network 2.2.2.1 0.0.0.0 area 0 R2(config-router)# network 203.230.7.5 0.0.0.0 area 0 R2(config-router)# network 203.230.7.2 0.0.0.0 area 0 | |
| R3 설정 | Router# conf t Router(config)# hostname R3
R3(config)# int gi0/0 R3(config-if)# ip add 3.3.3.1 255.255.255.0 R3(config-if)# no shut R3(config-if)# exit
R3(config)# int s0/2/0 R3(config-if)# ip add 203.230.7.9 255.255.255.252 R3(config-if)# no shut R3(config-if)# exit
R3(config)# int s0/2/1 R3(config-if)# ip add 203.230.7.6 255.255.255.252 R3(config-if)# no shut R3(config-if)# exit
R3(config)# router ospf 1 R3(config-router)# network 3.3.3.1 0.0.0.0 area 0 R3(config-router)# network 203.230.7.9 0.0.0.0 area 0 R3(config-router)# network 203.230.7.6 0.0.0.0 area 0 | |
PC0 제외설정 표준 ACL 설정 | R1(config)# access-list 1 deny 1.1.1.2 0.0.0.0 R1(config)# access-list 1 permit any
R1(config)# int gi0/0 R1(config-if)# ip access-group 1 in R1(config-if)# ^Z R1# wr | PC0(1.1.1.2)의 출발지 패킷은 제외하고 나머지 허용 |
PC1 허용설정 표준 ACL 설정 | R1(config)# access-list 1 permit 1.1.1.3 0.0.0.0 R1(config)# access-list 1 deny any
R1(config)# int gi0/0 R1(config-if)# ip access-group 1 in R1(config-if)# ^Z R1# wr | PC1(1.1.1.3)의 출발지 패킷은 허용하고 나머지 제외 |
| ACL 동작 상태 확인 | R1# show access-list 1
Standard IP access list 1 Permit host 1.1.1.3 (4 match(es)) (출발지 주소 패킷 4개 허용) deny any (4 match(es)) (그외 주소에서 나온 4개 패킷들은 버림) | |
| ACL 주석문(Remark) 설정 | R1(config)# access-list 1 remark PC0 packet deny and PC1 packet permit
R1(config)# do show run
access-list 1 remark PC0 packet deny and PC1 packet permit
| |
| 와일드카드 마스크(Wildcard mask) | 와일드카드 마스크는 서브넷 마스크의 반대되는 값 서브넷 마스크 와일드카드 마스크 255.255.225.0 0.0.0.255
짝수 IP 주소값 지정: 2032230.7.0 0.0.0.254 홀수 IP 주소값 지정: 2032230.7.1 0.0.0.254
네트워크 203.230.7.1/24 ~ 203.230.7.5/24만 정의하고자 한다면 203.230.7.0/29 로 서브넷 마스크 203.230.7.0 255.255.255.248 와일드카드마스크 203.230.7.0 0.0.0.7 | |
| ACL 문장구성 및 순서 | R1(config)# access-list 1 deny host 1.1.1.2 ① R1(config)# access-list 1 permit 1.1.1.0 0.0.0.255 ②
R1(config)# int gi0/0 R1(config-if)# ip access-list 1 in
PC0> ping 2.2.2.1 (불가) | ②의 목록을 첫 줄에 작성하고 ①을 둘째 줄에 작성하면 1.1.1.2가 외부와 통신하는 것을 막을 수 없음 |
| ACL을 이용한 원격 접속 제어 | R2(config)# access-list 1 permit host 1.1.1.2 ①
R2(config)# line vty 0 4 R2(config-line)# password cisco R2(config-line)# login
R2(config-line)# access-class 1 in
PC0> telnet 2.2.2.1 (R2에 접속 허용) PC1> telnet 2.2.2.1 (접속 불가) PC2> telnet 2.2.2.1 (접속 불가) PC3> telnet 2.2.2.1 (접속 불가) | ①을 설정한 후 “access-list 1 deny any” 명령어가 없어도 ACL이 “permit”으로 이루진 경우 “deny any”는 따로 선언하지 않아도 암묵적으로(implicit deny) 라우터에 정의됨 |
확장 ACL의 설정
PC0->R3 ping (x) | R1(config)# access-list 100 deny icmp host 1.1.1.2 host 203.230.7.9 echo R1(config)# access-list 100 deny icmp host 1.1.1.2 host 203.230.7.6 echo R1(config)# access-list 100 deny icmp host 1.1.1.2 host 3.3.3.1 echo R1(config)# access-list 100 permit ip any any
R1(config)# int gi0/0 R1(config-if)# ip access-group 100 in
PC0> ping 203.230.7.9 (불가) PC0> ping 203.230.7.6 (불가) PC0> ping 3.3.3.1 (불가) PC0> telnet 3.3.3.1 (접속 가능) | PC0가 R3으로 Ping 불가/ Telnet 접속 가능토록 R1에서 설정 |
확장 ACL의 설정
PC0->R3 ping 불가 | R3(config)# access-list 100 deny icmp host 1.1.1.2 host 203.230.7.9 echo R3(config)# access-list 100 deny icmp host 1.1.1.2 host 203.230.7.6 echo R3(config)# access-list 100 deny icmp host 1.1.1.2 host 3.3.3.1 echo R3(config)# access-list 100 permit ip any any
R3(config)# int se0/2/0 R3(config-if)# ip access-group 100 in R3(config-if)# exit
R3(config)# int se0/2/1 R3(config-if)# ip access-group 100 in | PC0가 R3으로 Ping 불가/ Telnet 접속 가능토록 R3에서 설정 |
확장 ACL의 설정
PC1->R2 텔넷 접속불가 | R1(config)# access-list 100 deny tcp host 1.1.1.3 host 203.230.7.2 eq telnet R1(config)# access-list 100 deny tcp host 1.1.1.3 host 203.230.7.5 eq telnet R1(config)# access-list 100 deny tcp host 1.1.1.3 host 2.2.2.1 eq telnet R1(config)# access-list 100 permit ip any any
R1(config)# int gi0/0 R1(config-if)# ip access-group 100 in
PC1> ping 2.2.2.1 (접속 성공) PC1> telnet 2.2.2.1 (접속 불가) | PC1만 R2에 Telnet 접속 불가로 R1에서 설정 |
Named 표준 ACL
PC0->모두 (0) PC1->모두 (x) | R1(config)# ip access-list standard infocomm R1(config-std-nalc)# permit host 1.1.1.3 R1(config-line)# deny any R1(config-line)# exit
R1(config)# int gi0/0 R1(config-if)# ip access-group inforcomm in | PC0는 모든 장치에 통신 불가 PC1은 모든 장치에 통신 가능 |
Named 확장 ACL
PC0->R3 ping(x) 불가 telnet(o) 가능 | R1(config)# ip access-list extended ping R1(config-std-nalc)# deny icmp host 1.1.1.2 host 1.1.1.3 R1(config-std-nalc)# deny icmp host 1.1.1.2 host 203.230.7.6 R1(config-std-nalc)# deny icmp host 1.1.1.2 host 203.230.7.9 R1(config-std-nalc)# permit ip any any R1(config-std-nalc)# exit
R1(config)# int gi0/0 R1(config-if)# ip access-group ping in R1(config-if)# exit
R1(config)# do show access-lists (결과는 뒤 페이지) R1(config)# exit
PC0> ping 3.3.3.1 (불가) PC0> ping 203.230.7.6 (불가) PC0> ping 203.230.7.3 (불가) PC0> telnet 3.3.3.1 (접속 가능) | |