![如果端口没有特权,为什么我在命名空间中是 root 时无法访问它们?](https://linux22.com/image/208044/%E5%A6%82%E6%9E%9C%E7%AB%AF%E5%8F%A3%E6%B2%A1%E6%9C%89%E7%89%B9%E6%9D%83%EF%BC%8C%E4%B8%BA%E4%BB%80%E4%B9%88%E6%88%91%E5%9C%A8%E5%91%BD%E5%90%8D%E7%A9%BA%E9%97%B4%E4%B8%AD%E6%98%AF%20root%20%E6%97%B6%E6%97%A0%E6%B3%95%E8%AE%BF%E9%97%AE%E5%AE%83%E4%BB%AC%EF%BC%9F.png)
我跑了sudo sysctl -w net.ipv4.ip_unprivileged_port_start=1
。然而,sudo ip netns exec myvpn unshare -r python -m http.server -b 127.0.0.1 2
不起作用。奇怪的是,这确实sudo ip netns exec myvpn unshare python -m http.server -b 127.0.0.1 2
:为什么?
编辑: 但是,两者sudo ip netns exec myvpn sudo -u $USER unshare python -m http.server -b 127.0.0.1 2
都sudo ip netns exec myvpn sudo -u system unshare -r python -m http.server -b 127.0.0.1 2
不起作用。
答案1
这声明这ip_unprivileged_port_start
是一个“per-namespace sysctl”。所以,就sudo ip netns exec myvpn sysctl -w net.ipv4.ip_unprivileged_port_start=1
这样你就完成了。