Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #set /augeas/load/Interfaces/incl /interfaces*
- #load
- defvar base /files//interfaces
- # Locate back interface
- 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]
- match $back
- # If it exists, remove gateway
- rm $back/gateway
- print $back
- # If it does not exist, add 10/8 route
- 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]
- match $need10
- set $need10/up[last()+1] 'ip route add 10.0.0.0/8 via 1.1.1.1'
- print $back
- # If it does not exist, add 192.168/16 route
- 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]
- match $need192
- set $need192/up[last()+1] 'ip route add 192.168.0.0/16 via 1.1.1.1'
- # Remove 192.168/20
- 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]
- # No 'down ip route del'
- rm $base/iface[*]/down[. =~ regexp('ip route del.*')]
- save
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement