【tinc】tinc服务满足跨域隧道访问

背景:

idc机房与公司办公网互通

操作如下:

服务端:

yum -y install tinc

tinc.conf:该文件主要描述了当前节点的名字,使用的虚拟网卡等。

rsa_key.priv:该文件是私钥文件,由tincd工具生成。

tinc-up:网络建立前需要执行的操作

tinc-down:网络建立后需要执行的操作

[root@VM_1_45_centos tp-3399_f]# ls

box_demo  createip.sh  hosts  rsa_key.priv  tinc.conf  tinc-down  tinc-up

[root@VM_1_45_centos tp-3399_f]# 

[root@VM_1_45_centos tp-3399_f]# cat tinc.conf 

Name=tpserver

Interface=tp-3399_f

Mode=switch

TCPOnly=yes

#Port=64523

PrivateKeyFile=/etc/tinc/tp-3399_f/rsa_key.priv

[root@VM_1_45_centos tp-3399_f]# cat tinc-up 

#!/bin/sh

ifconfig $INTERFACE 10.99.1.1 netmask 255.255.0.0

[root@VM_1_45_centos tp-3399_f]# cat tinc-down 

#!/bin/sh 

ifconfig $INTERFACE down

[root@VM_1_45_centos tp-3399_f]# 

#生成key

[root@VM_1_45_centos tp-3399_f]#tincd -n tincnet -K 4096

[root@VM-1-91-centos tp-3399_f]# cat hosts/box_40_91 
Compression=8
Subnet=10.90.1.91/32
PublicKeyFile=/etc/tinc/tpnet_tx_client/rsa_key.public

[root@VM-1-91-centos tp-3399_f]# cat hosts/tpserver 
Compression=8
Subnet=10.90.1.1/32
Address=10.40.1.45
Port=64550

-----BEGIN RSA PUBLIC KEY-----
xxx
-----END RSA PUBLIC KEY-----
[root@VM-1-91-centos tp-3399_f]# 

客户端:

客户端与服务的唯一不同的操作就是 tinc.conf的配置:

[root@VM-1-91-centos tp-3399_f]# cat tinc.conf 

Name=box_40_91

ConnectTo=tpserver  

Interfce=tp-3399_f

Mode=switch  

TCPOnly=yes  

Port=659

PrivateKeyFile=/etc/tinc/tp-3399_f/rsa_key.priv

[root@VM-1-91-centos tp-3399_f]# 

[root@VM-1-91-centos tp-3399_f]# ls

hosts  rsa_key.priv  tinc.conf  tinc-down  tinc-up

[root@VM-1-91-centos tp-3399_f]# ls hosts/

box_40_91  tpserver

[root@VM-1-91-centos tp-3399_f]# cat hosts/box_40_91 

Compression=8

Subnet=10.90.1.91/32

PublicKeyFile=/etc/tinc/tpnet_tx_client/rsa_key.public

[root@VM-1-91-centos tp-3399_f]# cat hosts/tpserver 

Compression=8

Subnet=10.90.1.1/32

Address=10.40.1.45

Port=64550

-----BEGIN RSA PUBLIC KEY-----

xxx

-----END RSA PUBLIC KEY-----

[root@VM-1-91-centos tp-3399_f]# cat tinc-up 

#!/bin/sh

ifconfig $INTERFACE 10.99.1.91 netmask 255.255.0.0

[root@VM-1-91-centos tp-3399_f]# cat tinc-down 

#!/bin/sh

ifconfig $INTERFACE down 

多了connectto的字段配置。

到此,隧道达成可访问,如果想访问与服务端想通的网段就需要宣告路由:

route add -net 10.40.1.0/24 dev tp-3399_f(此处添加的静态路由是idc机房网段或者腾讯云主机内网ip网段)

注意防火墙,有防火墙记得关了,以及如果是云主机搭建安全组端口开放等等。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值