2개의 다른 서브넷에서 2개의 IP를 사용하는 Xen VPS

2개의 다른 서브넷에서 2개의 IP를 사용하는 Xen VPS

저는 Xen을 처음 사용하고 동일한 게스트 VPS에 2개의 서로 다른 IP를 추가하는 방법을 이해하려고 합니다.

먼저 32GB RAM과 2개의 NIC가 있는 물리적 서버인 노드 설정을 설명하겠습니다. 첫 번째 NIC에는 공용 IP 82.XXX.YYY.ZZZ가 있고 두 번째 NIC는 cPanel 서버(개인 IP 192.168.XXX.YYY)에 연결하는 내부 네트워크용입니다.

지금까지 테스트한 결과 공용 네트워크나 개인 네트워크 중 하나만 사용하고 둘 다를 사용하지 않는 VPS를 만드는 데 성공했습니다. 공용 IP 또는 개인 IP로 VPS를 생성하면 ping을 수행하고 SSH를 통해 연결할 수도 있습니다.

하지만 예를 들어 노드(82.XXX.YYY.ZZZ)와 동일한 서브넷의 일부 IP를 사용하는 VPS를 만든 다음 개인 IP를 추가하려고 하면 내부 네트워크에서 개인 IP를 ping할 수 없으며, 반대로, 개인 IP(192.168.XXX.YYY)로 VPS를 생성하면 내부 네트워크에서 연결하여 ping할 수 있지만, 공용 IP를 추가하면 ping하거나 연결할 수 없습니다.

또한 이 정보가 이 문제에 도움이 될지는 모르겠지만 VPS 관리(VPS 생성, IP 할당, VPS 삭제 등)를 위해 SolusVM을 사용합니다.

이 문제를 해결하기 위해 제공해야 할 다른 정보가 무엇인지 알려주십시오.

답변1

브리지 네트워크 구성:

Edit /etc/network/interfaces
# vi /etc/network/interfaces
...
auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
        address [ipv4]
        netmask [netmask]
        network [network]
        broadcast [broadcast]
        gateway [ipv4gateway]
        bridge_ports eth0
        bridge_stp on
        bridge_maxwait 0
iface br0 inet6 static
        address [ipv6]
        netmask 64
        dns-nameservers [dnsipv6]
        gateway [ipv6gatewaay]
        autoconf 0
# internal
auto virbr0
iface virbr0 inet static
        address 192.168.0.1
        netmask 255.255.255.0
        broadcast 192.168.0.255
        pre-up brctl addbr virbr0

/etc/sysctl.conf.d를 편집하세요.

net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding=1
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0 

virbr0 수동 추가

# brctl addbr virbr0
# ifconfig virbr0 192.168.0.1 netmask 255.255.255.0 up  

domu용 dhcp 서버 설치 및 구성 isc-dhcp-server 설치

# apt-get install isc-dhcp-server 

/etc/default/isc-dhcp-server 편집

INTERFACES="virbr0"
Edit /etc/dhcp/dhcpd.conf
subnet 192.168.0.0 netmask 255.255.255.0 {
  range 192.168.0.10 192.168.0.50;
  option routers 192.168.0.1;
  default-lease-time 600;
  max-lease-time 7200;
}

DHCP 서버 다시 시작

# service isc-dhcp-server restart

domu 이미지를 생성하도록 xen-tool 구성 edit /etc/xen-tools/xen-tools.conf

#Begin by setting the dir = directive to the directory into which the tools are to create the Xen guest image files:
dir = /home/images
#lvm = myvolgroup -> if using LVM (logical volume management)
install-method = debootstrap
debootstrap-cmd = /usr/sbin/debootstrap
size   = 4G       # Root disk, suffix (G, M, k) required
memory = 512M # Suffix (G, M, k) required
swap   = 1G # Suffix (G, M, k) required
fs     = ext3     # Default file system for any disk
dist   = `jessie` # Default distribution is determined by Dom0's distribution
image  = sparse   # Specify sparse vs. full disk images (file based images only)
# for static
# gateway    = 192.168.1.1
# netmask    = 255.255.255.0
# broadcast  = 192.168.1.255
dhcp=1
bridge = virbr0
genpass_len = 8
passwd = 1
kernel      = /boot/vmlinuz-`uname -r`
initrd      = /boot/initrd.img-`uname -r`
pygrub = 1
mirror = http://debian.mirrors.ovh.net/debian
mirror_jessie = http://http.debian.net/debian
ext4_options     = noatime,nodiratime,errors=remount-ro 
ext3_options     = noatime,nodiratime,errors=remount-ro
ext2_options     = noatime,nodiratime,errors=remount-ro
xfs_options      = defaults
reiserfs_options = defaults
btrfs_options    = defaults
output    = /etc/xen

extension = .cfg

Xen 게스트용 Xen 디스크 이미지(루프백 이미지) 만들기 호스트 이름 testa, 디스크 10G, 스왑 1G, ram/메모리 512M, dhcp, vcpu 3, OS Debiean jessie를 사용하여 xen 게스트를 만듭니다.

# xen-create-image --hostname testa --size=10Gb --swap=1024Mb --memory=512Mb --vcpu=3  --dist=jessie
Can't exec "jessie": No such file or directory at /usr/share/perl5/Xen/Tools/Common.pm line 100, <FILE> line 134.
Use of uninitialized value $output in scalar chomp at /usr/share/perl5/Xen/Tools/Common.pm line 101, <FILE> line 134.
Use of uninitialized value $output in concatenation (.) or string at /usr/share/perl5/Xen/Tools/Common.pm line 104, <FILE> line 134.

General Information
--------------------
Hostname       :  testa
Distribution   :  jessie
Mirror         :  http://debian.mirrors.ovh.net/debian
Partitions     :  swap            1024Mb (swap)
                  /               10Gb  (ext3)
Image type     :  sparse
Memory size    :  512Mb
Bootloader     :  pygrub

Networking Information
----------------------
IP Address     : DHCP [MAC: 00:16:3E:73:6F:31]


Creating partition image: /home/vmimages/domains/testa/swap.img
Done

Creating swap on /home/vmimages/domains/testa/swap.img
Done

Creating partition image: /home/vmimages/domains/testa/disk.img
Done

Creating ext3 filesystem on /home/vmimages/domains/testa/disk.img
Done
Installation method: debootstrap
Done

Running hooks
Done

No role scripts were specified.  Skipping

Creating Xen configuration file
Done

No role scripts were specified.  Skipping
Setting up root password
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
All done


Logfile produced at:
         /var/log/xen-tools/testa.log

Installation Summary
---------------------
Hostname        :  testa
Distribution    :  jessie
MAC Address     :  00:16:3E:73:6F:31
IP Address(es)  :  dynamic
RSA Fingerprint :  21:12:bb:c3:ad:34:67:6f:cd:a1:7d:d3:ef:ae:95:f5
Root Password   :  N/A

이 과정은 약 14분 정도 소요됩니다. Xen 게스트 실행 Xen 게스트를 실행하려면

# xl create /etc/xen/testa.cfg -c

내부에서 인터넷으로 라우팅

# iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE
# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# iptables -A FORWARD -i virbr0 -o br0 -m state --state RELATED,ESTABLISHED -j ACCEPT
# iptables -A FORWARD -i virbr0 -o br0 -j ACCEPT  
Internet to internal in port xxx into 192.168.0.100 port yyy
# iptables -A PREROUTING -t nat -i br0 -p tcp --dport xxx -j DNAT --to 192.168.0.100:yyy
# iptables -A FORWARD -p tcp -d 192.168.0.100 --dport yyy -j ACCEPT

부팅 후 domu 자동 시작 만들기 /etc/xen/auto 폴더에 심볼릭 링크 만들기

# mkdir /etc/xen/auto
# cd /etc/xen/auto/
# ln -s /etc/xen/testa.cfg

/etc/xen/testa.cfg를 편집하세요.

# vi /etc/xen/testa.cfg
on_xend_stop='shutdown' 
on_xend_start='start'

전체 지침을 보려면 다음을 읽으십시오.http://www.garasiku.web.id/web/joomla/index.php/debian/80-how-to-install-xen-in-debian-jessie

관련 정보