部署I2P服务器

客户端选择

  • I2P
    基于java的I2P客户端,具有一个网页版的控制台。因为是第一个实现I2P协议的客户端,所以网络上很多教程是基于这个版本的。https://geti2p.net/
  • I2P Plus
    和I2P一样基于java,增强了网页版的控制台。https://i2pplus.github.io
  • I2P Daemon
    基于C++ 实现的I2P 客户端。应用本身占用空间很少。缺少网页控制台,只有一个查看网络信息的网页。这个版本有详细的配置文档。 https://i2pd.website/

上述三个版本都支持除了IOS外的主流操作系统(Linux, BSD, Windows, Android)和容器化部署(X86, ARM)。

I2P网络和常规互联网

I2P网络和通常的互联网不互通。为了通过I2P网络访问互联网,需要配置一个代理作为出口。
I2P社区推荐使用I2P Outproxy,目前已知的i2p-outproxy代理有:

如何设置这些出口,可以参考stormycloud的文档。目前没有发现这些服务的开源实现。
如果需要更稳定的隐蔽连接,可以在服务器部署Tor, 并在i2pd.conf中设置socksproxy将流量指向Tor作为出口。
在牺牲隐蔽性的前提下,可以利用隧道转发HTTP代理实现通过I2P网络访问互联网的需求。

使用I2PD配置隧道

I2P协议支持一定的内网穿透功能,因此可以配置简单的转发隧道。这些隧道不需要公网支持,但是延迟高,速度慢,只能作为应急使用。因为I2PD占用系统资源少,配置隧道不依赖于GUI,而且其docker镜像大小不高于20M,所以推荐使用这个版本配置I2P隧道。
I2PD需要两个配置文件i2pd.conf和tunnels.conf.

  1. 配置i2pd.conf
    此配置关闭了中继功能,开启了全部隐蔽选项。该配置适合简单浏览网页,更详细的配置参看I2PD文档示例

    • 如果要建立隧道,[http]和[i2pcontrol]至少要开启一个。

    • 如果不需要浏览i2p网页,可以关闭[httpproxy]和[socksproxy].

    • address是监听地址,如果允许局域网其他服务器访问,需要修改地址为I2P服务器地址。

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      42
      43
      44
      45
      46
      47
      48
      49
      50
      51
      52
      53
      54
      55
      56
      57
      58
      59
      60
      61
      62
      63
      64
      65
      66
      67
      68
      69
      70
      71
      72
      73
      74
      75
      76
      77
      78
      79
      80
      81
      82
      83
      84
      85
      86
      87
      88
      log = none

      daemon = true

      ## Port to listen for connections
      ## By default i2pd picks random port. You MUST pick a random number too,
      ## don't just uncomment this
      # port = 4567

      ipv4 = true
      ipv6 = false

      bandwidth = 256
      notransit = true
      floodfill = true

      [ntcp2]
      enabled = true
      published = false
      port = 4567

      [ssu2]
      enabled = true
      published = false
      port = 4567

      [http]
      enabled = false
      address = 127.0.0.1
      port = 7070
      webroot = /

      [httpproxy]
      enabled = true
      address = 127.0.0.1
      port = 4444
      keys = http-proxy-keys.dat
      addresshelper = true
      # outproxy = http://false.i2p

      [socksproxy]
      enabled = false
      address = 127.0.0.1
      port = 4447
      keys = socks-proxy-keys.dat
      outproxy.enabled = false
      outproxy = 127.0.0.1
      outproxyport = 9050

      [sam]
      enabled = false

      [bob]
      enabled = false

      [i2cp]
      enabled = false

      [i2pcontrol]
      enabled = false
      address = 127.0.0.1
      port = 7650
      password = itoopie

      [precomputation]
      elgamal = true

      [upnp]
      enabled = false
      name = I2Pd

      [meshnets]
      yggdrasil = false

      [reseed]
      verify = true
      # proxy = http://127.0.0.1:8118 # or socks://address:port

      [trust]
      hidden = true

      [persist]
      profiles = true
      addressbook = true

      [cpuext]
      aesni = true

  2. 配置tunnels.conf
    这里配置了可以访问服务器的ssh隧道和HTTP代理隧道以及一个可以在I2P网络访问的http服务器。通过I2P地址访问对应端口的流量会转发到服务器的对应端口。服务器需要额外安装支持相关功能的软件(ssh server、http proxy server、http server)。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    [ssh-tunnel]
    type = server
    host = 127.0.0.1
    port = 22
    keys = ssh-tunnel-key.dat

    [proxy]
    type = server
    host = 127.0.0.1
    port = 3128
    keys = proxy-key.dat

    [website]
    type = http
    host = 127.0.0.1
    port = 8080
    keys = website-key.dat
  3. 使用docker部署,其他安装方式参考文档

    1
    2
    3
    4
    5
    6
    docker pull purplei2p/i2pd

    docker run -d --name i2pd --network=host --restart always \
    -v "$PWD/i2pd.conf:/home/i2pd/data/i2pd.conf" \
    -v "$PWD/tunnels.conf:/home/i2pd/data/tunnels.conf" \
    i2pd
  4. 获得隧道的I2P地址
    每个隧道会被赋予唯一的b32.i2p地址,记录隧道的地址。

    • 使用I2PC获取地址
      1
      2
      3
      4
      5
      6
      7
      curl -X POST http://127.0.0.1:7650/json -d '{
      "method": "TunnelInfo",
      "params": {
      "Token": "your_access_token"
      },
      "id": 2
      }'
    • 使用http获取地址
      1
      curl http://127.0.0.1:7070/?page=i2p_tunnels|grep "i2p"
  5. 连接隧道的配置
    其他设备使用i2pd连接隧道,需要设置tunnels.conf,并填写对应的b32.i2p地址:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    [ssh-tunnel]
    type = client
    destination = <ssh-tunnel b32.i2p>:22
    port = 40022
    address = 0.0.0.0
    keys = ssh-tunnel-client-key.dat
    inbound.length = 1
    outbound.length = 1

    [proxy-client]
    type = client
    destination = <proxy b32.i2p>:3128
    port = 43128
    address = 0.0.0.0
    keys = proxy-client-key.dat
  6. 测试隧道

    1
    2
    ssh 127.0.0.1:40022
    curl -X 127.0.0.1:43128 https://ifconfig.me/

相关连接

i2pd docker-compose 部署 http代理
中文论坛
Reg.i2p registry service
Let’s Decentralize
Wolfram MathWorld