Sponsored Content
Special Forums IP Networking Script for Changing an IP address remotely Post 302243550 by nua7 on Monday 6th of October 2008 03:12:27 AM
Old 10-06-2008
This is what we use to assign a ip to a new machine. This would give you an idea, please make changes according to your requirements..


Code:
#!/bin/ksh
###############################################################################
#                                                                             #
# NAME        : cnfg_cm.sh                                                    #
# DESCRIPTION : This script will make changes in the following files:         #
#               a)/etc/sysconfig/network-scripts/ifcfg-eth0                   #
#               b)/etc/hosts                                                  #
#               c)/etc/sysconfig/network                                      #
#               d)/etc/security/access.conf                                   #
#                                                                             #        
#                                                                             #
#  Ver  Date      Description                            Analyst              #
#  ---  --------  -------------------------------        ---------------      #
#  A00  02-06-08  Original implementation                nua7                 #
###############################################################################
#Usage of the script is as follows:
#checking the variables passed
if [ $# -lt 2 ] ; then
      echo need 2 files  
      exit 0
fi
######
# Ensuring that only root can run this script
######
logonID=`whoami`
if test "$logonID" != "root"
then
  echo "\nYou should logon as MGR for running this script"
  exit
fi
#setting up variables
ips=$1
domain_name=".xyz.com"
mc_name=$2
export ips
#Modifying the ifcfg-eth0 file
awk -v ip=$ips '/ONBOOT=no/{
print
print "DEVICE=eth0"
print "BOOTPROTO=static"
print "IPADDR=" ip
print "NETMASK=255.255.255.0"
print "GATEWAY=123.123.123.1"
next
}1' /etc/sysconfig/network-scripts/ifcfg-eth0> /etc/sysconfig/network-scripts/temp1

sed -e's/no/yes/' /etc/sysconfig/network-scripts/temp1 > /etc/sysconfig/network-scripts/temp2

rm /etc/sysconfig/network-scripts/ifcfg-eth0
mv /etc/sysconfig/network-scripts/temp2 ifcfg-eth0
chmod 644 /etc/sysconfig/network-scripts/ifcfg-eth0
rm /etc/sysconfig/network-scripts/temp1
rm /etc/sysconfig/network-scripts/temp2

#Modifying /etc/hosts
echo $ips $mc_name$domain_name $mc_name > /etc/host2
sed -e's/127.0.0.1/#127.0.0.1/' /etc/hosts > /etc/host1
rm /etc/hosts
mv /etc/host1 /etc/hosts
hostname $mc_name
rm /etc/host1
rm /etc/host2

#Modifying access.conf

sed -e's/-:root/#-:root/' /etc/security/access.conf > /etc/security/access1.conf
rm /etc/security/access.conf
mv /etc/security/access1.conf /etc/security/access.conf
rm /etc/security/access1.conf
echo "Don't forget to reboot the system"

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Changing IP address with set_params

I want to change the IP address of my computer (743i card using HP-UX 10.2) using "set_params ip_address". The problem is the following: 1. I'm using a touch panel to enter in the IP address. 2. The set_params routine asks two questions; do I want to use the IP address entered and do I want... (3 Replies)
Discussion started by: maddog0606
3 Replies

2. UNIX for Advanced & Expert Users

Changing Machine IP address

Hopefully someone can help with this. I need the command to change the IP address on a machine (7 Replies)
Discussion started by: kkinnon
7 Replies

3. UNIX for Dummies Questions & Answers

Changing IP address

Hi, I am going to shift my Unix workstation to another lab. So I need to change the IP address. Please tell me how to change the Network IP address, what is the commands, what to take care? Thank you very much and have a very nice day. (4 Replies)
Discussion started by: champion
4 Replies

4. AIX

Changing the IP Address

I need to change the IP address on one of your Unix machines - P630, AIX5.2. I plan on using SMIT to perform this function. These are the steps that I have put together so far: 1. Select Communications Applications & Services - Select TCP/IP - Select Minimun Configuration & Startup... (2 Replies)
Discussion started by: jyoung
2 Replies

5. IP Networking

Changing the ip address

Help me save my Unix box. I've had this Unix box (Enterprise 450) for about 7 years now. It was being used as a file server for a Macintosh Prepress department. All of our networking was done through Helios Etharshare. I am still currently up and online (however the location has changed). Our ip... (1 Reply)
Discussion started by: ubed
1 Replies

6. Shell Programming and Scripting

changing passwords remotely on sun boxes

now, for reasons i really cant begin to delve into, i have to find a way to be able to rmeotely create user accounts and also assign them passwords. unfortunately, it appears Sun boxes frowns upon this. sun boxes will let u create a user account remotely but will never let u assign the useraccount... (0 Replies)
Discussion started by: Terrible
0 Replies

7. Windows & DOS: Issues & Discussions

Changing IP address

Hi ,,, i just come across this forum and i make it a must to be pay a visit here everyday and through it am learning a lots of things which am sure i will be able to share later... So i have a prob with my pc when i try to change my Ip address in the dos command using ipconfig command i got a... (1 Reply)
Discussion started by: Lutchumaya
1 Replies

8. AIX

changing ip address

Hi, I am using aix 5300-07, I am facing strange issue in aix. I have changed the ip address and gateway of aix server , it is showing the right ip address but it is taking old gateway ip address. I have used netstat -r command and found it is showing 2 Default gateway. I want to... (2 Replies)
Discussion started by: manoj.solaris
2 Replies

9. Cybersecurity

Port Address Changing....

Is there a software solution to stop intruders from changing my port addresses? Causes IPmap to crash. Platform is OS/X Leopard. (1 Reply)
Discussion started by: aleatory
1 Replies

10. IP Networking

Changing IP address

My work has a Unix based system that currently has the IP address 192.9.2.25 We recently changed internet providers from DSL to Cable. By doing so, we had to get a new router (Belkin) since the DSL provider had a wireless router/modem in one. With the DSL setup, I was able to change the router's... (2 Replies)
Discussion started by: Len351
2 Replies
SMPPPD-IFCFG(8) 						      SMPPPD							   SMPPPD-IFCFG(8)

NAME
smpppd-ifcfg - SuSE Meta PPP Daemon DESCRIPTION
smpppd-ifcfg is a daemon that controls a single dialup connection to the internet. It does so by starting and controlling the pppd. The configuration of the dialup connections is done by YaST2. smpppd-ifcfg is not intended for direct use. Use ifup and ifdown or a frontend like cinternet , qinternet or kinternet instead. OPTIONS
These options are recognized by smpppd-ifcfg. If a long option shows an argument as mandatory, then it is mandatory for the equivalent short option also. --up Bring the connection up. This is the default action. --down Bring the connection down. --status Report status of the connection. -i, --ifcfg=NAME Specify the ifcfg file to use. This option is mandatory. -p, --provider=NAME Specify the provider file to use. --detach Detach from the controlling terminal. This is the default. --nodeatch Don't detach from the controlling terminal. -d, --debug Turn on debugging. --version Show program version and exit. --help Show help information and exit. FILES
/etc/sysconfig/network/ifcfg-* Configuration files for the interfaces. /etc/sysconfig/network/providers/* Configuration files for the providers. /var/log/smpppd/ifcfg-xxx.log Log file. /var/log/smpppd/accounting.log File containing accounting information. /var/run/smpppd.ifcfg-xxx.pid Pid file. /var/lib/smpppd/ifcfg-xxx.info Info file with various status information. /var/run/smpppd/ifcfg-xxx Socket to communicate with smpppd. SEE ALSO
kinternet, qinternet, cinternet(1), accounting(1), wvdial(1), smpppd.conf(5), pppd(8), smpppd(8). AUTHOR
Arvin Schnell <arvin@suse.de> SuSE December 2002 SMPPPD-IFCFG(8)
All times are GMT -4. The time now is 11:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy