Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #set /augeas/load/Interfaces/incl /interfaces*
  2. #load
  3. defvar base /files//interfaces
  4.  
  5. # Locate back interface
  6. defvar back $base/iface[gateway = '1.1.1.1' or count(up[. =~ regexp('ip route add 10.0.0.0/8 via 1.1.1.1.*') and count(self[. =~ regexp('ip route add 10.0.0.0/8.* table.*')]) = 0]) = 1]
  7.  
  8. match $back
  9.  
  10. # If it exists, remove gateway
  11. rm $back/gateway
  12.  
  13. print $back
  14.  
  15. # If it does not exist, add 10/8 route
  16. defvar need10 $back[count(up[. =~ regexp('ip route add 10.0.0.0/8 via 1.1.1.1.*')]) - count(up[. =~ regexp('ip route add 10.0.0.0/8 via 1.1.1.1.* table.*')]) = 0]
  17.  
  18. match $need10
  19.  
  20. set $need10/up[last()+1] 'ip route add 10.0.0.0/8 via 1.1.1.1'
  21.  
  22. print $back
  23.  
  24. # If it does not exist, add 192.168/16 route
  25. defvar need192 $back[count(up[. =~ regexp('ip route add 192.168.0.0/16 via 1.1.1.1.*')]) - count(up[. =~ regexp('ip route add 192.168.0.0/16 via 1.1.1.1.* table')]) = 0]
  26.  
  27. match $need192
  28.  
  29. set $need192/up[last()+1] 'ip route add 192.168.0.0/16 via 1.1.1.1'
  30.  
  31. # Remove 192.168/20
  32. rm $back/up[. =~ regexp('ip route add 192.168.0.0/20 via 1.1.1.1.*') and count(self[. =~ regexp('ip route add 192.168.0.0/20.* table.*')]) = 0]
  33.  
  34. # No 'down ip route del'
  35. rm $base/iface[*]/down[. =~ regexp('ip route del.*')]
  36.  
  37. save
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement