V
V
vadik_tmb2015-08-03 10:45:20
System administration
vadik_tmb, 2015-08-03 10:45:20

Forward IP to a virtual machine?

There is a hypervisor
receives IP from the provider via dhcp

bond0     Link encap:Ethernet  HWaddr 0C:C4:7A:01:C5:CC  
          inet6 addr: fe80::ec4:7aff:fe01:c5cc/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:3497943 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5094201 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:3200769720 (2.9 GiB)  TX bytes:2173888522 (2.0 GiB)

br0       Link encap:Ethernet  HWaddr 0C:C4:7A:01:C5:CC  
          inet addr:37.235.ххх.132  Bcast:37.235.ххх.255  Mask:255.255.248.0
          inet6 addr: fe80::ec4:7aff:fe01:c5cc/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3483486 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2641824 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:3147142263 (2.9 GiB)  TX bytes:2026746464 (1.8 GiB)

eth0      Link encap:Ethernet  HWaddr 0C:C4:7A:01:C5:CD  
          UP BROADCAST SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
          Interrupt:18 Memory:fbb00000-fbb20000 

eth1      Link encap:Ethernet  HWaddr 0C:C4:7A:01:C5:CC  
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:3497943 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5094201 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:3200769720 (2.9 GiB)  TX bytes:2173888522 (2.0 GiB)
          Interrupt:19 Memory:fba00000-fba20000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

virbr0    Link encap:Ethernet  HWaddr 52:54:00:DF:83:98  
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1235330 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1176048 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1826407599 (1.7 GiB)  TX bytes:975834586 (930.6 MiB)

vnet0     Link encap:Ethernet  HWaddr FE:54:00:C1:01:04  
          inet6 addr: fe80::fc54:ff:fec1:104/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1235330 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1584777 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:1843702219 (1.7 GiB)  TX bytes:997088650 (950.8 MiB)

it has 2 virtual sites that receive an IP like 192.168.1.xxx from a dhcp server in a virtual network, the necessary ports are forwarded through
default.xml
<network>
  <name>default</name>
  <uuid>28cbea7c-c509-44a1-8911-3fb39aea7ec7</uuid>
  <forward dev='br0' mode='nat'>
    <interface dev='br0'/>
  </forward>
  <bridge name='virbr0' stp='on' delay='0' />
  <mac address='52:54:00:DF:83:98'/>
  <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254' />
    </dhcp>
  </ip>
</network>

sv-vm02.xml
<interface type='bridge'>
      <mac address='52:54:00:c1:01:04'/>
      <source bridge='virbr0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

How can I force the virtual machine to receive the IP from the provider's dhcp server?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
ldv, 2015-08-03
@vadik_tmb

Use bridge br0

<interface type='bridge'>
      <mac address='52:54:00:c1:01:04'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question