Linux/Kali_Linux

virtualbox 네트워크 설정, centos 네트워크 / Virtualbox network setup, centos network setup

옥뀨 2020. 7. 6. 02:27

virtualbox 네트워크 설정을 해보자.

Let's set up a virtualbox network.

 

필자는 유선랜 사용보다 무선랜 사용을 많이 하기 때문에 유선랜 설정을 진행해보려 한다.

I use wireless LAN more than wired LAN, so I will try to set up wired LAN.

 

먼저 virtualbox에 네트워크 설정을 하고 centos에도 네트워크 설정을 해보도록 하겠다.

First, I'll set up a network on the virtualbox and network on the centos.

 

그리고 한글 입출력을 위해 터미널에서 ssh 연결을 해보겠다.

And I will try a ssh connection from the terminal for Hangul input/output.

 

네트워크 설정을 하기에 앞서 호스트 PC가 인터넷에 연결 되어있는지 확인해보자.

Before setting up the network, check if the host PC is connected to the Internet.

 

오른쪽 상단에 네트워크를 연결하는 항목이 있는데 네트워크 연결이 되어있지 않다면 연결을 해주어야 한다.

In the upper right, there is an item to connect the network, if there is no network connection, we need to connect.

 

virtualbox 네트워크 설정(1) / virtualbox network setup(1)

 

연결이 잘 되어있는 것을 확인하려면 "터미널에 접속"하여 "ip addr" 명령어를 입력해보자.

To verify that the connection is working, try entering "ip addr" command by "accessing the terminal".

 

간단하게 설명하고 넘어가자면 첫번째 "lo" 라고 써있는 부분은 자신의 로컬 ip 주소이며 "127.0.0.1" 이다.

In simple terms, the first, "lo" is our local ip address and is "127.0.0.1".

 

두번째 "wlan0" 는 "Wireless Lan0" 의 약자로 무선 네트워크를 의미한다.

The second "wlan0" is an abbreviation of "Wireless Lan0" and means a wireless network.

 

"inet" 부분에 "[숫자],[숫자].[숫자].[숫자]" 가 출력된다면 네트워크에 정상 연결된 것이다.

If "[number],[number].[number].[number]" is displayed in the "inet" section, the network is properly connected.

 

간단하게 네트워크에 연결되었는지 확인만 하고 넘어가자.

Simply check if we are connected to the network and let's move on.

 

$ ip addr

 

virtualbox 네트워크 설정(2) / virtualbox network setup(2)

 

먼저 virtualbox에 네트워크 설정을 해주자.

First, let's configure the network for the virtualbox.

 

왼쪽 상단에 "파일" 항목을 클릭한 후 "호스트 네트워크 관리자" 를 클릭해주자.

Click the "File" item in the upper left corner and then click "Host Network Manager".

 

virtualbox 네트워크 설정(3) / virtualbox network setup(3)

 

이제 네트워크를 하나 만들어 주겠다.

Now we will create a network.

 

지금 만드려는 네트워크는 호스트 네트워크와 게스트 네트워크를 연결해주기 위한 네트워크라고 이해하면 되겠다.

Understand that the network we will create is the one we create to connect the host and guest networks.

 

여기서 말하는 호스트 네트워크는 현재 설치되어 있는 칼리 리눅스 네트워크이고 게스트 네트워크는

centos 네트워크라고 이해하면 된다.

It is understood that the host network referred to here is the currently installed Kali Linux network

and the guest network is the centos network.

 

그림으로 표현하자면 이렇다.

I'll express it with pictures.

 

 

 

"만들기"를 눌러주자.

Click "Create".

 

virtualbox 네트워크 설정(4) / virtualbox network setup(4)

 

"vboxnet0" 라는 네트워크가 생성된 것을 볼 수 있다.

We can see that a network called "vboxnet0" has been created.

 

"속성" 을 클릭하여 설정을 진행해주자.

Click "Property" to proceed with the setting.

 

virtualbox 네트워크 설정(5) / virtualbox network setup(5)

 

어뎁터에 대해 간단하게 설명하면 호스트 네트워크와 통신하기 위해 필요한 주소값을 설정하는 항목이다.

If the adapter is briefly described, it is an item to set the address value required to communicate

with the host network.

 

그림으로 설명해주겠다.

I'll explain with pictures.

 

 

어댑터는 굳이 수정할 필요가 없으니 "DHCP 서버" 설정으로 넘어가 보자.

There is no need to modify it, so let's move on to the "DHCP Server" setting.

 

virtualbox 네트워크 설정(6) / virtualbox network setup(6)

 

서버주소 : 192.168.56.100

Server address: 192.168.56.100

 

자체적으로 대역 네트워크를 사용하겠다는 뜻이다.

This means that it will use its own band network.

 

서브넷 마스크 : 255.255.255.0

Subnet mask: 255.255.255.0

 

분할해서 사용하지 않고 네트워크를 통째로 쓰겠다는 뜻이다.

This means that the network will be used entirely without being divided.

 

최저 주소 한계 : 192.168.56.101

Minimum address limit: 192.168.56.101

 

최대 주소 한계 : 192.168.56.254

Maximum address limit: 192.168.56.254

 

왜 서버주소가 최저 주소 한계에 들어가지 않는지, 최대 주소 한계의 마지막 부분이 255가 아닌지,

서브넷 마스크란 무엇인지 등 여러 네트워크 개념에 대해선 네트워크 카테고리에서 다뤄보도록 하겠다.

I'll cover several network concepts in the Network category,

including why server addresses don't fall within the lowest address limit,

why the last part of the maximum address limit isn't 255, and what is a subnet mask.

 

설정만 하고 "적용" 버튼을 눌러주자.

Just set it up and click the "Apply" button.

 

virtualbox 네트워크 설정(7) / virtualbox network setup(7)

 

네트워크를 만들었으니 이제 centos에 네트워크를 적용시켜주자.

Now that we have a network, let's apply the network to centos.

 

"설정" 항목을 클릭하자.

Click on the "Settings" item.

 

virtualbox 네트워크 설정(8) / virtualbox network setup(8)

 

"네트워크" 항목을 클릭한 후 "어뎁터1" 설정을 해주자.

Click "Network" and set "Adapter1".

 

먼저 호스트 네트워크와 연결시켜준다.

First, let's connect to the host network.

 

"어댑터에 브리지" 항목을 선택하고 "virtualbox 네트워크 설정(2)" 사진에 보면 2번째 네트워크인 wlan0 과 연결시켜

주기 위해 "wlan0" 항목을 선택한다.

Select "bridge to adapter" and select "wlan0" to connect to wlan0.

 

virtualbox 네트워크 설정(9) / virtualbox network setup(9)

 

"어뎁터2" 를 선택한 후 아까 "virtualbox 네트워크 설정(5) 사진" 에서 만들어놓은 네트워크를 넣어주겠다.

After selecting "Adapter 2", we will set up the "vboxnet" network that we created earlier.

 

"호스트 전용 어뎁터" 선택 후 "vboxnet0"를 선택해주자.

Select "Host-only adapter" and then "vboxnet0".

 

설정이 완료되었으니 "확인" 버튼을 클릭해주자.

Now that the settings are complete, click the "OK" button.

 

virtualbox 네트워크 설정(10) / virtualbox network setup(10)

 

centos를 실행시켜주겠다. "시작" 버튼을 눌러주자.

Let me run centos. Click the "Start" button.

 

virtualbox 네트워크 설정(11) / virtualbox network setup(11)

 

"root" 로 로그인 해주자.

Let's log in as "root".

 

centos 네트워크 설정(1) / centos network settings(1)

 

"ip addr" 명령어를 입력해보자.

Try entering the "ip addr" command.

 

그리고 한가지 설명을 하자면 명령어 입력 줄에 보면 칼리 리눅스에선 명령줄 시작이 "$" 이었는데 centos에선 "#" 로 시작함을 볼 수 있다.

And to explain one thing, if we look at the command line,

we can see that the start of the command line was "$" in Kali Linux, but it started with "#" in centos.

 

일반 사용자일 땐 "$" 가 붙고 root 사용자일땐 "#" 로 시작함을 알고 있으면 되겠다.

If we are a regular user, we should know that "$" is started and if we are a root user, it starts with "#".

 

명령어를 입력하고 난 후 네트워크에 아무것도 출력이 안되는 것을 확인할 수 있다.

After entering the command, we can see that nothing is displayed on the network.

아직 설정이 완료된 것이 아니다.

Configuration is not complete yet.

centos에서도 네트워크 설정을 해주어야 한다.

we need to configure the network in centos.

 

# ip addr

 

centos 네트워크 설정(2) / centos network settings(2)

 

네트워크 설정을 할 수 있게 네트워크 설정이 들어있는 파일의 위치까지 이동해보자.

Let's move to the location of the file containing the network settings so that we can configure the network.

 

"cd" 명령어는 "Change Directory" 의 약자로 디렉토리 이동을 뜻한다.

The "cd" command is short for "Change Directory", which means moving the directory.

 

사용 형식은 "cd /디렉토리 명" 이다.

The format used is "cd /directory name".

 

/etc 파일은 설정에 관한 데이터가 저장된 디텍토리고 /sysconfig 는 시스템 설정에 관한 데이터가 들어있다.

The /etc file is the directory where configuration data is stored,

and /sysconfig contains the system configuration data.

 

network-scripts는 네트워크 설정에 대한 디렉토리이다.

network-scripts is the directory for network configuration.

 

# cd /etc/sysconfig/network-scripts

 

centos 네트워크 설정(3) / centos network settings(3)

 

"ls" 명령어를 통해 어떤 파일이 있는지 확인해보자.

Enter the "ls" command to check the list of files in the current directory.

 

"ifcfg-enp0s3" 이라는 파일이 우리가 쓸 네트워크의 설정이 들어있는 파일이다.

The file "ifcfg-enp0s3" is the file that contains our network configuration.

 

centos 네트워크 설정(4) / centos network settings(4)

 

"vi" 명령어를 통해 파일을 열어보자.

Let's open the file using the "vi" command.

 

현재 "root" 로 로그인 되어 있으니 vi 앞에 sudo를 붙일 필요가 없다.

Since we are currently logged in as "root", we don't need to add sudo before vi.

 

# vi ifcfg-enp0s3

 

centos 네트워크 설정(5) / centos network settings(5)

 

vi 편집기로 파일을 열면 각종 설정에 대한 내용이 들어있다.

Opening the file with the vi editor contains information on various settings.

 

각 항목을 설명해보도록 하겠다.

Let me explain each item.

 

TYPE=Ethernet  // 장치의 타입을 지정해주는 항목

TYPE=Ethernet // Item that specifies the device type

 

PROXY_METHOD=none  //  프록시 구성 방법 | none | auto | 

PROXY_METHOD=none // How to configure the proxy | none | auto |

 

BROWSER_ONLY=no  // 프록시 구성이 브라우저 전용인지의 여부 | yes | no |

BROWSER_ONLY=no // Whether the proxy configuration is browser-only | yes | no |

 

BOOTPROTO=dhcp  // ip 부여 방식 설정, | dhcp | static | none |

BOOTPROTO=dhcp // Set ip grant method, | dhcp | static | none |

 

DEFROUTE=yes  // 시스템의 Default Routing 사용 유무 | yes | no |

DEFROUTE=yes // Whether the system uses default routing | yes | no |

 

IPV4_FAILURE_FATAL=no  // ipv4 설정이 실패할 경우 장치 비활성화 설정 | yes | no |

IPV4_FAILURE_FATAL=no // Set device disable if ipv4 setup fails | yes | no |

 

IPV6INIT=yes  // ipv6 사용 설정 | yes | no |

IPV6INIT=yes // Enable ipv6 | yes | no |

 

IPV6_AUTOCONF=yes  // ipv6 자동 설정 | yes | no |

IPV6_AUTOCONF=yes // ipv6 auto-configuration | yes | no |

 

IPV6_DEFROUTE=yes  // ipv6의 Default Routing 사용 유무 | yes | no | 

IPV6_DEFROUTE=yes // Whether ipv6 uses Default Routing | yes | no |

 

IPV6_FAILURE_FATAL=no  // ipv6 설정이 실패할 경우 장치 비활성화 설정 | yes | no |

IPV6_FAILURE_FATAL=no // Set device disable if ipv6 setup fails | yes | no |

 

IPV6_ADDR_GEN_MODE=stable-privacy  // 주소 설정 | EUI64 | stable-privacy |

IPV6_ADDR_GEN_MODE=stable-privacy // Set address | EUI64 | stable-privacy |

 

NAME=enp0s3  // 출력될 이더넷의 이름

NAME=enp0s3 // Ethernet name to be output

 

UUID=302f5dec-fc93-46e8-a1dc-eb761bb38ac2  // 고유 아이디를 부여, 자동으로 부여됨

UUID=302f5dec-fc93-46e8-a1dc-eb761bb38ac2 // Assign a unique ID, it is automatically assigned

 

DEVICE=enp0s3  // 이더넷 카드의 장치명

DEVICE=enp0s3 // Device name of the Ethernet card

 

ONBOOT=no  // 시스템 부팅 시 이더넷 카드를 Enable 시킬 것인지 설정 | yes | no |

ONBOOT=no // Set whether to enable the Ethernet card when the system boots | yes | no |

 

다른 것은 볼 필요가 없다.

No other modifications are necessary.

 

"ONBOOT = no" 항목의 "no" 를 "yes" 로 바꿔 주자.

Replace "no" in "ONBOOT = no" with "yes".

 

시스템 부팅 시 이더넷 카드를 Enable 시키겠다는 뜻이다.

This means that the Ethernet card will be enabled when the system boots.

 

centos 네트워크 설정(6) / centos network settings(6)

 

설정을 완료하고 나면 "ESC" 키를 눌러 ":wq" 를 입력하고 빠져나오자.

After completing the settings, press the "ESC" key to enter ":wq" and exit.

 

centos 네트워크 설정(7) / centos network settings(7)

 

설정을 변경하였으니 네트워크를 재시작해주자.

Now that the settings have been changed, restart the network.

 

# service network restart

 

centos 네트워크 설정(8) / centos network settings(8)

 

이제 홈디렉토리로 돌아와 네트워크가 잘 설정되었는지 확인해보자.

Now let's go back to the home directory and check if the network is set up properly.

 

# ip addr

 

centos 네트워크 설정(9) / centos network settings(9)

 

맞게 설정된 것을 확인했으니 이젠 패킷 전송이 잘 되는지 "ping" 명령어를 입력해서 통신해보자.

Now that we have confirmed that it is set properly,

let's communicate by entering the "ping" command to see if the packet transmission is working.

 

# ping 8.8.8.8

 

centos 네트워크 설정(10) / centos network settings(10)

 

마지막으로 칼리 리눅스의 터미널에서 ssh 연결을 통해 직접 centos에 접속해보도록 하겠다.

Finally, I'll try to access centos directly from the terminal of Kali Linux via ssh connection.

 

필자는 한글 입, 출력이 필요하기에 터미널에서의 접속이 필요하다.

I need Korean input and output, so I need a connection from the terminal.

 

연결은 ssh로 연결할 것이며 포트 번호는 22번 포트이다.

The connection will be via ssh, and the port number is port 22.

 

"시큐어 셸(Secure Shell, SSH)" 은 네트워크 상의 다른 컴퓨터에 로그인하거나 원격 시스템에서 명령을 실행하고

다른 시스템으로 파일을 복사할 수 있도록 해 주는 응용 프로그램 또는 프로토콜이다.

"Secure Shell (SSH)" is an application program or protocol that allows you to log in to another computer

on the network, execute commands on a remote system, and copy files to another system.

 

형식은 "ssh [사용자명]@[접속할 IP 주소]" 이다.

The format is "ssh [user name]@[IP address to access]".

 

$ ssh root@192.~~~.~~~.~~~

 

centos 네트워크 설정(11) / centos network settings(11)

 

설정을 끝마쳤다.

Setup is complete.

 

다음 포스팅에선 프로그래밍을 하기전 centos에서의 설치작업과 설정들을 다뤄보도록 하겠다.

In the next post, I'll cover installation and configuration in centos before programming.