n2n 连接总是不成功 求解

2016-05-29 10:38:41 +08:00
 skywing

1 supernode 是我用自己的美国 vps 搭建的,搭建过程如下

svn co https://svn.ntop.org/svn/ntop/trunk/n2n
  cd n2n/n2n_v1
  make #过程无报错
  nohup ./supernode -l 6489 & #防火墙已开放 6489 端口
  ps -A | grep supernode
  22610 pts/3    00:00:00 supernode

2 edge1 号为家里的路由器 openwrt 固件 1 安装 n2n

 opkg update
  opkg install n2n

2 修改配置文件


  cat > /etc/config/n2n << EOF
  config edge
   option ipaddr	'10.10.88.1'
   option supernode	'88.86.108.50'
   option port		'82'
   option community	'skywing'
   option key		'n2n1234'
  option route	'1'
  EOF

3 修改启动文件


 vi /etc/init.d/n2n
 #在 start()区域加入如下
 ifconfig edge0 mtu 1300    #修改 MTU 为 1300
 brctl addif br-lan edge0  #把 n2n 桥接到 lan  就可以用 DHCP 了

4 启动并加入开机启动


 /etc/init.d/n2n start
 /etc/init.d/n2n enable

3 edge2 号为公司的 linux 电脑 ubuntu 系统


	svn co https://svn.ntop.org/svn/ntop/trunk/n2n
  	cd n2n/n2n_v1
   make
   sudo ./edge -a 10.10.88.2 -c skywing -k n2n373114 -l 205.209.188.106:6489 -M 1300 -v | grep xxx.xxx.xxx.xxx (家里网络的公网 IP )

有看到输出 29/May/2016 10:38:32 [ n2n.c: 49] Unmarshalled hdr: public_ip=(2)xxx.xxx.xxx.xxx:3022, private_ip=(2)0.0.0.0:40297

但我在公司电脑 ping 家里路由 ping 不通 求解怎么回事? skywing@ubuntu:~$ ping 10.10.88.1 PING 10.10.88.1 (10.10.88.1) 56(84) bytes of data. From 10.10.88.2 icmp_seq=1 Destination Host Unreachable From 10.10.88.2 icmp_seq=2 Destination Host Unreachable From 10.10.88.2 icmp_seq=3 Destination Host Unreachable From 10.10.88.2 icmp_seq=4 Destination Host Unreachable From 10.10.88.2 icmp_seq=5 Destination Host Unreachable From 10.10.88.2 icmp_seq=6 Destination Host Unreachable From 10.10.88.2 icmp_seq=7 Destination Host Unreachable From 10.10.88.2 icmp_seq=8 Destination Host Unreachable From 10.10.88.2 icmp_seq=9 Destination Host Unreachable From 10.10.88.2 icmp_seq=10 Destination Host Unreachable

7598 次点击
所在节点    问与答
6 条回复
qianshizhou
2016-05-29 11:06:39 +08:00
nohup edge -d vpn0 -a 192.168.150.3 -c hi -k hello -s 255.255.255.0 -u pi -g pi -l me.club:9118 -m 00:02:03:04:05:06 -M 1200 -r -b &

这个是我的配置,使用挺好的。换成你自己的信息。 n2n 的 supernode 最好用国内的,快。我自己树莓派和腾讯云只有 10ms
64 bytes from 192.168.150.1: icmp_req=2 ttl=64 time=6.89 ms
64 bytes from 192.168.150.1: icmp_req=3 ttl=64 time=8.99 ms
64 bytes from 192.168.150.1: icmp_req=4 ttl=64 time=6.08 ms
64 bytes from 192.168.150.1: icmp_req=5 ttl=64 time=25.1 ms
64 bytes from 192.168.150.1: icmp_req=6 ttl=64 time=9.60 ms

我现在的网络拓扑非常复杂,家里和腾讯云 n2n. 腾讯云 和其它 vps,公司走的 vpn. 所有网络互联互通
qianshizhou
2016-05-29 11:12:08 +08:00
你这个不通是因为你把 n2n 桥接了,还开了 dhcp. 目前这个不支持。还是用点对点,自己在两端设置 SNAT 和路由
skywing
2016-05-29 14:28:23 +08:00
@qianshizhou 把桥接去掉后现在能正常连接了,谢谢! linux ping 家里的路由比较正常 20-30ms 左右 (同个城市)。公司另一台电脑 windows 连接上去就不正常, ping 到了 360ms 左右,明显是去美国绕了一圈再回来了,这是怎么回事呢? windows 和 linux 在一个子网内,为什么一个正常一个不正常?
windows ping 在同一个子网的 linux 也不正常,求解?
qianshizhou
2016-05-29 15:12:17 +08:00
@skywing 这个没办法, Windows 貌似不太支持 tun 模式。都是用 tap/30 模拟的,所以 windows 比 Linux 多一层协议处理。一般都在 windows 用 openvpn ,优化足够好
jasontse
2016-05-29 15:19:49 +08:00
在 OpenWrt 新建 Interface , Device 选择 edge0 并放入 LAN firewall zone ,这样就通了。

关于绕美国,给 edge 绑定一个 Local port 然后在防火墙中打开它,重启所有 edge 。
skywing
2016-05-29 23:06:27 +08:00
@jasontse 感谢,能具体说说吗?或者有文章教程推荐下?

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/281981

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX