본문 바로가기
네트워크

네트워크1 5차시

by 뭔가해보겠습니다 2024. 6. 15.

telnet
평문전송이 기본이므로 현재는 사용하지 않는다
최근에는 암호화 통신을 하는 ssh를 이용함

 

라우터에 원격 로그인 설정하는 법
- telnet
- ssh

콘솔 접속 : line console 0

원격 접속 : line vty 0 4
( 기본적으로 5개정도지만 더 많이 설정 가능. line vty 0 ? 하면 확인 가능 )

enable 비밀번호 설정
: enable password <비밀번호>

비밀번호 삭제

: no enable password

 

스위치 예시

Switch>enable

Switch#conf t

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#line console 0

Switch(config-line)#password cisco

Switch(config-line)#login

 

스위치와 랩탑(노트북)을 console로 연결한 후(RS232 --- Console), 터미널을 통해 들어가면 password를 묻는다

 

삭제

Switch>en

Switch#conf t

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#line console 0

Switch(config-line)#no login

 

스위치에 시간 설정하기

Switch>en

Switch#conf t

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#line console 0

Switch(config-line)#exec-timeout 5 0

=>  5분동안 미입력시 로그아웃됨

3초로 설정후 저절로 로그아웃됨

삭제

no exec-timeout

 

vty line : 텔넷 설정. 기본값이 없다

비밀번호 설정
line vty 0
password 비밀번호

 

예시

Switch>en

Switch#conf t

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#line vty ?

<0-15> First Line number

Switch(config)#line vty 0 4

Switch(config-line)#password cisco

 

=> ? 로 번호 숫자 확인한뒤, 범위를 잡아주고 비밀번호 설정

 

telnet을 사용하려면
스위치에 ip주소와 telnet 설정, 패스워드 설정이 되어 있어야 한다 

 

IP 주소 설정

int vlan number

ip add ip주소 서브넷마스크

예시

Switch(config)#

Switch(config)#int vlan 1

Switch(config-if)#ip add 10.10.10.2 255.255.255.0

Switch(config-if)#no sh

PC0 터미널에서 telnet을 통해 접속

 

 

enable 비밀번호 설정

enable secret

차이점 : enable secret은 비밀번호가 암호화되어 보인다

 

라우터 설정

Router>en

Router#conf t

Enter configuration commands, one per line. End with CNTL/Z.

Router(config)#hostname R1

R1(config)#no ip domain-lookup

R1(config)#enable secret cisco

R1(config)#line con 0

R1(config-line)#no ip domain-lookup

R1(config)#password cisco

^

% Invalid input detected at '^' marker. 갑자기 왜 나가졌을까?

R1(config)#no ip domain-lookup

R1(config)#line con 0

R1(config-line)#password cisco

R1(config-line)#login

R1(config-line)#end

R1(config)#line vty 0 4

R1(config-line)#password cisco

R1(config-line)#exit

R1(config)#int g0/0

R1(config-if)#ip add 10.10.10.1 255.255.255.0

R1(config-if)#no sh

%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up

R1(config-if)#end

 

=> 호스트이름 설정, 비밀번호 설정, line console 비밀번호 설정, vty telnet 설정 후 no sh

 

설정확인

R1#sh ip int b

Interface IP-Address OK? Method Status Protocol

GigabitEthernet0/0 10.10.10.1 YES manual up up

-

R1#sh run

Building configuration...

 

Current configuration : 727 bytes

!

version 15.1

no service timestamps log datetime msec

no service timestamps debug datetime msec

no service password-encryption

!

hostname R1

!

!

!

enable secret 5 $1$mERr$hx5rVt7rPNoS4wqbXKX7m0

=> secret로 암호화된 비밀번호

 

스위치에 사용자를 생성해서 로그인하기
username 사용자명 secret 비밀번호

 

예시

Switch#conf t

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#no ip domain-lookup

Switch(config)#hostname SW1

SW1(config)#enable secret cisco

The enable secret you have chosen is the same as your enable password.

This is not recommended. Re-enter the enable secret.

SW1(config)#int vlan 1

SW1(config-if)#ip add 10.10.10.2 255.255.255.0

SW1(config-if)#no sh

SW1(config-if)#exit

SW1(config)#username admin secret cisco

SW1(config)#line vty 0 4

SW1(config-line)#password cisco

SW1(config-line)#login local

SW1(config-line)#exit

=> 설정모드 들어가서, 호스트명 설정하고, 관리자 비밀번호 설정하고, vlan ip 설정하고, user 생성하고, telnet 설정

 

아이디와 비밀번호를 묻는다

 

+ transport input telnet : 텔넷 접속시도를 받아줌

+ transport input ssh : ssh 접속시도를 받아줌

 

 

ssh 설정하기

 

기본

Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#no ip domain-lookup
Router(config)#username admin secret cisco
Router(config)#enable secret sisco
Router(config)#line con 0
Router(config-line)#login local
Router(config-line)#exec-time 5 0
Router(config-line)#hostname R2
R2(config)#line vty 0 4
R2(config-line)#login local
R2(config-line)#int g0/0
R2(config-if)#ip add 10.10.20.1 255.255.255.0
R2(config-if)#no sh

 

 

ssh 설정 추가

1) 도메인 설정 & RSA 공개키 생성
2) ssh 버전 2 선택
3) 원격 접속 허용

R2(config)#crypto key generate rsa
% Please define a domain-name first.
=> 도메인을 설정하지 않은 경우


R2(config)#ip domain-name testmaster.net
R2(config)#crypto key generate rsa
The name for the keys will be: R2.testmaster.net
Choose the size of the key modulus in the range of 360 to 2048 for your
General Purpose Keys. Choosing a key modulus greater than 512 may take
a few minutes.
How many bits in the modulus [512]: 2048
% Generating 1024 bit RSA keys, keys will be non-exportable...[OK]

R2(config)#ip ssh version 2
*Mar 1 2:27:9.38: %SSH-5-ENABLED: SSH 1.99 has been enabled

R2(config)#line vty 0 4
R2(config-line)#transport input ssh
R2(config-line)#login local

 

참고: 
  . https://cafe.naver.com/linuxmasternet/478
  . https://cafe.naver.com/linuxmasternet/32092

 

접속 ( ssh -l 사용자명 ip주소 )

C:\>ssh -l admin 10.10.20.1
Password:

R2>

 

transport input ssh 명령어 효과

C:\>telnet 10.10.20.1
Trying 10.10.20.1 ...Open

[Connection to 10.10.20.1 closed by foreign host]

=> ssh만 받아들이고 telnet은 거부

 

라우터간 네트워크 10.10.30.0 추가

왼쪽 라우터에 int g0/1로 ip add 해주고
오른쪽 라우터에도 int g0/1로 ip add 해주어야 연결됨

( 하지만 10.10.10.2 PC에서 10.10.10.1 스위치 -> 10.10.30.1 R1 -> 10.10.30.1 R2 이렇게 거쳐서 10.10.20.2 PC로 가게 하려면 추가 설정 필요 )

 

R1(config)#ip route 10.10.20.0 255.255.255.0 10.10.30.2

R2(config)#ip route 10.10.10.0 255.255.255.0 10.10.30.1

=> 20.0 대역으로 갈 때는 30.2 R2로 보내고

10.0 대역으로 갈 때는 30.1 R1으로 보내는 정적 라우팅 설정

 

# do sh ip route

Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP

...

Gateway of last resort is not set

10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks

S 10.10.20.0/24 [1/0] via 10.10.30.2

=> static 정적 라우팅 확인

 

VLAN
물리적인 네트워크에 상관없이 논리적으로 네트워크를 분할하는 기술. 가상랜.

고유 식별자인 VLAN ID를 가지며 ID를 사용하여 스위치에서 패킷을 분류하고 전송
1부터 4094까지 선택

보통 VLAN 1이 기본 VLAN으로 사용된다

 

VLAN 스위치 두 가지 포트 유형
- 액세스 Access
- 트렁크 Trunk

 

SW1# sh vlan b

VLAN Name Status Ports

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

1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4, ... Fa0/24

10 VLAN0010 active

20 VLAN0020 active

1002 fddi-default active

1003 token-ring-default active

1004 fddinet-default active

1005 trnet-default active

 

삭제

SW1(config)#no vlan 10

SW1(config)#no vlan 20

SW1(config)#end

SW1# sh vlan b

VLAN Name Status Ports

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

1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4, ... Fa0/24

1002 fddi-default active

1003 token-ring-default active

1004 fddinet-default active

1005 trnet-default active

 

이름설정

SW1(config)#vlan 10

SW1(config-vlan)#name v10

SW1(config-vlan)#do sh vlan b

VLAN Name Status Ports

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

1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4, ... Fa0/24

10 v10 active

1002 fddi-default active

1003 token-ring-default active

1004 fddinet-default active

1005 trnet-default active

 

 

'네트워크' 카테고리의 다른 글

네트워크1 8차시  (0) 2024.06.23
네트워크1 6차시  (0) 2024.06.16
네트워크1 4차시  (0) 2024.06.09
네트워크1 3차시  (0) 2024.06.08
네트워크1 2차시  (0) 2024.06.02