본문 바로가기
정보기술/가상화

Vyatta - Network Operating System 사용방법

by fermi 2011. 4. 1.

서론
가상화 (Virtualization) 의 장점은 명확하기 때문에 피할 수 없는 선택이다. VMware Server 등과 같은 서버 가상화 소프트웨어 제품들은 일반적으로 자체적으로 NAT (Network Address Translation) 솔루션을 포함하고 있는 것에 반하여 VMware vSphere Hypervisor (ESXi) 등과 같이 OS 레벨에서 가상화를 제공하는 Hypervisor 제품군들은 NAT 를 제공하지 않는다. 그 대신에 Network 까지도 가상화하는 것이 가능하여 가상의 Switch 를 만들고 Network group 을 생성하는 것이 가능하여 본격적인 가상 Network 를 구축할 수 있다. 이를 위해서는 Router 역할을 하는 Virtual Machine 이 존재하여야 한다. Vyatta 는 Network Operating System 으로 바로 이 Router 의 역할을 수행할 수 있는 Open Source Operating System 이다.


본론
Vyatta Core (VC) 6.2 기준 - http://www.vyatta.org
Quick Start Guide (v5.0.3) - http://www.vyatta.com/downloads/documentation/VC5.0.2/Vyatta_QuickStart_VC5_v03.pdf
NAT in VMware vSphere ESX - http://www.javatuning.com/nat-in-vmware-vsphereesx-in-a-nut-shell/
Vyatta Firewall and NAT - http://www.carbonwind.net/VyattaOFR/Firewall/Firewall.htm


1. 다운로드
http://www.vyatta.org/downloads 에서 VMware ESX 4 Template 의 URL 을 복사하거나 OVF 를 다운로드하여 VMware vSphere Client 의 File > Deploy OVF Template 에 입력하면 Template 로 부터 VM 을 생성할 수 있으나, 이미지 업로드에 계속 오류가 나서 실패함.

다른 방법으로 Live CD iso 이미지를 다운로드하여 WMware 에 직접 설치할 수 있다.
다음의 절차는 Vyatta Core (VC) 6.2 - Live CD iso를 이용하였다.


2. 설치
참고: http://www.vyatta.org/getting-started/how-to-install
- 메모리는 512MB, HDD는 1GB 정도로 설정, NIC를 두개
- VMware ESXi 4.1 사용
- CD 마운트 후 부팅
- 로그인 (초기 Username: vyatta, Password: vyatta)
- 프롬프트가 뜨면 HDD 에 시스템을 설치할 수 있음

명령 프롬프트에서
$ install-system

이후, 절차를 따라가면 설치 완료
설치 완료 후 부팅시 로그인 어카운트는 vyatta, 암호는 설치시 설정한 것


3. Network Interface 설정
참고: http://www.javatuning.com/nat-in-vmware-vsphereesx-in-a-nut-shell/
eth0  를 WAN (10.0.0.100), eth1 (192.168.1.1) 을 LAN 으로 가정

$ configure
# set interfaces ethernet eth0 address 10.0.0.100/24
[edit]
# set interfaces gateway-address 10.0.0.1
[edit]
# set system name-server 8.8.8.8
[edit]
# set interfaces ethernet eth1 address 192.168.1.1/24
[edit]
# commit
[edit]
# save
[edit]
# show interfaces
[edit]
# exit
$


4. Vyatta Web GUI
참고: http://www.vyatta.org/documentation/tips-tricks/enable-gui

$ configure
# set service https
[edit]
# commit
[edit]
# save
[edit]
# exit
$

이후 interface 에 설정한 ip 로 Vyatta Web GUI 에 접속할 수 있다.


5. DHCP

$ configure
# set service dhcp-server shared-network-name ETH1_POOL subnet 192.168.1.0/24 start 192.168.0.2 stop 192.168.0.100
[edit]
# set service dhcp-server shared-network-name ETH1_POOL subnet 192.168.1.0/24 default-router 192.168.1.1
[edit]
# set service dhcp-server shared-network-name ETH1_POOL subnet 192.168.1.0/24 dns-server 8.8.8.8
[edit]
# commit
[edit]
# save
[edit]
# show service dhcp-server
[edit]
# exit
$


5-1. DHCP Reservation
Static mapping 의 이름을 STATIC-MAP1 으로 저장한다고 가정

$ configure
# set service dhcp-server shared-network-name ETH1-POOL subnet 192.168.1.0/24 static-mapping STATIC-MAP1 ip-address 192.168.1.3
[edit]
# set service dhcp-server shared-network-name ETH1-POOL subnet 192.168.1.0/24 static-mapping STATIC-MAP1 mac-address 00:0c:29:13:cd:a0
[edit]
# commit
[edit]
# save
[edit]


6. NAT

$ configure
# set service nat rule 1 source address 192.168.1.0/24
[edit]
# set service nat rule 1 outbound-interface eth0
[edit]
# set service nat rule 1 type masquerade
[edit]
# commit
[edit]
# save
[edit]
# show service nat
[edit]
# exit
$


6-1. Publish a Web server on an alternate port
http://www.carbonwind.net/VyattaOFR/Firewall/Firewall.htm#toPpp

set service nat rule 10 type destination
set service nat rule 10 protocol tcp
set service nat rule 10 inside-address port 80
set service nat rule 10 inside-address address 192.168.1.3
set service nat rule 10 inbound-interface eth0
set service nat rule 10 destination address 10.0.0.1
set service nat rule 10 destination port 8083


7. SSH

$ configure
# set service ssh
[edit]
# commit
[edit]
# save
[edit]
# exit
$


8. Firewall
http://www.carbonwind.net/VyattaOFR/Firewall/Firewall.htm#toPpp

set firewall name ETH0_IN rule 10 action accept
set firewall name ETH0_IN rule 10 protocol tcp
set firewall name ETH0_IN rule 10 destination address 192.168.1.3
set firewall name ETH0_IN rule 10 destination port 80
set firewall name ETH0_IN rule 10 state new enable
set firewall name ETH0_IN rule 10 state established enable
set firewall name ETH0_IN rule 10 state related enable

set interfaces ethernet eth0 firewall in name ETH0_IN

Note that the DNAT (Destination NAT) process takes place before the firewall one, so for example we just need one firewall rule on the in firewall instance on the Internet facing interface, allowing TCP port 80 and not TCP port 5000.
Thus, basically, the firewall rules from the above scenario where we published the web server on the standard TCP port 80, will remain untouched.

set firewall name ETH0_LOCAL rule 10 action accept
set firewall name ETH0_LOCAL rule 10 protocol tcp
set firewall name ETH0_LOCAL rule 10 destination address 10.0.0.1
set firewall name ETH0_LOCAL rule 10 destination port 22,443
set firewall name ETH0_LOCAL rule 10 state new enable
set firewall name ETH0_LOCAL rule 10 state established enable
set firewall name ETH0_LOCAL rule 10 state related enable

set interfaces ethernet eth0 firewall local name ETH0_LOCAL

Firewall 이 적용된 interface 는 deny all 룰이 implicit 하게 자동으로 적용 됨.


관리
Vyatta의 설정 파일은 /opt/vyatta/etc/config/config.boot 에 저장된다.  IP address  변경 등은 이 파일을 직접 수정하는 것으로도 가능하다. 


후기
이로써 완벽한 Network Virtualization 완료!
vSwitch1 이 eth0, vSwith2 가 eth1 에 연결되어 있다. Vyatta Core 는 Virtual Switch 2 로 부터 요청되는 네트워크 연결을 Virtual Switch 1 으로 NAT 서비스를 제공한다.