raffdevian 最近的时间轴更新
raffdevian

raffdevian

V2EX 第 632358 号会员,加入于 2023-06-03 11:14:22 +08:00
raffdevian 最近回复了
2023-06-05 01:07:51 +08:00
回复了 EdisonChan 创建的主题 问与答 想出国读硕士,但是手里没那么多钱,有没什么便宜的?
#14 和 "你能从地球上找到我,我就给你一嘴巴子" 有异曲同工之妙 - 都 TM 脱裤子放屁
2023-06-05 01:00:18 +08:00
回复了 fangwenxue 创建的主题 问与答 docker iptables 指定出口 ip
中文版本

当使用 Docker 的桥接网络时,您可以通过以下方式配置所需的出站以太网接口:

1. 确定主机系统上的出站以太网接口名称。您可以使用 `ip link` 命令列出可用接口:
```bash
ip link
```

2. 在主机的网络配置文件(例如 `/etc/iproute2/rt_tables`)中创建一个新的路由表。在文件末尾添加一条条目,选择一个唯一的标识符(例如 `200`)并指定一个名称(例如 `outgoing_eth_table`):
```
200 outgoing_eth_table
```

3. 通过添加规则来配置新的路由表,该规则匹配来自桥接网络(`my-bridge-network`)的流量,并将其指向所需的出站以太网接口(`ethX`)。用实际的接口名称替换 `<outgoing_interface>`。
```bash
ip route add default via <gateway_ip> dev <outgoing_interface> table outgoing_eth_table
ip rule add from <bridge_subnet> table outgoing_eth_table
```

例如:
```bash
ip route add default via 192.168.1.1 dev eth0 table outgoing_eth_table
ip rule add from 172.20.0.0/16 table outgoing_eth_table
```

4. 按照平常的方式将容器连接到桥接网络:
```bash
docker run --network=my-bridge-network --name my-container -d <image_name>
```

通过按照这些步骤进行操作,您可以创建一个自定义的路由表,用于指定来自桥接网络(`my-bridge-network`)的流量所使用的出站以太网接口(`ethX`)。Docker 将在将容器的数据转发到互联网时使用此路由表。

请注意,这些步骤仅供参考,具体的命令和配置文件可能因您使用的 Linux 发行版和版本而有所不同。
2023-06-05 00:44:35 +08:00
回复了 fangwenxue 创建的主题 问与答 docker iptables 指定出口 ip
> How can i specify the outgoing ethernet interface while using docker's bridge network?

> By default, Docker uses the default route on the host system to determine the outgoing Ethernet interface for containers connected to a bridge network. However, you can override this behavior and specify a specific outgoing Ethernet interface by configuring a custom routing table.

Here are the general steps to specify the outgoing Ethernet interface for containers in Docker's bridge network:

1. Identify the name of the outgoing Ethernet interface on your host system. You can use the `ip link` command to list the available interfaces:
```bash
ip link
```

2. Create a new routing table in the host's network configuration file (e.g., `/etc/iproute2/rt_tables`) by adding an entry at the end. Choose a unique identifier for the table (e.g., `200`) and specify a name (e.g., `outgoing_eth_table`):
```
200 outgoing_eth_table
```

3. Configure the new routing table by adding a rule that matches traffic from the bridge network (`my-bridge-network`) and directs it to the desired outgoing Ethernet interface (`ethX`). Replace `<outgoing_interface>` with the actual interface name identified in step 1:
```bash
ip route add default via <gateway_ip> dev <outgoing_interface> table outgoing_eth_table
ip rule add from <bridge_subnet> table outgoing_eth_table
```

For example:
```bash
ip route add default via 192.168.1.1 dev eth0 table outgoing_eth_table
ip rule add from 172.20.0.0/16 table outgoing_eth_table
```

4. Connect containers to the bridge network as usual:
```bash
docker run --network=my-bridge-network --name my-container -d <image_name>
```

By following these steps, you create a custom routing table that specifies the outgoing Ethernet interface (`ethX`) for traffic originating from the bridge network (`my-bridge-network`). Docker will then utilize this routing table when forwarding packets from containers to the internet.

Please note that these steps are general guidelines, and the exact commands and configuration files may vary depending on your Linux distribution and version.
2023-06-05 00:40:23 +08:00
回复了 fangwenxue 创建的主题 问与答 docker iptables 指定出口 ip
你在说啥, 驴唇不对马嘴。
路由使用 ip route 命令, 关 SNAT 啥事
听 v 友吹🐂真有意思
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2676 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 11ms · UTC 15:04 · PVG 23:04 · LAX 07:04 · JFK 10:04
Developed with CodeLauncher
♥ Do have faith in what you're doing.