---------- / \ _ / - \ / \ / - \ ----------------- | Client | ~~~~~~~ / Internet / ~~~~~~~ | Server | ---------- \ _ / - \ / \ _ / \ / / ----------------- || \ \ || \ || {tun0} {vlan8} || {tun1} || || \ - ================= tunnel ============== - / * vlan8 - 212.90.160.1/27 * tun0 - 10.254.254.2/30 * tun1 - 10.254.254.1/30
# sudo ssh-keygen -t rsa -b 4096 # ssh-copy-id -i .ssh / id_rsa.pub root@212.90.160.1
The authenticity of host '212.90.160.1 (212.90.160.1)' can't be established. RSA key fingerprint is aa: fe: a0: 38: 7d: 11: 78: 60: 01: b0: 80: 78: 90: ab: 6a: d2. Are you sure you want to continue connecting (yes / no)? yes Warning: Permanently added '212.90.160.1' (RSA) to the list of known hosts.
auto tun0 iface tun0 inet static pre-up ssh -S / var / run / ssh-myvpn-tunnel-control -M -f -w 0: 1 212.90.160.1 true pre-up sleep 5 post-up ip ls tun0 mtu 1300 address 10.254.254.2 netmask 255.255.255.252 pointopoint 10.254.254.1 post-down ssh -S / var / run / ssh-myvpn-tunnel-control -O exit 212.90.160.1
PermitTunnel point-to-point PermitRootLogin forced-commands-only
tunnel = "1", command = "/ sbin / ifdown tun1; / sbin / ifup tun1" ssh-rsa AAAA ...... X9vc = root @ ipclub
auto vlan8 iface vlan8 inet static address 212.90.160.1 netmask 255.255.255.224 network 212.90.160.0 broadcast 212.90.160.31 gateway 212.90.160.30 vlan_raw_device eth0 mtu 1400 iface tun1 inet static address 10.254.254.1 netmask 255.255.255.252 pointopoint 10.254.254.2 post-up ip ls tun0 mtu 1300
net.ipv4.conf.default.forwarding = 1
$ sudo sysctl net.ipv4.conf.default.forwarding = 1
$ sudo ifup tun0 $ ip al dev tun0 9: tun0: mtu 1300 qdisc pfifo_fast qlen 500 link / [65534] inet 10.254.254.2 peer 10.254.254.1/30 scope global tun0 $ ping -c2 10.254.254.1 PING 10.254.254.1 (10.254.254.1): 56 data bytes 64 bytes from 10.254.254.1: icmp_seq = 0 ttl = 64 time = 15.116 ms 64 bytes from 10.254.254.1: icmp_seq = 1 ttl = 64 time = 16.454 ms --- 10.254.254.1 ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min / avg / max / stddev = 15.116 / 15.785 / 16.454 / 0.669 ms
$ sudo tshark -tad -pni tun1 Running as user "root" and group "root". This could be dangerous. Capturing on tun1 2009-03-10 11: 25: 53.927598 10.254.254.2 -> 10.254.254.1 ICMP Echo (ping) request 2009-03-10 11: 25: 53.927649 10.254.254.1 -> 10.254.254.2 ICMP Echo (ping) reply 2009-03-10 11: 25: 54.567857 10.254.254.2 -> 10.254.254.1 ICMP Echo (ping) request 2009-03-10 11: 25: 54.567910 10.254.254.1 -> 10.254.254.2 ICMP Echo (ping) reply
$ cat /etc/cron.d/tun0 PATH = / usr / local / sbin: / usr / local / bin: / sbin: / bin: / usr / sbin: / usr / bin * / 5 * * * * root fping -c4 10.254.254.1 || (/ sbin / ifdown tun0; sleep 5; / sbin / ifup tun0) $ sudo /etc/init.d/cron restart
Source: https://habr.com/ru/post/81638/
All Articles