memo.log

技術情報の雑なメモ

IP over DNS を実現する iodine を試してみたメモ

メモ

  • サーバ
  • クライアント
    • WSL
    • 実IP: 192.168.201.105

サーバ手順

$ sudo apt-get install iodine
$ sudo iodined -f 192.168.1.100/24 example.com
Enter password:
Opened dns0
Setting IP of dns0 to 192.168.1.100
Setting MTU of dns0 to 1130
Opened IPv4 UDP socket
Listening to dns for domain example.com

別ウィンドウで ifconfig するとVPN用のインターフェースが上がるのが確認できる

dns0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1130
        inet 192.168.1.100  netmask 255.255.255.224  destination 192.168.1.100
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 500  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ルートにもエントリが追加される

 $ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.150.1   0.0.0.0         UG    304    0        0 wlan0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 dns0
192.168.150.0   0.0.0.0         255.255.255.0   U     304    0        0 wlan0

クライアント手順

$ sudo apt-get install iodine
$ sudo iodine -f -r kure10 example.com

クライアント側も仮想IFが立ち上がる。

dns0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1130
        inet 192.168.1.97  netmask 255.255.255.224  destination 192.168.1.97
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 500  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1  bytes 48 (48.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ちなみにルートテーブルにもエントリが追加されてる。

$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         KURE-EXPERTBOOK 0.0.0.0         UG    0      0        0 eth0
192.168.1.96    0.0.0.0         255.255.255.224 U     0      0        0 dns0
192.168.192.0   0.0.0.0         255.255.240.0   U     0      0        0 eth0

クライアントは立ち上げるときに指定した仮想IFのアドレスに疎通ができるようになる。

$ ping 192.168.1.100

動作確認

クライアント(WSLのIF)でのキャプチャ。 DNSで見えてるけど、データ部のところでICMPぽいデータが送られているのがわかる。

f:id:kuredev:20210516014207p:plain

参考

github.com

code.kryo.se