Thursday, April 4, 2013

Manually Configuring a Lan interface using ifconfig under HP-UX

You would like to add an ephemeral or temporary IP perhaps to troubleshoot a problem involving a Network Interface Card.

NOTE: Keep in mind you may lose network connectivity... be sure to be connected to the network console or MP (management port), or via another network card on the system other than the one you are configuring. Be sure to check if you are using NFS shares or other things that rely on network connectivity before making changes that may impact it's availability.

For temporary changes which will persist until changed again, or a reboot
occurs:
ifconfig lan0 down
ifconfig lan0 unplumb
ifconfig lan0 plumb
ifconfig lan0 172.16.0.121 up netmask 255.255.255.0
you can confirm by using:
netstat -in
If you need to configure a default route you can use the following:
1) View the current routes by using netstat -nr
You may have to remove the default route and the syntax would be:
route delete default 172.16.0.1
2) add the route as follows:
Note: "default route" route add default netmask 255.255.255.0 172.16.0.1 1
Note: "host route" route add host 136.128.103.16 10.12.3.102 1
Note: "net route" route add net 172.16.0.0 netmask 255.255.0.0
192.168.70.11 1
Keep in mind the changes are temporary and are not persistent across a reboot. At boot time the /etc/rc.config.d/netconf file is used as well as other configuration files that vary depending on the NIC and it's associated driver.

Example Routes in /etc/rc.config.d/netconf file (Take effect on reboot or "/sbin/init.d/net stop" "/sbin/init.d/net start" see note on connectivity below:

ROUTE_DESTINATION[2]="host 136.128.103.16"
ROUTE_GATEWAY[2]="10.2.15.35"
ROUTE_COUNT[2]="1"

ROUTE_DESTINATION[1]="net 172.16.0.0"
SUBNET_MASK[1]="255.255.0.0"
ROUTE_GATEWAY[1]="192.168.70.11"
ROUTE_COUNT[1]="1"

Default route in /etc/rc.config.d/netconf:
ROUTE_DESTINATION[0]=default
ROUTE_MASK[0]=255.255.255.0
ROUTE_GATEWAY[0]=172.16.0.1
ROUTE_COUNT[0]="1"
ROUTE_ARGS[0]=""
ROUTE_SOURCE[0]=""

Sample Interface entry in /etc/rc.config.d/netconf for lan0:
INTERFACE_NAME[1]="lan0"
IP_ADDRESS[1]="172.16.0.121"
SUBNET_MASK[1]="255.255.255.0"
BROADCAST_ADDRESS[1]="172.16.0.255"
INTERFACE_STATE[1]="up"
DHCP_ENABLE[1]="0"
INTERFACE_MODULES[1]=""

If you see an entry like lan900 and above... that pertains to Auto Port Aggregation (APA), which on other platforms is sometimes referred to NIC teaming or bonding.
You can actually add an alias IP or stack IP's on the same interface by using the following syntax. For example lan0 is actually lan0:0 so an additional IP could be added to lan0:1... lan0:2 etc. This is actually how service guard works... it takes advantage of these alias IP address and they are assigned to an application and then move between nodes in the serviceguard cluster.

Additional Commands
To try to determine which lan card is in which physical slot/location... use
ioscan -funC lan
then look at slot information with "olrad -q", or "rad -q" depending on your HP-UX OS version.

KEEP IN MIND IFCONFIG IS TEMPORARY. IF YOU NEED TO CHANGE THE IP ADDRESS PERMANANTLY IT WILL NEED TO BE DONE IN THE /etc/rc.config.d/netconf FILE.  If you are an advanced user you can edit this file directly and then re-run the /sbin/init.d/net stop and /sbin/init.d/net start or altertively reboot your server. If you do not plan to reboot you should be connected to the console either via a webconsole... actual console, or an ILO connection.

NOTE ON CONNECTIVITY:
(YOU MAY LOSE NETWORK CONNECTIVITY AND MAY EVEN HANG YOUR SYSTEM) Remember to keep in mind other services that rely on network services like NFS that may even affect another server. The safest thing is to edit the netconf file and then reboot during a maintenance window. You can also use the set_parms command to change the IP address if you dont want to edit the files manually or use "sam", or "smh" on newer systems.
Bryan Payne on Linkedin  https://www.linkedin.com/in/paynebryan








+Bryan Payne

If you found this information helpful... and you see an advertisement for which you have legitimate interest... every click helps.  Thanks!