SOLARIS
BASICS-P7
BASIC NETWORKING -2,
Well, move ahead from last post.
We already did a plumb/unplumb to an interface.
Now how to do UP/DOWN to an interface.
root@sol-test-1:>/#ifconfig e1000g1 up
root@sol-test-1:>/#ifconfig e1000g1
e1000g1:
flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4>
mtu 1500 index 4
inet 0.0.0.0 netmask ff000000
ether 0:c:29:c2:8f:9a
root@sol-test-1:>/#ifconfig e1000g1 down
root@sol-test-1:>/#ifconfig e1000g1
e1000g1:
flags=1000842<BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 4
inet 0.0.0.0 netmask ff000000
ether 0:c:29:c2:8f:9a
See the change in status of interface after making it up and down
(bold and yellow marked)
How to assign IP address to an interface?
root@sol-test-1:>/#ifconfig e1000g1 inet 192.168.234.135
netmask 255.255.255.0 up
root@sol-test-1:>/#ifconfig e1000g1
e1000g1:
flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 4
inet 192.168.234.135 netmask ffffff00
broadcast 192.168.234.255
ether 0:c:29:c2:8f:9a
Is this permanent?
NO…
A reboot and all gone.
Let’s make it persistent.
root@sol-test-1:>/#vi /etc/hosts
"/etc/hosts" [Read only] 6 lines, 97 characters
#
# Internet host table
#
::1 localhost
127.0.0.1 localhost
192.168.234.133 sol-test-1
loghost
192.168.234.135 sol-test-1 çç
root@sol-test-1:>/#vi /etc/hostname.e1000g1
"/etc/hostname.e1000g1" [New file]
192.168.234.135
That’s it.
We can assign Netmask as well here, like…
root@sol-test-1:>/#vi /etc/hostname.e1000g1
"/etc/hostname.e1000g1" [New file]
192.168.234.135 netmask 255.255.255.0
What port is being used by what type of service on system?
root@sol-test-1:>/#cat /etc/services
root@sol-test-1:>/#cat /etc/services |grep -i ftp
ftp-data 20/tcp
ftp 21/tcp
tftp 69/udp
root@sol-test-1:>/#cat /etc/services |grep -i ssh
ssh 22/tcp # Secure Shell
root@sol-test-1:>/#cat /etc/services |grep -i rlogin
klogin 543/tcp # Kerberos
authenticated rlogin
eklogin 2105/tcp # Kerberos encrypted
rlogin
Sometimes it might be required to setup a program to use specific
port in case any network error.
How to check the routing table?
root@sol-test-1:>/#netstat -nrv
IRE
Table: IPv4
Destination Mask Gateway Device Mxfrg Rtt Ref Flg
Out In/Fwd
--------------------
--------------- -------------------- ------ ----- ----- --- --- ----- ------
default 0.0.0.0 192.168.234.2 1500* 0 1
UG 0 0
192.168.234.0 255.255.255.0 192.168.234.133 e1000g0
1500* 0 1 U
4 0
192.168.234.0 255.255.255.0 192.168.234.135 e1000g1
1500* 0 1 U
0 0
192.168.234.0 255.255.255.0 192.168.234.137 e1000g2
1500* 0 1 U
0 0
224.0.0.0 240.0.0.0 192.168.234.133 e1000g0
1500* 0 1 U
0 0
127.0.0.1 255.255.255.255 127.0.0.1 lo0 8232*
0 4 UH 177
0
U – The interface is up.
H – Host route. The destination is a system, not a network.
G – The delivery system is another system (an indirect route).
D – The entry was added dynamically by an ICMP redirect.
M - The flag signifies that this route is modified by a redirect.
root@sol-test-1:>/#netstat -nr
Routing Table: IPv4
Destination Gateway Flags Ref
Use Interface
-------------------- -------------------- ----- ----- ----------
---------
default
192.168.234.2 UG 1 0
192.168.110.0
192.168.234.2 UG
1 0
192.168.234.0
192.168.234.133 U 1 4 e1000g0
192.168.234.0
192.168.234.135 U 1 0 e1000g1
192.168.234.0
192.168.234.137 U 1 0 e1000g2
224.0.0.0 192.168.234.133 U
1 0 e1000g0
127.0.0.1
127.0.0.1 UH 4
177 lo0
-n option disables the name resolution of hosts and ports and speed
up the o/p time
-r returns routing table
How to add a route?
# route -p add -net network-address -gateway
gateway-address
–p
Creates a route that persists across system reboots. If you want the
route to persist only for the current session, do not use the –p option.
–net network-address
Specifies that the route goes to the network with the address that is
specified in network-address.
–gateway gateway-address
Indicates that the gateway system for the specified route has the IP
address gateway-address.
root@sol-test-1:>/#route add 192.168.110.0
-netmask 255.255.255.0 192.168.110.1
root@sol-test-1:>/#route add 192.168.110.0/24
192.168.110.1
#route add <network> -netmask <subnet>
<gateway>
How to make route persistent?
root@sol-test-1:>/#route -p add 192.168.110.0 -netmask
255.255.255.0 192.168.110.1
root@sol-test-1:>/#route -p add 192.168.110.0/24
192.168.110.1
How to add a persistent default route?
root@sol-test-1:>/#route -p add default 192.168.234.2
root@sol-test-1:>/#route -p show
persistent: route add default 192.168.234.2
How to add another/second route?
root@sol-test-1:>/#route -p add -net 192.168.110.0
-gateway 192.168.234.2
add net 192.168.110.0: gateway 192.168.234.2
add persistent net 192.168.110.0: gateway 192.168.234.2
root@sol-test-1:>/#route -p show
persistent: route add default 192.168.234.2
persistent: route add -net 192.168.110.0 -gateway 192.168.234.2
How to delete a default route?
root@sol-test-1:>/#route -p delete 192.168.110.0/24
192.168.234.2
delete net 192.168.110.0/24: gateway 192.168.234.2
delete persistent net 192.168.110.0/24: gateway 192.168.234.2: not in
file
How to flush all routing in one go?
#route flush
We can also use the /etc/gateways file to add static routes. If the
/etc/gateways file exists, the in.routed daemon reads the file when it starts
root@sol-test-1:>/#vi /etc/gateways
"/etc/gateways" [New file]
net 192.168.110.0 gateway 192.168.234.2
/etc/inet/static_routes file will take care of static routes across
reboot,
root@sol-test-1:>/#cat /etc/inet/static_routes
# File generated by route(1M) - do not edit.
default 192.168.234.2
-net 192.168.110.0 -gateway 192.168.234.2
Static Routes at boot time
To make the routes available at boot time so the next time when the
server reboots, the routes are still available. Add a startup script named as
/etc/rc2.d/S76static-routes
And add the required route commands as above.
Change the permissions for the file so that the file is executable by
root.
# chmod 744 /etc/rc2.d/S76static-routes
How to add default route linked with/without interface?
root@sol-test-1:>/#route add default 192.168.234.2 -ifp
e1000g0
add net default: gateway 192.168.234.2
How to change default route linked with/without interface?
root@sol-test-1:>/#route change default 192.168.110.1
-ifp e1000g0
change net default: gateway 192.168.110.1
root@sol-test-1:>/#netstat -nr
Routing
Table: IPv4
Destination Gateway Flags Ref
Use Interface
--------------------
-------------------- ----- ----- ---------- ---------
default 192.168.234.2 UG
1 0
default 192.168.110.1 UG 1 0 e1000g0 çç
192.168.234.0 192.168.234.133 U
1 4 e1000g0
192.168.234.0 192.168.234.135 U
1 0 e1000g1
192.168.234.0 192.168.234.137 U
1 0 e1000g2
224.0.0.0 192.168.234.133 U
1 0 e1000g0
127.0.0.1 127.0.0.1 UH 4
177 lo0
#cat /etc/rc2.d/S99Networkroutes
No comments:
Post a Comment