📜 ⬆️ ⬇️

Hetzner, save IPv4 addresses for XenServer virtual machines

A small life hack that you can use if you want to save some IPv4 addresses on your virtual machines in XenServer (it doesn't matter).

After you have installed Hetzner'en XenServer or another OS on the server, you get 1 IP address, mask and gateway. Since virtual machines require separate addresses, you have the opportunity to order them:


')


For example, we were allocated 46.4.205.64/29. How to use all 8 addresses? About this below.

On XenCenter we create an additional network:







Assign dom0 in this subnet to an address from a range of private addresses (in this case, 172.16.1.1/24):



When creating a new VM in the configuration process, we indicate that the network will be the newly created Network 1:



Installing the OS in a virtual machine can cause some inconvenience if it needs the Internet. Therefore, for Linux distributions, it is recommended to use full images, rather than netinstall. However, it is always possible to order one additional IP for such needs, and use it at the time of installation (respectively via Network 0).

In the process of installing the OS when setting up the network, specify the IP from the above range (in this case, 172.16.1.0/24), for example, 172.16.1.10/24 without specifying a gateway .

After installation, let's assign the address 46.4.205.64 to our virtual machine:

- in the network interface settings (for example in debian):

/ etc / network / interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 172.16.1.10
netmask 255.255.255.0

auto eth0: 0
iface eth0: 0 inet static
address 46.4.205.64
netmask 255.255.255.255

- and write the route at startup:

#mcedit /etc/network/if-up.d/route
#! / bin / bash
/ sbin / ip route add default via 172.16.1.1 src 46.4.205.64

not forgetting #chmod + x /etc/network/if-up.d/route

With this, the virtual machine network setup is complete. It remains to correct the routing to dom0.

Determine the uuid of our network (Network 1):

#xe network-list

Add a static route to our subnet:

#xe network-param-set uuid = uuid other-config: static-routes = 46.4.205.64 / 29 / 172.16.1.1

Check:

#ip ro
default via <external address> dev xenbr0
46.4.173.64/29 via 172.16.1.1 dev xapi1
172.16.1.0/24 dev xapi1 proto kernel scope link src 172.16.1.1
<external address> / 29 dev xenbr0 proto kernel scope link src <htcner gateway>

Well, in conclusion:

Spoiler header
C: \ Users \ spacewalk> ping 46.4.205.64

Packet exchange from 46.4.205.64 over with 32 data bytes:
The answer from 46.4.205.64: the number of bytes = 32 time = 40ms TTL = 56
The answer from 46.4.205.64: the number of bytes = 32 time = 40ms TTL = 56
The answer from 46.4.205.64: the number of bytes = 32 time = 40ms TTL = 56
The answer from 46.4.205.64: the number of bytes = 32 time = 40ms TTL = 56

Ping statistics for 46.4.205.64:
Packets: sent = 4, received = 4, lost = 0
(0% loss)
Approximate time of reception and transmission in ms:
Min = 40msec, Max = 40 ms, Medium = 40 ms

C: \ Users \ spacewalk> tracert 46.4.173.60

Tracing the route to static.60.173.4.46.clients.your-server.de [46.4.173.60]
with a maximum number of hops 30:

1 1 ms 2 ms <1 ms 192.168.89.1
2 1 ms 1 ms 1 ms 213.231.0.200
3 2 ms 1 ms 1 ms odessa1-xe-0-0-0-931.ett.ua [80.93.126.69]
4 53 ms 34 ms 61 ms fft-od.ett.ua [80.93.127.238]
5 36 ms 45 ms 36 ms decix2-gw.hetzner.de [80.81.193.164]
6 40 ms 42 ms 40 ms core22.hetzner.de [213.239.245.17]
7 48 ms 42 ms 40 ms ex9k1.rz13.hetzner.de [213.239.229.150]
8 41 ms 40 ms 41 ms static. <External address> .clients.your-server.de [<external address>]
9 40 ms 40 ms 41 ms static.64.205.4.46.clients.your-server.de [46.4.
205.64]

Tracing completed.

The solution is not tied to a specific routing platform and OS in virtual machines, just at hand was such a set of software. The only question is how to implement it with a Windows virtual machine. Perhaps in the comments prompt.

Save addresses and thank you for your attention.

Source: https://habr.com/ru/post/317230/


All Articles