Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Evert Mouw, 2013
  4. # Modified by Marc Ranolfi, 2017-07-24
  5.  
  6. # ------------
  7. # wait for network availability
  8. # ------------
  9. TESTHOST=kernel.org
  10. while ! ping -q -c 1 $TESTHOST > /dev/null
  11. do
  12. echo "$0: Cannot ping $TESTHOST, waiting another 5 secs..."
  13. sleep 5
  14. done
  15.  
  16. # ------------
  17. # network config
  18. # ------------
  19. HWLINK=enp10s0
  20. MACVLN=macvlan0
  21.  
  22. IP=192.168.1.3/24
  23. NETWORK=192.168.1.0/24
  24. GATEWAY=192.168.1.1
  25.  
  26. # ------------
  27. # setting up $MACVLN interface
  28. # ------------
  29. ip link add link $HWLINK $MACVLN type macvlan mode bridge
  30. ip address add $IP dev $MACVLN
  31. ip link set dev $MACVLN up
  32.  
  33. # ------------
  34. # routing table
  35. # ------------
  36. # empty routes
  37. ip route flush dev $HWLINK
  38. ip route flush dev $MACVLN
  39.  
  40. # add routes
  41. ip route add $NETWORK dev $MACVLN metric 0
  42.  
  43. # add the default gateway
  44. ip route add default via $GATEWAY
  45.  
  46. [Unit]
  47. Description=Create_macvlan_bridge
  48. Wants=network-online.target
  49. After=network.target network-online.target dhcpcd.service
  50.  
  51. [Service]
  52. Type=oneshot
  53. ExecStart=/usr/local/bin/create_macvlan_bridge.sh
  54.  
  55. [Install]
  56. WantedBy=multi-user.target
  57.  
  58. systemctl disable dhcpcd
  59. systemctl enable dhcpcd@enp10s0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement