основная помощь для конфигурации NAT необходима

О, привет снова wildchild - если Вы сообщаете мне, какую версию SAN-ОС или NX-ОС Вы используете, я счастливо отправлю Вам копию превосходной ссылки команды Cisco.

0
задан 31 May 2012 в 00:58
1 ответ

I haven't tested this, but this is what I would try.

  1. Create a new bridge on the host with brctl

    brctl addbr br0
    
  2. Configure the VM with bridged networking connected to this bridge

  3. Assign a private subnet to the bridge and give the host an IP on it

    ip addr add 192.168.1.1/24 dev br0
    ip route add 192.168.1.0/24 dev br0
    
  4. Either statically configure the VM with an IP on this range (e.g. 192.168.1.2), or setup a DHCP server on the host (e.g. dnsmasq or VirtualBox's dhcpserver).

  5. Check that the host can access the VM and vice versa on the private IPs
  6. Attach the static IP to eth0 on the host

    ip addr add 1.0.2.30/24 dev eth0
    
  7. Check that you can connect to the host on the additional IP from outside

  8. Enable IP forwarding on the host

    echo 1 > /proc/sys/net/ipv4/ip_forward
    
  9. Configure iptables to SNAT outgoing packets from the VM

    iptables --table nat --append POSTROUTING --source 192.168.1.0/24 --jump SNAT --to 1.0.2.30
    iptables --append FORWARD --source 192.168.1.0/24 --jump ACCEPT
    
  10. Check that the VM has connectivity to the Internet

  11. Configure iptables to DNAT packets to the additional IP to the VM

    iptables --table nat --append PREROUTING --destination 1.0.2.30 --to-destination 192.168.1.2
    iptables --append FORWARD --destination 192.168.1.2 --jump ACCEPT
    
  12. Убедитесь, что вы можете подключиться к виртуальной машине по дополнительному IP извне.

2
ответ дан 4 December 2019 в 14:28

Теги

Похожие вопросы