hmgle / graftcp

A flexible tool for redirecting a given program's TCP traffic to SOCKS5 or HTTP proxy.
GNU General Public License v3.0
2.07k stars 174 forks source link

help: not support virtual machine #50

Closed wyzssw closed 2 years ago

wyzssw commented 2 years ago

Describe the bug

To Reproduce /etc/graftcp-local/graftcp-local.conf

## graftcp-local configuation

## Listen address (default ":2233")
listen = :2233

## Write logs to file, to stdout if empty
# logfile = graftcp-local.log

## Log level (0-6), 0: debug, 1: info, 2: notice, 3: warn, 4: error,
## 5: critical: 6: fatal
loglevel = 0

## Pipe path for graftcp to send address info (default "/tmp/graftcplocal.fifo")
# pipepath = /tmp/graftcplocal.fifo

## SOCKS5 address (default "127.0.0.1:1080")
socks5 = 192.168.3.35:1089

## SOCKS5 proxy username (default "")
# socks5_username = SOCKS5USERNAME

## SOCKS5 proxy password (default "")
# socks5_password = SOCKS5PASSWORD

## HTTP proxy address (default "")
http_proxy = 192.168.3.35:1088

## Set the mode for select a proxy (default "auto")
## "auto": select socks5 if socks5 is reachable, else HTTP proxy if HTTP proxy
##  is rechable, else direct.
## "random": select the reachable proxy randomly.
## "only_http_proxy": only use http proxy.
## "only_socks5": only use socks5 proxy.
## "direct": direct connect.
select_proxy_mode = only_http_proxy

## Use the system logger (syslog on Unix, Event Log on Windows)
# use_syslog = true

以上配置proxy的地址保证没有问题,因为我通过执行http_proxy=192.168.3.35:1088 curl 'http://www.google.com'是可以访问到内容的

启动graftcp-local后 /usr/bin/graftcp-local -config /etc/graftcp-local/graftcp-local.conf

执行 graftcp wget 'http://www.google.com' 依然不能翻墙 graftcp bash 同样没有效果

Expected behavior 能够翻墙

日志 从日志看,DNS没有问题,每次执行对应一条Request PID日志,就是无法翻成功

root@u1:/home/whf/install# journalctl -f -u graftcp-local.service
6月 23 07:28:32 u1 graftcp-local[35941]: [2022-06-23 07:28:32] [NOTICE] graftcp-local stop
6月 23 07:28:32 u1 systemd[1]: Stopping Translate graftcp TCP to SOCKS5 or HTTP proxy...
6月 23 07:28:32 u1 systemd[1]: graftcp-local.service: Deactivated successfully.
6月 23 07:28:32 u1 systemd[1]: Stopped Translate graftcp TCP to SOCKS5 or HTTP proxy.
6月 23 07:28:32 u1 systemd[1]: Started Translate graftcp TCP to SOCKS5 or HTTP proxy.
6月 23 07:28:32 u1 graftcp-local[45674]: [2022-06-23 07:28:32] [NOTICE] graftcp-local start
6月 23 07:28:32 u1 graftcp-local[45674]: [2022-06-23 07:28:32] [INFO] select_proxy_mode: only_http_proxy
6月 23 07:28:32 u1 graftcp-local[45674]: [2022-06-23 07:28:32] [INFO] graftcp-local start listening :2233...
6月 23 07:28:51 u1 graftcp-local[45674]: [2022-06-23 07:28:51] [INFO] Request PID: 45690, Source Addr: 127.0.0.1:46872, Dest Addr: 202.182.98.125:80
6月 23 07:31:38 u1 graftcp-local[45674]: [2022-06-23 07:31:38] [INFO] Request PID: 45742, Source Addr: 127.0.0.1:46874, Dest Addr: 31.13.84.34:80
6月 23 07:41:49 u1 graftcp-local[45674]: [2022-06-23 07:41:49] [INFO] Request PID: 46473, Source Addr: 127.0.0.1:46876, Dest Addr: 128.242.240.212:80
6月 23 07:42:15 u1 graftcp-local[45674]: [2022-06-23 07:42:15] [INFO] Request PID: 46494, Source Addr: 127.0.0.1:46878, Dest Addr: 128.242.240.212:80

Desktop (please complete the following information): 我用的windows下VMware虚拟机,虚拟机系统是Ubuntu 22.04,主机是intel nuc

root@u1:/home/whf# graftcp-local -version
graftcp-local version v0.4
root@u1:/home/whf# graftcp -V
graftcp v0.4

安装途径: 通过下载编译好的二进制deb

System:
  Host: u1 Kernel: 5.15.0-39-generic x86_64 bits: 64 Console: pty pts/4
    Distro: Ubuntu 22.04 (Jammy Jellyfish)
Machine:
  Type: Vmware System: VMware product: VMware Virtual Platform v: N/A
    serial: VMware-56 4d b2 8e 0f d8 4a e7-51 fa a1 f5 22 67 b1
  Mobo: Intel model: 440BX Desktop Reference Platform serial: N/A BIOS: Phoenix v: 6.00
    date: 07/22/2020
CPU:
  Info: 2x 1-core model: Intel Celeron J4005 bits: 64 type: SMP cache: L2: 2x 4 MiB (8 MiB)
  Speed (MHz): avg: 1997 min/max: N/A cores: 1: 1997 2: 1997
Graphics:
  Device-1: VMware SVGA II Adapter driver: vmwgfx v: 2.19.0.0
  Display: server: X.org v: 1.21.1.3 with: Xwayland v: 22.1.1 driver: gpu: vmwgfx
    note:  X driver n/a tty: 148x44
  Message: GL data unavailable in console for root.
Audio:
  Device-1: Ensoniq ES1371/ES1373 / Creative Labs CT2518 driver: snd_ens1371
  Sound Server-1: ALSA v: k5.15.0-39-generic running: yes
  Sound Server-2: PulseAudio v: 15.99.1 running: yes
  Sound Server-3: PipeWire v: 0.3.48 running: yes
Network:
  Device-1: Intel 82371AB/EB/MB PIIX4 ACPI type: network bridge driver: N/A
  Device-2: Intel 82545EM Gigabit Ethernet driver: e1000
  IF: ens33 state: up speed: 1000 Mbps duplex: full mac: 00:0c:29:22:67:b1
Bluetooth:
  Device-1: VMware Virtual Bluetooth Adapter type: USB driver: btusb
  Report: hciconfig ID: hci0 state: up address: 14:85:7F:80:95:89
Drives:
  Local Storage: total: 20 GiB used: 11.83 GiB (59.2%)
  ID-1: /dev/sda vendor: VMware model: Virtual S size: 20 GiB
Partition:
  ID-1: / size: 19.02 GiB used: 11.83 GiB (62.2%) fs: ext4 dev: /dev/sda3
  ID-2: /boot/efi size: 512 MiB used: 5.2 MiB (1.0%) fs: vfat dev: /dev/sda2
Swap:
  Alert: No swap data was found.
Sensors:
  Message: No sensor data found. Is lm-sensors configured?
Info:
  Processes: 323 Uptime: 23h 52m Memory: 3.8 GiB used: 1.78 GiB (47.0%) Init: systemd runlevel: 5
  Shell: Bash inxi: 3.3.13
hmgle commented 2 years ago

从日志上看,应该是 DNS 被污染导致的。我用 curl 试了下日志上几个 IP 返回的结果,都是返回 curl: (52) Empty reply from server。你可以用这个正常的 Google IP 试试:graftcp curl http://172.217.24.36,预期会返回如下内容:

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
wyzssw commented 2 years ago

确实如此,这个应该如何解决,我的场景是想连上k8s.grc.io来安装Kubernetes v1.24.0,使用阿里云镜像遇到了些问题。

root@u1:/home/whf#  graftcp curl http://172.217.24.36
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
hmgle commented 2 years ago

DNS 污染有很多解决方案,你可以自行搜索后选择一个适合自己的。