#!/bin/bash
#1. 修改IP地址
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 <<EOF
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.5.$1
PREFIX=24
GATEWAY=192.168.5.2
DNS1=192.168.5.2
NAME=eth0
EOF
#2. 修改网卡脚本
sed -i '/eth0/d' /etc/udev/rules.d/70-persistent-net.rules
sed -i 's/eth1/eth0/g' /etc/udev/rules.d/70-persistent-net.rules
#3. 修改主机名
sed -i "s/HOSTNAME=.*/HOSTNAME=hadoop$1/g" /etc/sysconfig/network
网友评论