This is because your first matching regular expression:
server: 127.0.0.1
And the second one:
next_server: 127.0.0.1
As you can see, the first regular expression will match both patterns, since server: 127.0.0.1 found for both cases.
Correction: To avoid unwanted matching , you need to use word boundaries as follows:
sed -i.bak 's/\b\(server: \)127.0.0.1/\1xxx.xxx.xxx.xxx/' /etc/cobbler/settings
Note: On OSX, you need to use this strange syntax for word boundaries:
sed -i.bak 's/[[:<:]]\(server: \)127.0.0.1/\1xxx.xxx.xxx.xxx/' /etc/cobbler/settings
source share