OpenVZ Forum


Home » General » Support » Assign more ips to container (how to add more public ips to container)
icon4.gif  Assign more ips to container [message #47110] Sat, 07 July 2012 23:13
pateutz is currently offline  pateutz
Messages: 4
Registered: July 2012
Junior Member
hy everyone

i have Debian 6.0 i386 with openvz 686

i make some containers and them work good

but i wann make a container with multiple public ips to container

at server i have made bridge this is the config

root@smallhosting:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface

brctl addbr br0
auto br0
iface br0 inet static
bridge_ports eth1
 address 89.42.231.180
 broadcast 89.42.231.255
 netmask 255.255.255.0
 gateway 89.42.231.1


the id of container is 113

this is conf of 113.conf

VE_ROOT="/storage/vz/root/$VEID"
VE_PRIVATE="/storage/vz/private/$VEID"
OSTEMPLATE="debian-6.0-i386-minimal"
ORIGIN_SAMPLE="basic"
HOSTNAME="test.smallhosting.ro"
NAMESERVER="193.231.169.2"
SEARCHDOMAIN="smallhosting.ro"
VETH_IP_ADDRESS="89.42.231.113"
NETIF="ifname=eth1.113,mac=00:02:04:06:08:02,host_ifname=veth113.0,host_mac=00:19:99:c4:66:87"



so i tryed a lots of times and search 2 weeks on google to read how to make this

so i tryed like this:

i installed vlan and i config interface like this

brctl addbr br0
auto br0
iface br0 inet static
bridge_ports eth1
 address 89.42.231.180
 broadcast 89.42.231.255
 netmask 255.255.255.0
 gateway 89.42.231.1

auto eth1.113
iface eth1.113 inet static
        address 89.42.231.113
        netmask 255.255.255.0
        #gateway 192.168.110.254
        #network 192.168.110.0
        broadcast 89.42.231.255
        vlan_raw_device eth1

auto eth1.124
iface eth1.124 inet static
        address 89.42.231.124
        netmask 255.255.255.0
        #gateway 192.168.110.254
        #network 192.168.110.0
        broadcast 89.42.231.255
        vlan_raw_device eth1


113.conf was this

VE_ROOT="/storage/vz/root/$VEID"
VE_PRIVATE="/storage/vz/private/$VEID"
OSTEMPLATE="debian-6.0-i386-minimal"
ORIGIN_SAMPLE="basic"
HOSTNAME="test.smallhosting.ro"
NAMESERVER="193.231.169.2"
SEARCHDOMAIN="smallhosting.ro"
VETH_IP_ADDRESS="89.42.231.113/24;89.42.231.124/24"
#BRIDGEDEV="br0"
NETIF="ifname=eth1.113,mac=00:02:04:06:08:02,host_ifname=veth113.0,host_mac=00:19:99:c4:66:87;ifname=eth1.124,mac=00:02:04:06:08:04,host_ifname=veth113.1,host_mac=00:19:99:c4:66:87"



i restarted the network

root@smallhosting:~# /etc/init.d/networking restart
Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces ... (warning).
Reconfiguring network interfaces...Removed VLAN -:eth1.113:-

Waiting for br0 to get ready (MAXWAIT is 32 seconds).
Set name-type for VLAN subsystem. Should be visible in /proc/net/vlan/config
Added VLAN with VID == 113 to IF -:eth1:-
Set name-type for VLAN subsystem. Should be visible in /proc/net/vlan/config
Added VLAN with VID == 124 to IF -:eth1:-
done.


this is the ifconfig

root@smallhosting:~# ifconfig
br0       Link encap:Ethernet  HWaddr 00:19:99:c4:66:87
          inet addr:89.42.231.180  Bcast:89.42.231.255  Mask:255.255.255.0
          inet6 addr: fe80::219:99ff:fec4:6687/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2325 errors:0 dropped:0 overruns:0 frame:0
          TX packets:70 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:184371 (180.0 KiB)  TX bytes:5912 (5.7 KiB)

eth1      Link encap:Ethernet  HWaddr 00:19:99:c4:66:87
          inet6 addr: fe80::219:99ff:fec4:6687/64 Scope:Link
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
          RX packets:121742 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4798 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:11519797 (10.9 MiB)  TX bytes:518455 (506.3 KiB)
          Interrupt:18 Memory:fe600000-fe620000

eth1.113  Link encap:Ethernet  HWaddr 00:19:99:c4:66:87
          inet addr:89.42.231.113  Bcast:89.42.231.255  Mask:255.255.255.0
          inet6 addr: fe80::219:99ff:fec4:6687/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:468 (468.0 B)

eth1.124  Link encap:Ethernet  HWaddr 00:19:99:c4:66:87
          inet addr:89.42.231.124  Bcast:89.42.231.255  Mask:255.255.255.0
          inet6 addr: fe80::219:99ff:fec4:6687/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:468 (468.0 B)


i started the container

root@smallhosting:~# vzctl start 113
Restarting container
Starting container ...
Container is mounted
Setting CPU units: 1000
Set hostname: test.smallhosting.ro
File resolv.conf was modified
Configure veth devices: veth113.0 veth113.1
ifname=
host_ifname=
Initializing interface veth113.0 for VE113.
Adding interface veth113.0 to the bridge br0.
Adding an IP 89.42.231.113/24 to the eth1.113 for VE113.
Adding a route from VE0 to VE113.
RTNETLINK answers: File exists
ifname=
host_ifname=
Initializing interface veth113.1 for VE113.
SIOCSIFADDR: No such device
veth113.1: ERROR while getting interface flags: No such device
Adding interface veth113.1 to the bridge br0.
interface veth113.1 does not exist!
Cannot find device "eth1.124"
Adding an IP 89.42.231.124/24 to the eth1.124 for VE113.
Cannot find device "eth1.124"
Adding a route from VE0 to VE113.
ifname=
host_ifname=
Initializing interface veth113.0 for VE113.
Adding interface veth113.0 to the bridge br0.
device veth113.0 is already a member of a bridge; can't enslave it to bridge br0.
Adding an IP 89.42.231.113/24 to the eth1.113 for VE113.
RTNETLINK answers: File exists
Adding a route from VE0 to VE113.
RTNETLINK answers: File exists
ifname=
host_ifname=
Initializing interface veth113.1 for VE113.
Adding interface veth113.1 to the bridge br0.
Adding an IP 89.42.231.124/24 to the eth1.124 for VE113.
Adding a route from VE0 to VE113.
RTNETLINK answers: File exists
Container start in progress...


i entered in container "vzctl enter 113"


ifconfig in container
eth1.113  Link encap:Ethernet  HWaddr 00:02:04:06:08:02
          inet addr:89.42.231.113  Bcast:0.0.0.0  Mask:255.255.255.0
          inet6 addr: fe80::202:4ff:fe06:802/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1393 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:103134 (100.7 KiB)  TX bytes:600 (600.0 B)

eth1.124  Link encap:Ethernet  HWaddr 00:02:04:06:08:04
          inet addr:89.42.231.124  Bcast:0.0.0.0  Mask:255.255.255.0
          inet6 addr: fe80::202:4ff:fe06:804/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1386 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:102147 (99.7 KiB)  TX bytes:600 (600.0 B)

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)


route -n on container

root@test:/# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
89.42.231.1     0.0.0.0         255.255.255.255 UH    0      0        0 eth1.113
89.42.231.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1.113
89.42.231.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1.124
0.0.0.0         89.42.231.1     0.0.0.0         UG    0      0        0 eth1.113


no internet access
no pings in gateway
root@test:/# ping 89.42.231.1
PING 89.42.231.1 (89.42.231.1) 56(84) bytes of data.

--- 89.42.231.1 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 999ms

root@test:/# ping 89.42.231.1
PING 89.42.231.1 (89.42.231.1) 56(84) bytes of data.

--- 89.42.231.1 ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 3999ms


route -n on server

89.42.231.124   0.0.0.0         255.255.255.255 UH    0      0        0 br0
89.42.231.113   0.0.0.0         255.255.255.255 UH    0      0        0 br0
89.42.231.0     0.0.0.0         255.255.255.0   U     0      0        0 br0
89.42.231.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1.113
89.42.231.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1.124
0.0.0.0         89.42.231.1     0.0.0.0         UG    0      0        0 br0


ping from server in container at 89.42.231.113
root@smallhosting:~# ping 89.42.231.113
PING 89.42.231.113 (89.42.231.113) 56(84) bytes of data.
64 bytes from 89.42.231.113: icmp_req=1 ttl=64 time=0.020 ms
64 bytes from 89.42.231.113: icmp_req=2 ttl=64 time=0.033 ms
64 bytes from 89.42.231.113: icmp_req=3 ttl=64 time=0.028 ms
^C
--- 89.42.231.113 ping statistics ---
3 packets transmitted, 3 received, 
...

Previous Topic: Internal routing via domain
Next Topic: Direct access to PCI card & drives?
Goto Forum:
  


Current Time: Thu Aug 01 22:29:24 GMT 2024

Total time taken to generate the page: 0.03087 seconds