executable_iproute2-bridge 668 B

123456789101112131415161718192021222324
  1. #!/bin/sh
  2. # Create bridge network
  3. # Copyright © 2019, 2020 Oleg Pykhalov <go.wigust@gmail.com>
  4. # Released under the GNU GPLv3 or any later version.
  5. # https://wiki.archlinux.org/index.php/Network_bridge#With_iproute2
  6. bridge_name=br0
  7. interface_name=enp9s0
  8. network=192.168.105.120/24
  9. default_gw=192.168.105.1
  10. # https://bugzilla.redhat.com/show_bug.cgi?id=542405
  11. sysctl net.bridge.bridge-nf-call-iptables=0
  12. ip address del "$network" dev "$interface_name"
  13. ip link add name "$bridge_name" type bridge
  14. ip link set "$bridge_name" up
  15. ip link set "$interface_name" master "$bridge_name"
  16. ip address add "$network" dev "$bridge_name"
  17. ip route add default via "$default_gw"