Hello! There is a linux server, an ssh tunnel is connected to it. How to add this ssh-tunnel to network / interfaces so that the server would see it as an additional ip?

This can be done via ipip tunnel or pptp, but I need it via ssh. Since there are 10 servers to which I connect via ssh tunnel and I need to add 10 interfaces with different external IPs. Tell me, how can this be implemented?

PS: on servers to which I connect via ssh nothing can be done

  • one
    Here habrahabr.ru/post/87197 write how the tunnel rises, but ifconfig is required on both sides of the connection, i.e. you need root access to both hosts - Mike
  • so i can do it. This is too simple, but in my case, impossible. I can only make a connection via ssh or openssh or somehow make a vpn from an ssh tunnel (I don’t know how yet). And I need to add the external IP that I received from the ssh connection in etc / interfaces. - bossuvarkin
  • it's not entirely clear what exactly you need. What is the original task / problem? - aleksandr barakin
  • @bossuvarkin In the question, add what is your distribution. in gentoo and debian I didn’t find / etc / interfaces - Mike
  • one
    You can also try sshuttle: debian.pro/1747 - sercxjo

2 answers 2

Before you start the ssh daemon in Point-to-Point mode, you need to prepare a tun device for each server in advance. This can be done in two ways:

  1. Command ip tuntap:
ip tuntap add dev tun0 mode tun 
  1. Keep your devices ready by adding a device to / etc / systemd / network / netdev:
[NetDev] Name=tun0 Kind=tun #Разрешить доступ пользователям входящим в группу vpn [Tun] Group=vpn
[NetDev] Name=tun0 Kind=tun #Разрешить доступ пользователям входящим в группу vpn [Tun] Group=vpn 

And network file:

[Match] Name=tun0 [Address] Address=172.17.0.1/30 Peer=172.17.0.2/30 [Network] Address=172.17.0.1/30 [Route] Gateway=172.17.0.1 Destination=192.168.1.0/24
[Match] Name=tun0 [Address] Address=172.17.0.1/30 Peer=172.17.0.2/30 [Network] Address=172.17.0.1/30 [Route] Gateway=172.17.0.1 Destination=192.168.1.0/24 

The second option is preferable because:

  • firewall will know about the presence of such devices
  • An unmovable user can open the tunnel
  • You can set up routes in advance, and not register them every time you want to connect

Guide to raising a tunnel by unmovable users

    You can build / load slirp on the server and raise ppp via ssh (root is not needed) https://en.wikipedia.org/wiki/Slirp http://math.arizona.edu/~swig/documentation/slirp/windows/win2000 .php