Skip to contentSkip to conversation

write-ifcfg.sh: Don't overwrite network config in root filesystem

PATCH In review Gerhard Wiesinger 2 participants 4 messages Jun 21, 2014 – Jun 25, 2014 3 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 write-ifcfg.sh: Don't overwrite network config in root filesystem

This patch adds the possibility to keep the original network configuration specified in the root filesystem. This is necessary in situations with dual stack IPv4 and IPv6 configurations or different kind on nameservers (e.g. public ones at boot time, running a dns server on localhost later on).

Keeping original configuration can be activated by:
networkstatic=yes
on the kernel boot command line.

---
 modules.d/45ifcfg/write-ifcfg.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
modules.d/45ifcfg/write-ifcfg.sh +5 -2
index 803ae8e..033abe5 100755
@@ -277,7 +277,10 @@ echo "files /etc/sysconfig/network-scripts" >> /run/initramfs/rwtab
 echo "files /var/lib/dhclient" >> /run/initramfs/rwtab
 {
     cp /tmp/net.* /run/initramfs/
-    cp /tmp/net.$netif.resolv.conf /run/initramfs/state/etc/resolv.conf
-    copytree /tmp/ifcfg /run/initramfs/state/etc/sysconfig/network-scripts
+    networkstatic="$(getarg networkstatic=)"
+    if [ -z "${networkstatic}" ]; then
+        cp /tmp/net.$netif.resolv.conf /run/initramfs/state/etc/resolv.conf
+        copytree /tmp/ifcfg /run/initramfs/state/etc/sysconfig/network-scripts
+    fi
     cp /tmp/ifcfg-leases/* /run/initramfs/state/var/lib/dhclient
 } > /dev/null 2>&1
Signature · 1 line
1.9.3

A message that is not in the archive (sent off-list or not yet received): alpine.LFD.2.02.1406211239250.1876-GinJ0NHkz1PSbTvUbH3RCA@public.gmane.org

#2 lore raw
Quoted 25 lines · Gerhard Wiesinger

This patch adds the possibility to keep the original network configuration specified in the root filesystem. This is necessary in situations with dual stack IPv4 and IPv6 configurations or different kind on nameservers (e.g. public ones at boot time, running a dns server on localhost later on).

Keeping original configuration can be activated by:
networkstatic=yes
on the kernel boot command line.

---
 modules.d/45ifcfg/write-ifcfg.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
modules.d/45ifcfg/write-ifcfg.sh +0 -0
index 803ae8e..033abe5 100755
@@ -277,7 +277,10 @@ echo "files /etc/sysconfig/network-scripts" >>

/run/initramfs/rwtab
echo "files /var/lib/dhclient" >> /run/initramfs/rwtab {
cp /tmp/net.* /run/initramfs/

modules.d/45ifcfg/write-ifcfg.sh echo "files /etc/sysconfig/network-scripts" >> /run/initramfs/rwtab · line 286

Quoted 9 lines
modules.d/45ifcfg/write-ifcfg.sh +5 -2
-    cp /tmp/net.$netif.resolv.conf /run/initramfs/state/etc/resolv.conf
-    copytree /tmp/ifcfg /run/initramfs/state/etc/sysconfig/network-scripts
+    networkstatic="$(getarg networkstatic=)"
+    if [ -z "${networkstatic}" ]; then
+        cp /tmp/net.$netif.resolv.conf /run/initramfs/state/etc/resolv.conf
+        copytree /tmp/ifcfg /run/initramfs/state/etc/sysconfig/network-scripts
+    fi
     cp /tmp/ifcfg-leases/* /run/initramfs/state/var/lib/dhclient
 } > /dev/null 2>&1

I don't understand this. It only copies to /run/initramfs. If you want to keep your original network configuration, just don't copy over the files from /run/initramfs to your root filesystem.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 8 lines · Harald Hoyer
Quoted 7 lines · Gerhard Wiesinger

This patch adds the possibility to keep the original network configuration specified in the root filesystem. This is necessary in situations with dual stack IPv4 and IPv6 configurations or different kind on nameservers (e.g. public ones at boot time, running a dns server on localhost later on).

Quoted 8 lines
Quoted 8 lines

Keeping original configuration can be activated by:
networkstatic=yes
on the kernel boot command line.

I don't understand this. It only copies to /run/initramfs. If you want to keep your original network configuration, just don't copy over the files from /run/initramfs to your root filesystem.

Hello Harald,

The topic is: /etc/sysconfig/network-scripts/ifcfg-eth0 is overwritten by dracut when network config is specified on boot command line (e.g. grub config). As normal config is different and more complex (e.g. IPv6 setup) boot config is different.

I found, that this patch doesn't overwrite the network config in /etc/sysconfig/network-scripts/ifcfg-eth0 when you specify network config on the boot command line.

I didn't debug into details and I'm not familiar with dracut in detail so I can't say why it works but it works. I think that some other code parts copy the initramfs afterwards to /etc/sysconfig/....

But maybe you can clarify it.

Ciao,
Gerhard

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 29 lines · Gerhard Wiesinger
Quoted 8 lines · Harald Hoyer
Quoted 7 lines · Gerhard Wiesinger

This patch adds the possibility to keep the original network configuration specified in the root filesystem. This is necessary in situations with dual stack IPv4 and IPv6 configurations or different kind on nameservers (e.g. public ones at boot time, running a dns server on localhost later on).

Quoted 8 lines
Quoted 8 lines

Keeping original configuration can be activated by:
networkstatic=yes
on the kernel boot command line.

I don't understand this. It only copies to /run/initramfs. If you want to keep your original network configuration, just don't copy over the files from /run/initramfs to your root filesystem.

Hello Harald,

The topic is: /etc/sysconfig/network-scripts/ifcfg-eth0 is overwritten by dracut when network config is specified on boot command line (e.g. grub config). As normal config is different and more complex (e.g. IPv6 setup) boot config is different.

I found, that this patch doesn't overwrite the network config in /etc/sysconfig/network-scripts/ifcfg-eth0 when you specify network config on the boot command line.

Quoted 8 lines

I didn't debug into details and I'm not familiar with dracut in detail so I can't say why it works but it works. I think that some other code parts copy the initramfs afterwards to /etc/sysconfig/....

But maybe you can clarify it.

Ciao,
Gerhard

On Fedora, this is fedora-import-state.service, which calls /lib/systemd/fedora-import-state.

You could disable/mask that with:

$ sudo systemctl mask fedora-import-state.service