Thursday, July 3, 2008

ifconfig & route for Linux & Solaris

Linux;
# Set the ip & bring up the interface
ifconfig eth0 192.168.1.2 netmask 255.255.255.0 up

# Add/Del default route
route add default gw 192.168.0.1
route del default gw 192.168.0.1
OR
route add default gw 192.168.1.1 eth0

# Add route to network
route add -net 10.0.0.0 netmask 255.0.0.0 gw 192.168.1.254 eth0
route del -net 10.0.0.0 netmask 255.0.0.0 gw 192.168.1.254 eth0

# Add route to host
route add -host 10.10.10.45 gw 192.168.0.1

===============

Solaris;
# Enable network interface
ifconfig vmxnet0 plumb up

# Set the ip & bring up the interface
ifconfig hme0 192.168.1.13 netmask 255.255.255.0 up

# + sign will refer to default network configuration file
ifconfig hme0 192.168.1.13 netmask + broadcast + up

ifconfig hme0 192.168.1.13 netmask 255.255.255.0 broadcast 192.168.1.255 up


# Add default route
route add default 192.168.1.1

# Add static route to network
route add net 192.168.68.0 192.168.0.1 -netmask 255.255.255.0
# 192.168.0.1 is gw

# Add static route to host
route add host 192.168.1.2 192.168.5.1
# 192.168.5.1 is gw

# Add the persistent route,
# The static routes will be stored in file /etc/inet/static_routes.
route -p add 192.168.15.0 192.168.15.1

HP-UX
# Set IP and bring up the NIC
ifconfig lan0 16.118.112.135 netmask 255.255.255.0 up

# Bring down NIC
ifconfig lan0 down

> Network configuration file;
/etc/rc.config.d/netconf

No comments: