Mailinglist Archive: opensuse-autoinstall (99 mails)

< Previous Next >
RE: [opensuse-autoinstall] SuSE 10.1 + Converting from dhcp to static IP
  • From: "King, Richard (CE1 UNIX Admin)" <rking@xxxxxx>
  • Date: Fri, 4 May 2007 16:42:57 -0600
  • Message-id: <F4BFA40B06FA5A498AFA998AD4A4E6AC03986F98@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>

After playing with the autoyast process, I think I figured out how-to
convert from dhcp to static IP on a installed system. 

It's not pretty, but it works. :) Please keep in mind I just started
playing with autoyast a couple of weeks ago.

This is what I have in the networking section of the control file:

<networking>
     <nfs_server> 
      <nfs_exports config:type="list">
        <nfs_export> 
          <allowed config:type="list">
            <allowed_clients>@lab_nis(rw,sync)</allowed_clients>
          </allowed>
          <mountpoint>/local</mountpoint>
        </nfs_export>
      </nfs_exports>
      <start_nfsserver config:type="boolean">true</start_nfsserver>
    </nfs_server> 
    <dhcp_options> 
      <dhclient_client_id></dhclient_client_id>
      <dhclient_hostname_option></dhclient_hostname_option>
    </dhcp_options>
    <dns>
      <dhcp_hostname config:type="boolean">true</dhcp_hostname>
      <dhcp_resolv config:type="boolean">true</dhcp_resolv>
    </dns>
    <interfaces config:type="list">
      <interface> 
        <bootproto>dhcp</bootproto>
        <device>eth0</device>
        <startmode>onboot</startmode>
      </interface>
    </interfaces>
    <modules config:type="list">
    </modules>
    <routing>
      <ip_forward config:type="boolean">false</ip_forward>
    </routing>
  </networking>

Then I have the following in the post-scripts section:

<script>
<debug config:type="boolean">false</debug>
<feedback config:type="boolean">false</feedback>
<filename>staticIP</filename>
<interpreter>shell</interpreter>
<location></location>
<network_needed config:type="boolean">false</network_needed>
<source><![CDATA[#!/bin/bash

GW=`netstat -rn | tail -1 | awk '{ print $2 }'`
SM=`ifconfig | grep  Mask | head -1 | awk '{ print $4 }' | sed
's/Mask://g'`
IP=`ifconfig | grep "inet addr" | head -1 | awk '{ print $2 }' | sed
's/addr://g'`
MAC=`ifconfig | grep HWaddr | awk '{ print $5 }'`
FQDN=`host $IP | awk '{ print $5 }' | sed 's/.$//g'`
DOMAIN=`host $IP | awk '{ print $5 }' | sed 's/.$//g' | awk -F"." '{
print $2"."$3"."$4 }'`
CLIENT=`host $IP | awk '{ print $5 }' | awk -F"." '{ print $1 }'`

rm -rf /etc/sysconfig/network/routes
cat > /etc/sysconfig/network/routes <<-GATEWAY
default $GW - -
GATEWAY


rm -rf /etc/sysconfig/network/ifcfg-eth-id-*
cat > /etc/sysconfig/network/ifcfg-eth-id-$MAC <<-IFCFG_FILE
BOOTPROTO='static'
STARTMODE='onboot'
IPADDR='$IP'
NETMASK='$SM'
_type='eth'
IFCFG_FILE


rm -rf /etc/hosts
cat > /etc/hosts <<-HOSTS_FILE
fe00::0         ipv6-localnet
ff00::0         ipv6-mcastprefix
ff02::1         ipv6-allnodes
ff02::2         ipv6-allrouters
ff02::3         ipv6-allhosts
$IP     $CLIENT.$DOMAIN $CLIENT
127.0.0.1       localhost
HOSTS_FILE


rm -rf /etc/resolv.conf
cat > /etc/resolv.conf <<-RESOLV_FILE
domain $DOMAIN
nameserver xx.xx.xx.xx # resolver1 
nameserver xx.xx.xx.xx # resolver2
RESOLV_FILE


rm -rf /etc/HOSTNAME
cat > /etc/HOSTNAME <<-HOST
$CLIENT.$DOMAIN
HOST

hostname $CLIENT

/etc/init.d/network restart
]]></source>
</script>
</post-scripts>
</scripts>

--
Rick King
 
-----Original Message-----
From: King, Richard 
Sent: Friday, May 04, 2007 10:42 AM
To: opensuse-autoinstall@xxxxxxxxxxxx
Subject: [opensuse-autoinstall] SuSE 10.1 + Converting from dhcp to
static IP

***Sending Message again, first message didn't seem to go through***

SuSE Version: 10.1
Install Method: PXEBOOT/DHCP 

Hello Everyone!

I was wondering if anyone had any suggestions on how-to convert from
dhcp-boot to static IP during the autoyast install?

Questions:
1) Should converting from dhcp-boot to static IP take place during
pre-scripts, or post-scripts?
2) When the install is initiated with dhcp, what file holds the
network/dhcp information during the install process?
3) Would it be practical to use commands such as ifconfig and netstat to
get the network information, and write to the
/etc/sysconfig/network/ifcfg-eth-id-$MAC and
/etc/sysconfig/network/routes files?

Observations:
I have noticed if a client is using dhcp, the package "NetworkManager"
is installed, and will manage the network settings for eth0. However, if
a client is using dhcp/NetworkManager, the NTP & NIS services will fail
to start during bootup. If I manually change the network settings to
static, NTP & NIS will start during bootup. 

Any help with this would be greatly appreciated. 

My best to you

--
Rick King



This is what I have in the network section of my control file. 

<networking>
     <nfs_server>
      <nfs_exports config:type="list">
        <nfs_export>
          <allowed config:type="list">
            <allowed_clients>@lab_nis(rw,sync)</allowed_clients>
          </allowed>
          <mountpoint>/local</mountpoint>
        </nfs_export>
      </nfs_exports>
      <start_nfsserver config:type="boolean">true</start_nfsserver>
    </nfs_server>
    <dhcp_options>
      <dhclient_client_id></dhclient_client_id>
      <dhclient_hostname_option>AUTO</dhclient_hostname_option>
    </dhcp_options>
    <dns>
      <dhcp_hostname config:type="boolean">true</dhcp_hostname>
      <dhcp_resolv config:type="boolean">true</dhcp_resolv>
      <hostname>AUTO</hostname>
    </dns>
    <interfaces config:type="list">
      <interface>
        <bootproto>dhcp</bootproto>
        <device>eth0</device>
        <startmode>onboot</startmode>
      </interface>
    </interfaces>
    <modules config:type="list">
    </modules>
    <routing>
      <ip_forward config:type="boolean">false</ip_forward>
    </routing>
  </networking>
--
To unsubscribe, e-mail: opensuse-autoinstall+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-autoinstall+help@xxxxxxxxxxxx

--
To unsubscribe, e-mail: opensuse-autoinstall+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-autoinstall+help@xxxxxxxxxxxx

< Previous Next >