diff options
author | Bill Nottingham <notting@redhat.com> | 2010-11-30 21:53:02 -0500 |
---|---|---|
committer | Bill Nottingham <notting@redhat.com> | 2010-11-30 21:53:02 -0500 |
commit | ff5befb95b133cc1da3f32ffcd9f3cef779244b6 (patch) | |
tree | c2f360e405892a0add6ac011917d96c3fe2374aa /sysconfig/network-scripts/network-functions | |
parent | d624aba089bd95acfe8f02bebb01c34a4f242216 (diff) | |
download | initscripts-ff5befb95b133cc1da3f32ffcd9f3cef779244b6.tar initscripts-ff5befb95b133cc1da3f32ffcd9f3cef779244b6.tar.gz initscripts-ff5befb95b133cc1da3f32ffcd9f3cef779244b6.tar.bz2 initscripts-ff5befb95b133cc1da3f32ffcd9f3cef779244b6.tar.xz initscripts-ff5befb95b133cc1da3f32ffcd9f3cef779244b6.zip |
Support multiple IP addreses via IPADDRn, PREFIXn (or NETMASKn) (#633984) Adapted from <jklimes@redhat.com>
In addition to legacy IP aliases, this commit adds a support for configuring
mupliple IPs via single ifcfg file. It uses the same syntax and behaviour as
NetworkManager.
Diffstat (limited to 'sysconfig/network-scripts/network-functions')
-rw-r--r-- | sysconfig/network-scripts/network-functions | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions index 9645a379..3b5695f7 100644 --- a/sysconfig/network-scripts/network-functions +++ b/sysconfig/network-scripts/network-functions @@ -156,20 +156,36 @@ source_config () expand_config () { - if [ -z "${NETMASK}" ]; then - eval $(/bin/ipcalc --netmask ${IPADDR}) - fi + local i=0 val + for idx in '' {0..255} ; do + ipaddr[$i]=$(eval echo '$'IPADDR$idx) + if [ -z "${ipaddr[$i]}" ]; then + [ "$idx" ] && [ $idx -gt 2 ] && break + continue + fi + prefix[$i]=$(eval echo '$'PREFIX$idx) + netmask[$i]=$(eval echo '$'NETMASK$idx) + broadcast[$i]=$(eval echo '$'BROADCAST$idx) - if [ -z "${PREFIX}" ]; then - eval $(/bin/ipcalc --prefix ${IPADDR} ${NETMASK}) - fi + if [ "${netmask[$i]}x" = "x" ]; then + val=$(/bin/ipcalc --netmask "${ipaddr[$i]}") + netmask[$i]=${val##NETMASK=} + fi - if [ -z "${BROADCAST}" ]; then - eval $(/bin/ipcalc --broadcast ${IPADDR} ${NETMASK}) - fi + if [ "${prefix[$i]}x" = "x" ]; then + val=$(/bin/ipcalc --prefix ${ipaddr[$i]} ${netmask[$i]}) + prefix[$i]=${val##PREFIX=} + fi + + if [ "${broadcast[$i]}x" = "x" ]; then + val=$(/bin/ipcalc --broadcast ${ipaddr[$i]} ${netmask[$i]}) + broadcast[$i]=${val##BROADCAST=} + fi + i=$((i+1)) + done if [ -z "${NETWORK}" ]; then - eval $(/bin/ipcalc --network ${IPADDR} ${NETMASK}) + eval $(/bin/ipcalc --network ${ipaddr[0]} ${netmask[0]}) fi } |