Script to adjust network settings


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to adjust network settings
# 1  
Old 11-06-2010
Script to adjust network settings

Hello, Newbie question on scripting - I'm looking to create a simple script that will work on RHEL5 that will adjust the network settings: ip address, default gateway, and subnet mask. If anything else needs to be done (service network stop / start) or should be done to make settings active - I want to include that - then ping to a public IP and confirm a successful response.
Thanks for your input
# 2  
Old 11-06-2010
looks like homework to me...?!
# 3  
Old 11-06-2010
No sir, it is not. I am provisioning RHEL virtual machines and need to automate checking and updating the network configuration of them afterwards.
# 4  
Old 11-06-2010
so show us what you have done so far... nobody is going to write scripts for you because this is your job. you have to start and if specific problems occur, you can always ask. for starters, you might want to take a look at commands like "ifconfig" (for checking your network) and "sed" or "ed" for editing files from a script.
# 5  
Old 11-06-2010
The main issue I'm having is with the default gateway. After provisioning a virtual machine, the default gateway for some reason does not populate. So the main problem is to script the population of the default gateway

So in what I've tried so far,

This line is intended to populate the default gateway:

route add default gw 192.168.26.1

but results in the following message:

SIOCADDRT: File Exists


Some postings suggest steps such as this:

1. Open ifcfg file vi /etc/sysconfig/network-scripts/ifcfg-eth0:7
2. NETWORK=217.174.242.0 Make sure this address is unique to each ifcfg file; if you use the same address in another ifcfg file you will receive the aforementioned error.
3. Edit if required by pressing i to begin insert mode, make the changes, then pressing Esc to return to view mode.
3. Save the document by using a SHIFT ZZ combination.
4. Restart the network: service network restart


But having to that for every vm would defeat my object of saving time through scripting the process.

Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Network settings on Motorola System V R32V3.2

Hi, I have inherited a Motorola System V R32V3.2 system. The system works fine, but we need to change the network settings. I've changed the IP address successfully, however I'm lost on the gateway and subnet mask. I've changed the default gateway using route -g10.0.8.1, but it changes back to... (7 Replies)
Discussion started by: Tilmar
7 Replies

2. Shell Programming and Scripting

Script to adjust system time

Hello everyone, I am trying to write a script that will accomplish the following: - query current system time and store result into a variable - wait for some amount of time, say 300 seconds - reset system time to earlier queried time + 1 second I did some basic shell scripting (CSH... (11 Replies)
Discussion started by: xaiu
11 Replies

3. Solaris

Creating A Solaris Zone - Unable to install - Are network settings required?

Hi i have created a solaris zone but have not yet connected any network cables for this new zone, can i set the zone up without running the command 'add net' and not adding an ip or physical interface? i tried to add dummy internet settings and get this zonecfg:coddr> add net... (4 Replies)
Discussion started by: newbiesolaris10
4 Replies

4. UNIX for Dummies Questions & Answers

Linux Server Network Settings - Share Directory Structure

Hello Unix Gurus Who I Hope Reads This, I have quasi-inherited control over a Linux cluster at a university research lab. The post-doc that set it up is gone, and the person in charge of administering the cluster doesn't know a ton about Linux. Amongst other things, I want to use the cluster... (0 Replies)
Discussion started by: mbl
0 Replies

5. HP-UX

Network Printer Settings-landscape/portrait mode

Hello everyone.. While printing through command line, we can set printing option with -o <lanscape/portrait> to print file in required mode. But i want to know is there any way we can set this as default behaviour for this printer? After configuration any script we can modify for this... (0 Replies)
Discussion started by: laxmikant
0 Replies

6. Solaris

Network settings

I have problem with network settings. Where i can find network config ? I'm newbie, but i very want learn this OS. I find : /etc/hostname.<interface> /etc/netconfig /etc/netmasks /etc/networks /etc/inet/hosts But where i can write my IP-address and after reboot i be know that my server... (2 Replies)
Discussion started by: jess_t03
2 Replies

7. Linux

Mandriva 2006 keeps resetting network settings...

I've been looking for documentation on how to stop this behavior. I have two nics in my system. eth0: configured manually and as a dhcp server for the local network eth1: configured w/ dhcp enabled connected to router dns server addresses keep getting reset every few minutes. i suspect... (0 Replies)
Discussion started by: rbetzen
0 Replies

8. UNIX for Dummies Questions & Answers

Network settings

Total newbie here!! How do I view and alter network settings (ip address, subnet mask and default gateway) in UNIX? Thanks in advance.. (3 Replies)
Discussion started by: ZappaDub
3 Replies

9. Shell Programming and Scripting

Adjust the db script

Enclosing a script that is used everyday for database shutdown. In here you will find some code that checks oracle version. That part is very unnecessary since we use only 8.1.7 and will never go back.. Can anyone help me by modifying the code, to never use that part and readjust so script does... (1 Reply)
Discussion started by: ST2000
1 Replies

10. UNIX for Dummies Questions & Answers

Network settings on Red Hat

HELP!! How do you change the network setting from auto-duplex to 100 Base T Full Duplex in Red HaT? (1 Reply)
Discussion started by: johnlong
1 Replies
Login or Register to Ask a Question