-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path040-network.sh
More file actions
55 lines (46 loc) · 1.36 KB
/
Copy path040-network.sh
File metadata and controls
55 lines (46 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/sh -x
# Generate generic /etc/hosts file
cat > /etc/hosts << EOT
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
EOT
# Network sysconfig
cat > /etc/sysconfig/network << EOT
NETWORKING=yes
NOZEROCONF=yes
NETWORKING_IPV6=no
IPV6INIT=no
EOT
# Disable ipv6
echo "options ipv6 disable=1" >> /etc/modprobe.d/ipv6.conf
echo "net.ipv6.conf.all.disable_ipv6=1" >> /etc/sysctl.d/ipv6.conf
# Set default NIC config for eth0 device
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF
DEVICE="eth0"
BOOTPROTO="dhcp"
ONBOOT="yes"
TYPE="Ethernet"
USERCTL="yes"
PEERDNS="yes"
IPV6INIT="no"
PERSISTENT_DHCLIENT="1"
EOF
# Dhcp client config
cat >> /etc/dhcp/dhclient.conf << EOF
timeout 300;
retry 60;
EOF
# Clean up any network info for cloning
sed -i -e '/^HWADDR/d' -e '/^UUID/d' /etc/sysconfig/network-scripts/ifcfg-*
# Remove 70 udev rules
if [ -f "/etc/udev/rules.d/70-persistent-net.rules" ]; then
rm /etc/udev/rules.d/70-persistent-net.rules
fi
# Retain eth0 naming in AWS
ln -fs /dev/null /etc/udev/rules.d/80-net-name-slot.rules
# rename biosdevname files
i=0
for _nic in $(find /etc/sysconfig/network-scripts/ifcfg-* ! -name ifcfg-lo); do
mv $_nic /etc/sysconfig/network-scripts/ifcfg-eth${i}
sed -i -e "s/^DEVICE=.*/DEVICE=eth${i}/" -e "s/^NAME=.*/NAME=eth${i}/" /etc/sysconfig/network-scripts/ifcfg-eth${i}
i=$(expr $i + 1)
done