1

我的情况如下:

我通过 eth0 连接到我们的数据中心。有一个可以上网的代理,但确实受到限制。使用 wlan0,我在我们的非代理环境中,我无法访问我们的数据中心。

我的问题:我不想在 eth0 接口上使用 apt-get,因为我们的内部 apt 镜像不支持我的本地 ubuntu 版本并且它按设计工作,我得到一个网络无法访问的错误。我想在 wlan0 接口上使用 apt-get install ,因为与互联网的连接不受限制。但是不要关闭 et0,因为我不想重新启动我对数据中心的所有会话。

4

1 回答 1

0

尝试以下操作:

# Add a new namespace called test_ns
ip netns add aptwifi

# Set test to use eth0, after this point eth0 is not usable by programs
# outside the namespace
ip link set wlan0 netns aptwifi

# Bring up eth0 inside test_ns
ip netns exec aptwifi ip link set wlan0 up

# Use dhcp to get an ipv4 address for eth0
ip netns exec aptwifi dhclient wlan0

# Ping google from inside the namespace
ip netns exec aptwifi apt update

来源:https ://unix.stackexchange.com/questions/210982/bind-unix-program-to-specific-network-interface

于 2019-10-11T20:30:18.303 回答