This is what I get when applying above sed
script to the dhcp.conf
given:
iptables -I FORWARD -s 192.168.0.254 -p tcp -m multiport --dports 110,143,25,465,585,993,995,80,443 -m mac --mac-source E8:50:8B:F3:98:F6 -j ACCEPT
iptables -I FORWARD -s 192.168.0.253 -p tcp -m multiport --dports 110,143,25,465,585,993,995,80,443 -m mac --mac-source E8:50:8B:E1:E9:35 -j ACCEPT
iptables -I FORWARD -s 192.168.0.252 -p tcp -m multiport --dports 110,143,25,465,585,993,995,80,443 -m mac --mac-source 3C:FA:43:B1:13:3A -j ACCEPT
Anything special with your dhcp.conf
? What be your sed
version?
EDIT: OK, after correcting the code tags (changed from QUOTE tags) we can see the leading whitespace in the dhcp.conf
file that need to be taken care of.
HERE YOU CAN SEE THE IMPORTANCE OF SHOWING COMMANDS AND INPUT CHARACTER BY CHARACTER, KEY STROKE BY KEY STROKE IN CODE TAGS!
Try
sed -n '/^ *hardware ethernet/ {s///; h; d;}; /^ *fixed-address / {s///; G; s/[;\n]//g; s/ / -p tcp -m multiport --dports 110,143,25,465,585,993,995,80,443 -m mac --mac-source /; s/^/iptables -I FORWARD -s /; s/$/ -j ACCEPT/; p;}' dhcp.conf