It turns out that iptables doesn\'t handle leading zeros too well. As $machinenumber that is used has to have a leading zero in it for other purposes, the idea
No, you make all (alomost all) correct. You just must:
=$() or backticks instead of ()That would be correct:
nozero=$(echo $machinenumber | sed 's/^0*//')
Also you must use variables without () around them. You can add "" if you want:
iptables -t nat -I POSTROUTING -s "10.$machinetype.$nozero.0/24" -j MASQUERADE
And of course variables here are not necessary. You can say simply:
iptables -t nat -I POSTROUTING -s "10.$(echo $machinenumber | sed 's/^0*//').$nozero.0/24" -j MASQUERADE