G
G
gudron2018-09-05 18:27:15
linux
gudron, 2018-09-05 18:27:15

How to convert script to /etc/network/interfaces rules?

Good afternoon.
In fact, there is a Scaleway virtual machine provider.
Among its disadvantages is that instances created without an external ip cannot access the Internet.
There are many solutions, I chose to create GRE tunnels from internal virtual machines to external ones and then NAT'ing traffic through iptables MASQUERADE
Actually, this option is described here - https://community.online.net/t/yet-another-tutoria. ..
There is a bash script that raises the whole thing.

#!/bin/bash

REMOTE_ADDR="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX92.priv.cloud.scaleway.com
XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX93.priv.cloud.scaleway.com"

ip link add name br0 type bridge
ip addr add 172.16.42.254/24 dev br0
ip link set br0 up

for ADDR in $REMOTE_ADDR; do
        IP=$(getent hosts $ADDR | awk '{ print $1 }')
        IP_SANITIZED=$(echo $IP | sed 's/\./-/g')
        TUN_DEV="tun-"$IP_SANITIZED

        ip link add $TUN_DEV type gretap remote $IP ttl 64
        ip link set dev $TUN_DEV up
        ip link set dev $TUN_DEV master br0
done

I want to write "rules" for the /etc/network/interfaces file that would do the same. But I slowed down over the fact that I do not understand how to write it correctly.
the following version was born
iface br0 inet static
  description create bridge interface
  address 172.16.42.254
  netmask 24




  # hook scripts
  pre-up ip link add name br0 type bridge
  post-up ip link add tun-1 type gretap remote 10.16.167.11 ttl 64
  post-up ip link set dev tun-1 up
  post-up ip link set dev tun-1 master br0
  post-up ip link add tun-2 type gretap remote 10.16.157.141 ttl 64
  post-up ip link set dev tun-2 up
  post-up ip link set dev tun-2 master br0
  post-up ip link add tun-3 type gretap remote 10.16.119.13 ttl 64
  post-up ip link set dev tun-3 up
  post-up ip link set dev tun-3 master br0

But he doesn't seem to be correct.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Golobokov, 2018-09-06
@AVG75

auto eth1.6
iface eth1.6 inet static
  vlan_raw_device eth1
  address 10.10.55.1
  netmask 255.255.255.0
        up /etc/network/eth1_6_up.script

here eth1_6_up.script is the script that is executed when the eth1.6 interface is raised

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question