LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Virtualization and Cloud (https://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/)
-   -   Problem to set static IP (https://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/problem-to-set-static-ip-774168/)

satimis 12-08-2009 03:12 AM

Problem to set static IP
 
Hi folks,

KVM
host - Debian 5.0
VM (guest) - Ubuntu 9.10


Just created a new VM running Ubuntu 9.10 with following command;

$ sudo virt-install --connect qemu:///system -n vm30ubuntu910 -r 512 --vcpus=2 -f /home/satimis/VM/vm30ubuntu910.qcow2 -s 12 -c /home/satimis/Desktop/mini_ubuntu9.10.iso --vnc --noautoconsole --os-type linux --accelerate --network=bridge:br0 --hvm


Internet can be connected with following dynamic IP

$ cat /etc/network/interfaces
Code:

auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp


If change it to static IP then it can't connect Internet

$ cat /etc/network/interfaces
Code:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
        address        192.168.0.30
        netmask        255.255.255.0
        network        192.168.0.0
        broadcast      192.168.0.255
        gateway        192.168.0.1
        bridge_ports    eth0
        bridge_fd      9
        bridge_hello    2
        bridge_maxage  12
        bridge_stp      off


$ sudo ifconfig eth0
Code:

eth0        Link encap: Ethernet  HWaddr 54:52:00:07:69:c8
        Broadcase multicast  MTU:1500  Metric:1
        RX packets:0 errors:0 dropped:0 ovrruns:0 frame:0
        TX packets:0 errors:0 dropped:0 ovrruns:0 carrier:0       
        collisions:0 txqueuelen:1000
        RX bytes:0 (0.0 B)  TX bytes:0 (0.0.B)
        Interrupt:10

$ netstat -rn
Code:

Kernel IP routing table
Destination  Gateway  Genmask  Flags  MSS Window  irtt  Iface

Please advise how to fix the problem. TIA


Remark:
Other VMs works seamlessly with above static IP


B.R.
satimis

zhjim 12-08-2009 06:33 AM

Quote:

Originally Posted by satimis (Post 3783700)
Remark:
Other VMs works seamlessly with above static IP

If the other VM's work then the problem lies within the new VM (who thought of that ;)).
I'm a bit puzzled what configs you posted are for what. I assembled that they are all from the Host and not from the guest. Right?

Please provide the following information
- complete ip addr from the host
- complete ip addr from the guest
- complete ip route from host
- complete ip route from guest
- complete ip link from host
- complete ip link from guest
- brctl show
- line how you start the guest

The ip link part is to make sure that the nics are up and in promisce mode.

Ideas why it is not working
You did not join the nic of the guest with the bridge from host.
Different subnet between guest and host. (typo)
Configured nic is not installed inside guest. (kvm has about 6-8 diffrent nic that are passed to the guest) Missing module? dmesg | grep "eth"; lspci; ip link;

Hope it helps

Cheers Zhjim

satimis 12-08-2009 08:12 AM

Quote:

Originally Posted by zhjim (Post 3783933)
If the other VM's work then the problem lies within the new VM (who thought of that ;)).

Thanks for your advice.

I suppose you meant the command for creating the new VM. I took it from the document written down previously in creating the old VM.


Quote:

I'm a bit puzzled what configs you posted are for what. I assembled that they are all from the Host and not from the guest. Right?
Sorry, no. They are from VM, the guest. I copied them from the running guest and change the IP address.


Quote:

Please provide the following information
- complete ip addr from the host
192.168.0.10

Quote:

- complete ip addr from the guest
192.168.0.30

This is the static ip address I try to use without result. The dynamic ip assigned automatically is 192.168.0.49

They are ip address on the router

Quote:

- complete ip route from host
$ ip route
Code:

192.168.0.0/24 dev br0  proto kernel  scope link  src 192.168.0.10
192.168.122.0/24 dev virbr0  proto kernel  scope link  src 192.168.122.1
default via 192.168.0.1 dev br0

Would it be the problem here "192.168.0.0/24 ?
Where can I change it to "192.168.0.0/50"?

Quote:

- complete ip route from guest
$ ip route
Code:

192.168.0.0/24 dev eth0  proto kernel  scope link  src 192.168.0.49
default via 192.168.0.1 dev eth0  metric 100

Quote:

- complete ip link from host
$ ip link
Code:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
    link/ether 00:0e:a6:f9:a3:5b brd ff:ff:ff:ff:ff:ff
3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
    link/ether 00:0e:a6:f9:a3:5b brd ff:ff:ff:ff:ff:ff
4: virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
    link/ether fa:cc:db:5d:a5:63 brd ff:ff:ff:ff:ff:ff
5: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 500
    link/ether 00:ff:95:46:91:b5 brd ff:ff:ff:ff:ff:ff
6: vnet1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 500
    link/ether 00:ff:00:13:7d:6d brd ff:ff:ff:ff:ff:ff
7: vnet2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 500
    link/ether 00:ff:e9:57:bf:64 brd ff:ff:ff:ff:ff:ff

Quote:

- complete ip link from guest
$ ip link
Code:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 54:52:00:07:69:c8 brd ff:ff:ff:ff:ff:ff

Quote:

- brctl show
On host

$ sudo brctl show
Code:

bridge name        bridge id                STP enabled        interfaces
br0                8000.000ea6f9a35b        no                eth0
                                                        vnet0
                                                        vnet1
                                                        vnet2
virbr0                8000.000000000000        yes

Quote:

- line how you start the guest
On host

$ sudo virsh --connect qemu:///system start vmX

X is the vm number.

Quote:

The ip link part is to make sure that the nics are up and in promisce mode.
Could you please explain in more detail on "promisece mode". There is only 1 nic on this box.


Quote:

Ideas why it is not working
You did not join the nic of the guest with the bridge from host.
Different subnet between guest and host. (typo)
Configured nic is not installed inside guest. (kvm has about 6-8 diffrent nic that are passed to the guest) Missing module? dmesg | grep "eth"; lspci; ip link;
On host;

$ dmesg | grep "eth"
Code:

[    2.755926] forcedeth: Reverse Engineered nForce ethernet driver. Version 0.61.
[    3.363323] forcedeth 0000:00:08.0: ifname eth0, PHY OUI 0x5043 @ 1, addr 00:0e:a6:f9:a3:5b
[    3.363327] forcedeth 0000:00:08.0: highdma csum vlan pwrctl mgmt timirq gbit lnktim msi desc-v3
[    9.607547] Driver 'sd' needs updating - please use bus_type methods
[    9.607814]  sda:<4>Driver 'sr' needs updating - please use bus_type methods
[  21.730966] device eth0 entered promiscuous mode
[  21.742410] br0: port 1(eth0) entering learning state
[  32.352126] br0: port 1(eth0) entering forwarding state
[  34.149594] eth0: no IPv6 routers present


B.R.
satimis

zhjim 12-08-2009 08:53 AM

Quote:

Originally Posted by satimis (Post 3784057)
I suppose you meant the command for creating the new VM. I took it from the document written down previously in creating the old VM.

Nope, actually I wanted to know how you make the connection between host and guest. But as you are using virsh to start the vm I'm lost. I only have experience with qemu-system-x64_86 to start vm's. And with that binary you normaly provide a -net option. The nic which goes with the -net option has to be on the bridge. (further down I'm getting back on this)

Quote:

Originally Posted by satimis (Post 3784057)
192.168.0.30

This is the static ip address I try to use without result. The dynamic ip assigned automatically is 192.168.0.49

They are ip address on the router

Might be the chance that 192.168.0.30 is allready used on another machine. But don't think this will hold true. But a ping 192.168.0.30 from the host would make this clear (when coming think about it, if you would get an response from 192.168.0.30 you would'nt have come to think that the vm is not running....)


Quote:

Originally Posted by satimis (Post 3784057)
Would it be the problem here "192.168.0.0/24 ?

The routes look fine to me. Just a normal 254 host subnet in CIDR notation.

Quote:

Originally Posted by satimis (Post 3784057)
Where can I change it to "192.168.0.0/50"?

You would need to change the netmask of the host. /etc/network/interfaces should do the trick. Just comment out the network and broadcast line cause they would not match with a netmask of 255.255.0.0 (which isn't a /50 subnet no fun on math right now ;))

Quote:

Originally Posted by satimis (Post 3784057)
$ ip link

Okay we have a nic in the guest so this works out.


Quote:

Originally Posted by satimis (Post 3784057)
$ sudo brctl show
Code:

bridge name        bridge id                STP enabled        interfaces
br0                8000.000ea6f9a35b        no                eth0
                                                        vnet0
                                                        vnet1
                                                        vnet2
virbr0                8000.000000000000        yes


What is the second bridge good for? Maybe this is causing some trouble? Also I doubt this cause it got no interface connected to it. Also it got Spanning Tree Protocol enabled...



Quote:

Originally Posted by satimis (Post 3784057)
$ sudo virsh --connect qemu:///system start vmX

X is the vm number.

Sadly but true I dunno virsh. Are there any config files for each VM?
I found this line on the manpage
Code:

attach-interface domain-id type source optional --target target --mac mac --script script
Attach a new network interface to the domain.
type can be either network to indicate a physical network device or bridge to indicate a bridge to a device.
source indicates the source device.
target allows you to indicate the target device in the guest.
mac allows you to specify the MAC address of the network interface.
script allows you to specify a path to a script handling a bridge instead of the default one.

Quote:

Originally Posted by satimis (Post 3784057)
Could you please explain in more detail on "promisece mode". There is only 1 nic on this box.

Promisce mode has the nic to also accept packets for mac address that are not the one of the nic itself. It normaly is used for sniffing network traffic what you on some kind need to have so the VM's can be reached from outside.
If the physical device (eth0) is not in promisce mode it would only put packets with the right mac address (ip link eth0) on to the network stack. But as we are debuing the inside it should not make a huge diffrence. Beside how do you test network connectivity from/to the guest? And as the other VM's are working I doubt that this realy makes a difference.


To straighten things I would take a look how the other VM's are started maybe this gives the final clue. Specially as they are working.
Next ping from host to guest and vice versa to make sure that the box itself is happy. After that see that you can ping something on the network from the guest.

satimis 12-08-2009 09:35 AM

Quote:

Originally Posted by zhjim (Post 3784094)
But as you are using virsh to start the vm I'm lost

There are 2 ways to start VMs

1) Virsh
2) virt-manager

Both work without problem.


Quote:

Might be the chance that 192.168.0.30 ......
Sorry, no.

I name the VM with a number starting from vm11, vm12, etc. Each VM is assigned with a static IP corresponding to its number, such as;

192.168.0.11 for vm11
192.168.0.12 for vm12
etc.

The last VM created is vm30 with ip address 192.168.0.30 assigned. There is no duplication.


Quote:

You would need to change the netmask of the host. /etc/network/interfaces should do the trick
On the host

/etc/network/interfaces
Code:

        netmask        255.255.255.0
It has been there for long time. What shall I change for a test?


Quote:

What is the second bridge good for?
Code:

virbr0                8000.000000000000        yes

I have no idea how it comes.


Quote:

Are there any config files for each VM?
I have no idea. Would it be vm11.qcow2, vm12.qcow2, etc.? But they are program.


Quote:

I would take a look how the other VM's are started maybe this gives the final clue. Specially as they are working.
Most time I run;
$ sudo virsh --connect qemu:///system start vm11/vm12 etc.

They can be ping either way without problem. From the guest I can ping other guests and/or Internet.


B.R.
satimis

zhjim 12-09-2009 04:50 AM

Quote:

Originally Posted by satimis (Post 3784123)
On the host

/etc/network/interfaces
Code:

        netmask        255.255.255.0
It has been there for long time. What shall I change for a test?

If you don't have to have a bigger subnet I would leave the networkmask as it is right now. If you need a bigger one go with 255.255.0.0 which lets you have 254 * 254 numbers of hosts.

Quote:

Originally Posted by satimis (Post 3784123)
I have no idea. Would it be vm11.qcow2, vm12.qcow2, etc.? But they are program.

the *.qcow2 files are the diskimages of the vm's. So this might be a point to further check on...


Quote:

Originally Posted by satimis (Post 3784123)
Most time I run;
$ sudo virsh --connect qemu:///system start vm11/vm12 etc.

They can be ping either way without problem. From the guest I can ping other guests and/or Internet.

Hm...
I'm out of ideas right now. Let me think about it some more. I'll check back later.

satimis 12-10-2009 07:50 AM

Hi zhjim,

I found out the cause in running following command on VM (Guest)

$ sudo /etc/init.d/networking restart
Code:

* Reconfiguring network interfaces...                                   
 * if-up.d/mountnfs[eth0]: waiting for interface br0 before doing NFS mounts
SIOCSIFADDR: No such device
br0: ERROR while getting interface flags: No such device
SIOCSIFNETMASK: No such device
SIOCSIFBRDADDR: No such device
br0: ERROR while getting interface flags: No such device
br0: ERROR while getting interface flags: No such device
Failed to bring up br0.
                                                                  [ OK ]

I have no idea how to fix the problem. IIRC I met this problem sometimes ago. I had it fixed later unfortunate I have no recollection.

B.R.
satimis

satimis 12-10-2009 07:55 PM

Solved
 
Hi zhjim,

I got my problem sorted out.

VM host already has bridge-utils installed. But VM guest also needs it. After having it installed on VM guest my problem is gone.

B.R.
satimis

zhjim 12-14-2009 04:55 AM

Quote:

Originally Posted by satimis (Post 3787222)
Hi zhjim,

I got my problem sorted out.

Great that you got I sorted.
I am sorry that I could not response lately, but works a bitch at the moment.

satimis 12-14-2009 06:09 AM

Quote:

Originally Posted by zhjim (Post 3790723)
Great that you got I sorted.
I am sorry that I could not response lately, but works a bitch at the moment.

Hi zhjim,

Still I don't understand why it needs bridge-utils in VM (guest). It was by chance to discover this solution.

B.R.
satimis

zhjim 12-15-2009 02:10 AM

I guess its the way the network in the guest is configured. Check out /etc/network/interfaces.
There should be some line about the bridge. I'd say you could comment it out. Or just leave it as every thing is working.


All times are GMT -5. The time now is 05:17 PM.