#!/bin/bash
netdev="$(ip a | grep 'state UP' | cut -d' ' -f2 | cut -d: -f1)"
read -p 'Digite o IP deste player: ' ipn < /dev/tty
baseip="$(echo ${ipn} | cut -d. -f1-3)"
dns="10.195.30.40"
mask="255.255.255.224"
gateway="${baseip}.62"
cat <<EOF | sudo tee /etc/netplan/01-netcfg.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    ${netdev}:
      dhcp4: no
      addresses:
        - ${ipn}/27
      gateway4: ${gateway}
      nameservers:
          addresses: [${dns}]
EOF
netplan apply
