Sponsored Content
Special Forums IP Networking Switching from DHCP to Static IP Post 302308543 by dr.house on Sunday 19th of April 2009 08:07:40 AM
Old 04-19-2009
The following code of mine (quoted in extracts) has been used to allow for updating the network settings of a Debian-based live system at boot time ...:

Code:
  eth0|eth1)

    updateConsole

    echo -ne "\e[33m"
    echo ""
    echo "          \|||/                          "
    echo "          (0 0)                          "
    echo "-------ooO-(_)-Ooo-----------------------"
    echo ""
    echo "Attempting to upset, er, setup <$OPTION> ..."
    echo ""

    ADDRESS="192.168.110.100"
    echo -n "Address [192.168.110.100]: "
    read address
    if [ "$address" != "" ]
    then
      ADDRESS="$address"
    fi
    GATEWAY="192.168.110.101"
    echo -n "Gateway [192.168.110.101]: "
    read gateway
    if [ "$gateway" != "" ]
    then
      GATEWAY="$gateway"
    fi
    echo ""
    echo -ne "\e[0m"

    ETH=/etc/network/interfaces
    mv $ETH $ETH.dhcp

    ifconfig lo 127.0.0.1
    route add 127.0.0.0 lo

    ifconfig "$OPTION" "$ADDRESS" netmask 255.255.255.0
    route add "$ADDRESS" "$OPTION"

    route add default gw "$GATEWAY" "$OPTION" > /dev/null 2>&1

    DNS=/etc/resolv.conf
    mv $DNS $DNS.dhcp && touch $DNS
    echo "nameserver 208.67.220.220" >> $DNS
    echo "nameserver 208.67.222.222" >> $DNS

    ping -c 1 housisms.net > /dev/null 2>&1
    if [ $? -eq 0 ]
    then
      echo -ne "\e[32m"
      echo "You're now part of the 'World Wide Wait'."
      SAVE="yes"
    else
      echo -ne "\e[31m"
      echo "Nice try - to no avail, I'm (not) afraid."
      SAVE="no"
    fi
    echo ""
    echo -ne "\e[0m"
    
    if [ "$SAVE" = "yes" ]
    then
    
      BROADCAST="`echo $ADDRESS | awk -F '.' '{ print $1"."$2"."$3".255"}'`"
    
      touch $ETH
      echo "auto lo" >> $ETH
      echo "iface lo inet loopback" >> $ETH
      echo "auto $OPTION" >> $ETH
      echo "iface $OPTION inet static" >> $ETH
      echo "address $ADDRESS" >> $ETH
      echo "netmask 255.255.255.0" >> $ETH
      echo "broadcast $BROADCAST" >> $ETH
      echo "gateway $GATEWAY" >> $ETH
    fi

  ;;

 

10 More Discussions You Might Find Interesting

1. HP-UX

HP-UX 10.xx Changing from static IP to DHCP

***Newbie alert*** What's the easiest way to accomplish this? An admin left our company and I have taken over his HP Workstation and moved it to a different location that is on a different IP segment. I have performed a number of google searches but the steps I have followed haven't worked. ... (1 Reply)
Discussion started by: Steelysteel
1 Replies

2. IP Networking

dhcp and static ip conflicts.

I have a USB Wireless Adapter using the rum0 driver. All I want to do is set a perminent static IP for the onboard wired interface elxl0. I can plumb the wired interface up fine on the fly, but when I try to save the static IP over a reboot, I lose the IP address assigned to rum0 from my wireless... (1 Reply)
Discussion started by: ts97783
1 Replies

3. IP Networking

How to configure DHCP to Static IP

I am pretty new to this. My router was earlier configured to enable DHCP, thus my UNIX box is using the dhcp address, i.e. I have to do a ifconfig dhcp hme0 start. Since I am planning to use my NT as a web server, I needed to use the static IP address. How do I configure the unix box to use the... (5 Replies)
Discussion started by: lee30320
5 Replies

4. Red Hat

How to know whether my system is using DHCP or STATIC IP

Hi, I am using RHEL 5.1 and i would like to know, how to find the whether my system is using DHCP or STATIC IP with out looking at /etc/sysconfig/network-scripts/ifconfig-eth0 configuration file. Regards, Venkat (3 Replies)
Discussion started by: venkat55
3 Replies

5. IP Networking

I need HELP to Set up Coyote Linux router with 1 static IP & 64 internal static IP

hello, i need help on setting my coyote linux, i've working on this for last 5 days, can't get it to work. I've been posting this message to coyote forum, and other linux forum, but haven't get any answer yet. Hope someone here can help me...... please see my attached picture first. ... (0 Replies)
Discussion started by: dlwoaud
0 Replies

6. UNIX for Dummies Questions & Answers

How to tell if i am using DHCP or Static

Hey guys , YEs this is probably silly for most but i am new to this forum and solaris . i am curious to know if the ip address we have for our solaris server is static or dhcp . how can i tell ? will ifconfig -a tell me this ? or other commands? Thanks in advance (1 Reply)
Discussion started by: xdrivex
1 Replies

7. Red Hat

Purpose of Static IP address through DHCP

Hi All, Could you please explain the purpose of assigning the static IP by using the DHCP Concept. Like by using the clients MAC address we assign the static IP Address. Waiting for your reply. Thanks in Advance. (6 Replies)
Discussion started by: Sharath Kumar
6 Replies

8. HP-UX

[Solved] Static or DHCP IP in HP-UX

Hi, I can find the IP details whether it is Static or dynamic in Linux machine from the location /etc/sysconfig/network-scripts/ifconfig-eth0 configuration file. Can someone suggest a location to find the same in HP UX machines? -Vivek (2 Replies)
Discussion started by: vkk
2 Replies

9. IP Networking

Node switched itself from static to DHCP on reboot issue

I'm trying to figure out what circumstances would cause an Open Solaris 11.2 host to switch itself from a static to a DHCP ip address upon reboot. This has only happened once but is a cause for some concern as this machine will be part of a web server pool. Nothing has changed on the LAN that... (2 Replies)
Discussion started by: SmokeyJoe
2 Replies

10. Solaris

Solaris static IP changed (non DHCP)

We have 2 solaris 10 t5240 servers with static IP addresses on nxge0 I/F which were rebooted a few days back with a known good config that has been in place for years (for /etc/hosts, /etc/hostname.nxge0, /etc/netmasks, etc) They are not using dhcp. About the same time today, both of their... (7 Replies)
Discussion started by: hdatontodo
7 Replies
echo(3XCURSES)						  X/Open Curses Library Functions					    echo(3XCURSES)

NAME
echo, noecho - enable/disable terminal echo SYNOPSIS
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib -R /usr/xpg4/lib -lcurses [ library... ] c89 [ flag... ] file... -lcurses [ library... ] #include <curses.h> int echo(void); int noecho(void); DESCRIPTION
The echo() function enables Echo mode for the current screen. The noecho() function disables Echo mode for the current screen. Initially, curses software echo mode is enabled and hardware echo mode of the tty driver is disabled. The echo() and noecho() functions control soft- ware echo only. Hardware echo must remain disabled for the duration of the application, else the behavior is undefined. RETURN VALUES
Upon successful completion, these functions return OK. Otherwise, they return ERR. ERRORS
No errors are defined. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
getch(3XCURSES), getstr(3XCURSES), initscr(3XCURSES), libcurses(3XCURSES), scanw(3XCURSES), attributes(5), standards(5) SunOS 5.10 5 Jun 2002 echo(3XCURSES)
All times are GMT -4. The time now is 11:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy