Modifying sysctl values inside lxc container

Ace*_*Ace 5 networking container lxc

I have made several linux containers using the normal userspace tools (not docker), and I have been setting up a test environment.

I want to set up two containers to try out heartbeat, which requires the containers to bind to and ip address that is not yet configured, namely net.ipv4.ip_nonlocal_bind=1

Everytime I try it, it says something like this:

user@lxc1:~$ sudo sysctl -w net.ipv4.ip_nonlocal_bind=1
sysctl: cannot stat /proc/sys/net/ipv4/ip_nonlocal_bind: No such file or directory
Run Code Online (Sandbox Code Playgroud)

Also modifying the sysctl.conf file doesnt help. So i did some research, and aparently the guest container binds to the host's /proc/sys (which makes sense), so i modified the hosts value by adding the proper value to the hosts sysctl.conf and then i rebooted the host for good measure:

user@host:~$ sudo sysctl -A | grep -i nonlocal
net.ipv4.ip_nonlocal_bind = 1
Run Code Online (Sandbox Code Playgroud)

as noted above, the host reflects the configuration that i want to see the in guest container, but even after rebooting, the container -still- shows the same problem.

How do i modify these values in the guest container, is it even possible?

And*_*yer 2

我遇到过同样的问题。你说得对,它与 LXC 容器有关。我添加 net.ipv4.ip_nonlocal_bind = 1 到我的 LXC 主机的 sysctl.conf ,然后运行:( sysctl -p需要 root 访问/sudo)

我确实必须重新启动容器才能使更改生效。此外,您仍然会登上sysctl: cannot stat /proc/sys/net/ipv4/ip_nonlocal_bind: No such file or directory 集装箱。如果该功能有效,我不完全确定是否有必要在来宾容器上运行相同的命令。

我现在可以通过 VIP 或定义的 IP 访问容器。