executable_brctl-start 986 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env bash
  2. set -ex
  3. case "$1" in
  4. --help)
  5. echo "Run safely, e.g.: sudo -i sh -c '/home/oleg/bin/brctl-start; sleep 120; reboot'"
  6. ;;
  7. *)
  8. if [[ $(ip a) == *"tap0"* ]]
  9. then
  10. printf "\033[35mtap0 already exists, exiting.\033[0m\n"
  11. exit 1
  12. fi
  13. ip tuntap add tap0 mode tap
  14. ip address del 192.168.0.144/24 dev enp34s0
  15. # Could break office network if tap0 is openvpn connection:
  16. brctl addbr br0
  17. brctl addif br0 tap0
  18. brctl addif br0 enp34s0
  19. ip link set br0 up
  20. ip address add 192.168.0.144/24 dev br0
  21. ip route add default via 192.168.0.1
  22. ip link set tap0 up
  23. # https://bugzilla.redhat.com/show_bug.cgi?id=542405
  24. sysctl net.bridge.bridge-nf-call-iptables=0
  25. echo "Hint: Make sure tap10 interfaces inside the bridge by invoking 'brctl addif br0 tap10' and interface is up by invoking 'ip link set tap10 up'."
  26. esac