I have VPS server hosted using Xen from hosting provider. I am assigned few IP addresses (*.*.56.234, *.*.56.235, *.*.56.236, ...), however there is one physical network device eth0.
The host is using first one from the pool (*.*.56.234). I want my container to use *.*.56.235 and to be fully autonomous. That is to say, the .235 address should be only available to the container and .234 to the host so that I can start up two different services on both host and container where both of them are listening on the same port.
I guess I messed up the configuration entries as I was able to make network running on the container but:
- There is short freeze when trying to access the internet (curl, wget) -- like it was looking for proper route but after curling ip-checking website it shows proper .235 IP
- When I'm setting up listener within container on port that is not used in the host machine it sometimes works and sometimes doesn't (meaning sometimes I can or cannot connect to it)
- If I host service inside container using the same port as one of the services on the host, I will always connect to the host's one even if I connect to .235 address
Here's my configuration (note that X, Y denote public range, none of these is LAN range)
Host's /etc/network/interfaces
# The primary network interface
allow-hotplug eth0
iface eth0 inet static
address X.Y.56.234
netmask 255.255.255.248
network X.Y.56.232
broadcast X.Y.56.239
gateway X.Y.56.233
dns-nameservers 8.8.8.8
auto br0
iface br0 inet static
bridge_ports eth0
bridge_fd 0
###################
address X.Y.56.235
network X.Y.56.232
broadcast X.Y.56.239
gateway X.Y.56.233
dns-nameservers 8.8.8.8
Container's /etc/network/interfaces
auto lxcnet0
iface lxcnet0 inet static
address X.Y.56.235
network X.Y.56.232
broadcast X.Y.56.239
gateway X.Y.56.233
dns-nameservers 8.8.8.8
container's config entries
## Network
lxc.network.type = veth
lxc.network.flags = up
lxc.network.name = lxcnet0
lxc.network.hwaddr = 00:FF:AA:11:22:33
lxc.network.link = br0
lxc.network.ipv4 = X.Y.56.235/32