26
2019
03
10:18:36

iptunnel



推荐点击下面图片,通过本站淘宝优惠价购买:

image.png

这个周末终于解决了这个问题。再Linux 2.4 上配置成功了!首先linux要先配置为一个router。注意要设置ip_forward=1。然后加入net-tools中的iptunnel命令和ipip.o模块。条件有限,没有在WAN上试验,仅仅在LAN中建立了如下的测试环境:本地LAN使用192.168.4.0网段,远程LAN使用192.168.3.0网段。设置两个网关。两个网关使用HUB连接。测试PC和网关之间使用交叉网线直接连接。如果大家有条件,可以把两个网关的eth1接口换成PPP或是ADSL,建立一个真正的WAN中的ip tunnel。

网络拓扑如下:

PC1<--->gateway1 gateway2<---> PC2 
eth0 eth1 eth1 eth0

PC1 IP: 192.168.4.143 default gateway:192.168.4.1 netmask 255.255.255.0 
PC2 IP: 192.168.3.137 default gateway:192.168.3.1 netmask 255.255.255.0

gateway1 eth0连接pc1,eth1连接外网。 eth0: 192.168.4.1 eth1:192.168.2.10

gateway2 eth0连接pc2,eth1连接外网。 eth0: 192.168.3.1 eth1: 192.168.2.11

配置步骤如下:

1 在 gateway1上:

ifconfig检查eth0 eth1 IP地址正确

insmod ipip.o

lsmod检查ipip模块加载成功

iptunnel add tunl1 mode ipip remote gateway2-eth1-IP

ifconfig tunl1 gateway1-eth0-IP

route add -host gateway2-eth1-IP dev tunl1

route add -net 远程网段(本试验中是192.168.3.0)netmask 255.255.255.0 gw gateway2-eth1-IP

route del -host gateway2-eth1-IP dev tunl1

MAKE SURE ip_forward == 1 我开始就是因为这个而麻烦了一次。

2 在gateway2上作类似的配置操作:

ifconfig检查eth0 eth1 IP地址正确

insmod ipip.o

lsmod检查ipip模块加载成功

iptunnel add tunl1 mode ipip remote gateway1-eth1-IP

ifconfig tunl1 gateway2-eth0-IP

route add -host gateway1-eth1-IP dev tunl1

route add -net 远程网段(本试验中是192.168.4.0)netmask 255.255.255.0 gw gateway1-eth1-IP

route del -host gateway1-eth1-IP dev tunl1

MAKE SURE ip_forward == 1 我开始就是因为这个而麻烦了一次。

配置成功,在PC1上ping PC2,可以ping通。在HUB上使用sniffer,可以看到icmp包已经变为ipip协议类型的了!


本文链接:https://hqyman.cn/post/423.html 非本站原创文章欢迎转载,原创文章需保留本站地址!

分享到:





休息一下,本站随机推荐观看栏目:


« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

您的IP地址是: