An open API service indexing awesome lists of open source software.

https://github.com/moresec-io/conduit

A transparent proxy mesh. 一个透明代理网格,为你集群间安全保驾护航!
https://github.com/moresec-io/conduit

iptables mesh-networks mtls security tls tob transparent-proxy

Last synced: 5 months ago
JSON representation

A transparent proxy mesh. 一个透明代理网格,为你集群间安全保驾护航!

Awesome Lists containing this project

README

          



[![Go](https://github.com/moresec-io/conduit/actions/workflows/go.yml/badge.svg)](https://github.com/moresec-io/conduit/actions/workflows/go.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/moresec-io/conduit)](https://goreportcard.com/report/github.com/moresec-io/conduit)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

Conduit是一个透明代理和Mesh代理,劫持并加密你的流量,无需任何软件开发和改造成本,几分钟即可部署完成使用,为你的集群间通信保驾护航。如果你面临:集群间通信未考虑加密、网络中数据泄漏并被检测、使用未配置TLS的MySQL/PostgreSQL、被中间人攻击,Conduit就是你的天命之选!

## 特性

- **无需编码/改造** 没有任何代码改造成本,分钟级部署和交付
- **部署简单** 配置易理解,一行命令启动,点到点代理和加密
- **集群安全** 支持TLS和mTLS,更安全,更防中间人
- **性能无损** 使用Netfilter提供的透明代理,几乎无性能损耗
- **全场景代理** 支持简单N:1的Client/Server代理,也支持N:M的透明代理Mesh
- **中心化管理** 支持全局控制面,随时加入新节点

## 使用

* Client/Server模式
* Mesh模式

| ![](./docs/diagrams/client-server.jpg)| ![](./docs/diagrams/conduit.jpg) |
|-----------------------|-----------------------|
| Client-Server模式 | Mesh模式 |

### 1. Client-Server模式

所有在```Host A```访问```:80```端口都会经过```Host B(172.168.0.11:5053)```访问到```127.0.0.1:80```:

![](./docs/diagrams/client-server.jpg)

Host A配置做为客户端:

**conduit.yaml**

```yaml
client:
enable: true
network: tcp
listen: 127.0.0.1:5052 # Host A监听
check_time: 60
forward_table:
- dst: :80 # 支持ip:port或者:port
dst_as: 127.0.0.1:80
peer_index: 1
peers:
- index: 1
network: tcp
addresses:
- 172.168.0.11:5053 # Host B配置

log:
maxsize: 10
level: debug
file: /opt/conduit/log/conduit.log
```

Host B配置做为服务端
**conduit.yaml**

```yaml
server:
enable: true
listen:
network: tcp
addr: 172.168.0.11:5053 # Host B监听

log:
maxsize: 10
level: debug
file: /opt/conduit/log/conduit.log
```

分别在```Host A```和```Host B```运行两个Conduit

```
/opt/conduit/bin/conduit -c /opt/conduit/conf/conduit.yaml

```

### 2. Mesh模式
配置集群成为一个A B C D互相访问都走mTLS通道的透明代理Mesh。

![](./docs/diagrams/conduit.jpg)

Manager配置:

**manager.yaml**

```yaml
conduit_manager:
listen:
network: "tcp"
addr: "0.0.0.0:5051"

db:
driver: sqlite
address: /opt/conduit/data/
db: manager.db
debug: false

cert: # cert strategy for conduits
ca:
not_after: 1,0,0 # 1 year 0 month 0 day
common_name: "conduit.com"
cert:
not_after: 1,0,0
common_name: "conduit.com"
organization: "moresec.com"

log:
maxsize: 10
level: info
file: /opt/conduit/log/manager.log
```

配置做为客户端和服务端:

**conduit.yaml**

```yaml
manager:
enable: true
dial:
network: tcp
addresses:
- 172.168.0.17:5051

server:
enable: true
listen:
network: tcp
addr: 172.168.0.11:5053

client:
enable: true
network: tcp
listen: 127.0.0.1:5052
check_time: 60

log:
maxsize: 10
level: debug
file: /opt/conduit/log/conduit.log
```

在任意一台可达节点部署Manager:

```bash
/opt/conduit/bin/manager -c /opt/conduit/conf/manager.yaml
```

在Host A B C D部署Conduit:

```bash
/opt/conduit/bin/conduit -c /opt/conduit/conf/conduit.yaml

```

## 获取

```
make conduit
```

得到release/bin/conduit

```
make manager
```

得到release/bin/manager

## Q&A

**1. Conduit会影响我的iptables表吗**

Conduit独立建立了CONDUIT Chain,只有命中了ipset的才会进入透明代理。并且在正常退出后,会清除所有规则。

```
-A PREROUTING -i br+ -j CONDUIT
-A OUTPUT -p tcp -m mark --mark 0x5a4 -j ACCEPT
-A OUTPUT ! -o br+ -j CONDUIT
-A CONDUIT -p tcp -m set --match-set CONDUIT_IPPORT dst,dst -j MARK --set-xmark 0x5a6/0xffffffff
-A CONDUIT -p tcp -m set --match-set CONDUIT_PORT dst -j MARK --set-xmark 0x5a7/0xffffffff
-A CONDUIT -p tcp -m set --match-set CONDUIT_IP dst -j MARK --set-xmark 0x5a5/0xffffffff
-A CONDUIT -p tcp -m set --match-set CONDUIT_IPPORT dst,dst -j DNAT --to-destination 127.0.0.1:5052
-A CONDUIT -p tcp -m set --match-set CONDUIT_PORT dst -j DNAT --to-destination 127.0.0.1:5052
-A CONDUIT -p tcp -m set --match-set CONDUIT_IP dst -j DNAT --to-destination 127.0.0.1:5052
```

**2. 性能怎么样**

使用iperf可以打满带宽

```
-----------------------------------------------------------
Server listening on 80
-----------------------------------------------------------
Accepted connection from 127.0.0.1, port 47363
[ 5] local 127.0.0.1 port 80 connected to 127.0.0.1 port 47364
[ ID] Interval Transfer Bandwidth
[ 5] 0.00-1.00 sec 311 MBytes 2.61 Gbits/sec
[ 5] 1.00-2.00 sec 322 MBytes 2.70 Gbits/sec
[ 5] 2.00-3.00 sec 312 MBytes 2.61 Gbits/sec
[ 5] 3.00-4.00 sec 318 MBytes 2.67 Gbits/sec
[ 5] 4.00-5.00 sec 304 MBytes 2.55 Gbits/sec
[ 5] 5.00-6.00 sec 326 MBytes 2.74 Gbits/sec
[ 5] 6.00-7.00 sec 330 MBytes 2.77 Gbits/sec
[ 5] 7.00-8.00 sec 326 MBytes 2.74 Gbits/sec
[ 5] 8.00-9.00 sec 320 MBytes 2.68 Gbits/sec
[ 5] 9.00-10.00 sec 318 MBytes 2.67 Gbits/sec
...
```

**3. 适用于什么场景**

* ToB交付产品时,经常需要暴露mysql/redis端口,但是历史原因没有配置tls,可以使用Conduit来接管安全
* 没有微隔离,但是需要把几台主机流量隔离起来,可以使用Conduit来构成Mesh网络
* 不希望对外端口开放过多,可以使用Conduit做为代理使用

**4. 为什么会给流量打Mark**

为了防止Conduit发出的流量又被iptables劫持,所以使用Mark来忽略。

**5. 我需要开通fw_mark吗**

fw_mark是为了iptables的mark在socket接收时能够查到这个mark,以快速确定匹配了哪个ipset,如果没有也没关系,会多一层判断

**6. 配置了Mesh还能额外配置forward_table吗**

可以,Mesh的流量会走CONDUIT_IP的ipset,forward_table配置是CONDUIT_IP或CONDUIT_IPPORT的ipset,而且优先级更高

### 贡献

如果你发现任何Bug,请提出Issue,项目Maintainers会及时响应相关问题。

如果你希望能够提交Feature,更快速解决项目问题,满足以下简单条件下欢迎提交PR:

* 代码风格保持一致
* 每次提交一个Feature
* 提交的代码都携带单元测试

## 许可证

Released under the [Apache License 2.0](https://github.com/moresec-io/conduit/blob/main/LICENSE)