安装tunctl用于新建TAP/TUN设备,TAP为以太网设备,TUN为网络层设备。
yum install tunctl
#debian下为uml-utilities
Client配置:
tunctl -t tap1
ifconfig tap4 192.168.1.1 netmask 255.255.255.0 up
Server配置:
tunctl -t tap2
ifconfig tap2 192.168.1.2 netmask 255.255.255.0 up
echo "PermitTunnel yes" >> /etc/ssh/sshd_config
Client发起SSH Tunnel连接:
ssh -N -f -o Tunnel=ethernet -w 1:2 remote-host
#-w local tap id:remote tap id