일부 컴퓨터에서 VirtualBox를 실행하는 Ubuntu Server 14.04가 있습니다. 이 머신은 OpenStack Fuel이 설치되어 있으며 NIC 인터페이스 인프라를 변경할 수 없습니다 (호스트 만 2 개, NAT 1 개).
이 기계 중 하나는 연료 제어 패널을 실행하고 있지만 호스트 전용 인터페이스 (10.20.0.2) 중 하나에서만 액세스 할 수 있습니다.
내 홈 네트워크는 192.168.25.x입니다. 호스트 머신 (Ubuntu) 외부는 192.168.25.25입니다.
이제 홈 네트워크에 Windows 시스템이 있고 VM (IP 10.20.0.2)에서 실행되는 Fuel 패널에 액세스해야합니다.
필요한 것은 하드웨어 192.168.25.25 인터페이스의 수신을 virtualbox hostonly 10.20.0.X VM 인터페이스로 전달하여 IP 10.20.0.2에 도달하는 것입니다.
이것은 모든 인터페이스를 보여주는 내 호스트 ifconfig입니다.
root@AKRAB:~# ifconfig
lo Link encap:Loopback Local
inet end.: 127.0.0.1 Masc:255.0.0.0
endereço inet6: ::1/128 Escopo:Máquina
UP LOOPBACK RUNNING MTU:65536 Métrica:1
pacotes RX:19685 erros:0 descartados:0 excesso:0 quadro:0
Pacotes TX:19685 erros:0 descartados:0 excesso:0 portadora:0
colisões:0 txqueuelen:0
RX bytes:7674590 (7.6 MB) TX bytes:7674590 (7.6 MB)
vboxnet0 Link encap:Ethernet Endereço de HW 0a:00:27:00:00:00
inet end.: 10.20.0.1 Bcast:10.20.0.255 Masc:255.255.255.0
endereço inet6: fe80::800:27ff:fe00:0/64 Escopo:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Métrica:1
pacotes RX:0 erros:0 descartados:0 excesso:0 quadro:0
Pacotes TX:167 erros:0 descartados:0 excesso:0 portadora:0
colisões:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:22260 (22.2 KB)
vboxnet1 Link encap:Ethernet Endereço de HW 0a:00:27:00:00:01
inet end.: 172.16.0.254 Bcast:172.16.0.255 Masc:255.255.255.0
endereço inet6: fe80::800:27ff:fe00:1/64 Escopo:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Métrica:1
pacotes RX:0 erros:0 descartados:0 excesso:0 quadro:0
Pacotes TX:437 erros:0 descartados:0 excesso:0 portadora:0
colisões:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:137886 (137.8 KB)
vboxnet2 Link encap:Ethernet Endereço de HW 0a:00:27:00:00:02
inet end.: 172.16.1.1 Bcast:172.16.1.255 Masc:255.255.255.0
endereço inet6: fe80::800:27ff:fe00:2/64 Escopo:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Métrica:1
pacotes RX:0 erros:0 descartados:0 excesso:0 quadro:0
Pacotes TX:464 erros:0 descartados:0 excesso:0 portadora:0
colisões:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:150336 (150.3 KB)
wlan0 Link encap:Ethernet Endereço de HW 00:13:46:94:18:c1
inet end.: 192.168.25.25 Bcast:192.168.25.255 Masc:255.255.255.0
endereço inet6: fe80::213:46ff:fe94:18c1/64 Escopo:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Métrica:1
pacotes RX:2354945 erros:0 descartados:4 excesso:0 quadro:0
Pacotes TX:1237088 erros:0 descartados:0 excesso:0 portadora:0
colisões:0 txqueuelen:1000
RX bytes:3455421823 (3.4 GB) TX bytes:103231994 (103.2 MB)
root@AKRAB:~#
wlan0 외부 인터페이스 (내 홈 네트워크)와 이동하려는 네트워크 (10.20.0.2)를 숨기는 vboxnet0을 볼 수 있습니다.
이러한 모든 주소는 대상을 포함하여 정적입니다. VM에서 연결하려는 포트 번호는 8443 (Mirantis Fuel Dashboard)입니다.
성공하지 못했습니다.
root@AKRAB:~# iptables -I FORWARD -d 10.20.0.2 -m comment --comment "Accept to forward Fuel DashBoard traffic" -m tcp -p tcp --dport 8443 -j ACCEPT
root@AKRAB:~# iptables -t nat -I PREROUTING -m tcp -p tcp --dport 8443 -m comment --comment "redirect pkts to virtual machine" -j DNAT --to-destination 10.20.0.2:8443
root@AKRAB:~# iptables -t nat -I POSTROUTING -m comment --comment "NAT the src ip" -d 10.20.0.2 -o vboxnet0 -j MASQUERADE
결과 :
root@AKRAB:~# iptables -nvL FORWARD
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT tcp -- * * 10.20.0.2 0.0.0.0/0 /* Accept to forward Fuel DashBoard return traffic */ tcp spt:8443
0 0 ACCEPT tcp -- * * 0.0.0.0/0 10.20.0.2 /* Accept to forward Fuel DashBoard traffic */ tcp dpt:8443
과
root@AKRAB:~# iptables -t nat -nvL
Chain PREROUTING (policy ACCEPT 73 packets, 6145 bytes)
pkts bytes target prot opt in out source destination
18 912 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8443 /* redirect pkts to virtual machine */ to:10.20.0.2:8443
Chain INPUT (policy ACCEPT 73 packets, 6145 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 759 packets, 47828 bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 759 packets, 47828 bytes)
pkts bytes target prot opt in out source destination
0 0 MASQUERADE all -- * vboxnet0 0.0.0.0/0 10.20.0.2 /* NAT the src ip */
iptables 규칙은 괜찮은 것 같지만 ip forward를 활성화하는 것을 놓친 것 같습니다.
echo 1 > /proc/sys/net/ipv4/ip_forward
그런 다음 iptables 규칙이 다음과 일치하는지 확인하십시오.
iptables -t nat -nvL
iptables -nvL FORWARD
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다