This article will explain about to add type of routes in Solaris10 .
Static and Dynamic routes:
The static routes are added by using the route command either by a script or by using command line. Dynamic routes are added by default routing daemons.These are the deamons /usr/sbin/in.routed (Routing Information Protocol(RIP) and /usr/sbin/in.rdisc (Router Network Discovery Protocol) which are responsible for adding dynamic routes that are inbuilt with Solaris OS it self.
Pre-request tasks:
1). Take backup of current configuration file as well as screenshot
2). Check whether your able to ping and trace route IP which your going to add or change
3). Take console access before changing default router, it may cause to not allow ssh some time
The various flags in routes :
U – The route is up.
G – The route uses a gateway.
H – The target is a host route.
D – The route was added dynamically by ICMP redirect.
M - The flag signifies that this route is modified by a redirect.
My Server Current Setup:
1). Generally adding, changing and deleting default route without specifying interface
2). Adding , changing and deleting default route with specifying interface
Static and Dynamic routes:
The static routes are added by using the route command either by a script or by using command line. Dynamic routes are added by default routing daemons.These are the deamons /usr/sbin/in.routed (Routing Information Protocol(RIP) and /usr/sbin/in.rdisc (Router Network Discovery Protocol) which are responsible for adding dynamic routes that are inbuilt with Solaris OS it self.
Pre-request tasks:
1). Take backup of current configuration file as well as screenshot
2). Check whether your able to ping and trace route IP which your going to add or change
3). Take console access before changing default router, it may cause to not allow ssh some time
The various flags in routes :
U – The route is up.
G – The route uses a gateway.
H – The target is a host route.
D – The route was added dynamically by ICMP redirect.
M - The flag signifies that this route is modified by a redirect.
My Server Current Setup:
bash-3.2# netstat -rn
Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
-------------------- -------------------- ----- -- ---------- ---------
192.168.10.0 192.168.10.21 U 1 25 e1000g0
224.0.0.0 192.168.10.21 U 1 0 e1000g0
127.0.0.1 127.0.0.1 UH 6 67 lo0
bash-3.2# cat /etc/inet/static_routes
# File generated by route(1M) - do not edit.
bash-3.2#
Here I am adding, changing and deleting route aka default gateway in two method.1). Generally adding, changing and deleting default route without specifying interface
2). Adding , changing and deleting default route with specifying interface
To add default router persistently : (if your using route command with -p option then not require to put entry to /etc/defaultrouter file, instead it will add entry automatically to /etc/inet/static_routes file which will take care across reboot.
bash-3.2# route -p add default 192.168.10.1
add net default: gateway 192.168.10.1
add persistent net default: gateway 192.168.10.1
bash-3.2# cat /etc/inet/static_routes
# File generated by route(1M) - do not edit.
default 192.168.10.1
bash-3.2# netstat -rn
Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
-------------------- ----------------- ----- ----- ---------- ---------
default 192.168.10.1 UG 1 0
192.168.10.0 192.168.10.21 U 1 57 e1000g0
224.0.0.0 192.168.10.21 U 1 0 e1000g0
127.0.0.1 127.0.0.1 UH 4 133 lo0
bash-3.2#
Note - We can't change persistent route using -p , we have to delete it and add it.bash-3.2# route -p change default 192.168.10.10
change net default: gateway 192.168.10.10
route: change command not supported with -p
bash-3.2#
To delete persistent default route:
bash-3.2# route -p delete default 192.168.10.1
delete net default: gateway 192.168.10.1
delete persistent net default: gateway 192.168.10.1
bash-3.2# netstat -rn
Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
----------------- -------------------- ----- ----- ---------- ---------
192.168.10.0 192.168.10.21 U 1 25 e1000g0
224.0.0.0 192.168.10.21 U 1 0 e1000g0
127.0.0.1 127.0.0.1 UH 4 131 lo0
bash-3.2# cat /etc/inet/static_routes
# File generated by route(1M) - do not edit.
bash-3.2#
To add "default" router without and with specifying interface:bash-3.2# route add default 192.168.10.10
add net default: gateway 192.168.10.10
bash-3.2# route add default 192.168.10.1 -ifp e1000g0
add net default: gateway 192.168.10.1
bash-3.2# netstat -rn
Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
-------------------- ----------------- ----- ----- ---------- ---------
default 192.168.10.10 UG 1 0
default 192.168.10.1 UG 1 0 e1000g0
192.168.10.0 192.168.10.21 U 1 32 e1000g0
224.0.0.0 192.168.10.21 U 1 0 e1000g0
127.0.0.1 127.0.0.1 UH 4 133 lo0
bash-3.2#
To change "default" router without and with specifying interface:bash-3.2# route change default 192.168.10.5
change net default: gateway 192.168.10.5
bash-3.2# route change default 192.168.10.21 -ifp e1000g0
change net default: gateway 192.168.10.21
bash-3.2# netstat -rn
Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
-------------------- ----------------- ----- ----- ---------- ---------
default 192.168.10.5 UG 1 0
default 192.168.10.21 UG 1 0 e1000g0
192.168.10.0 192.168.10.21 U 1 32 e1000g0
224.0.0.0 192.168.10.21 U 1 0 e1000g0
127.0.0.1 127.0.0.1 UH 4 133 lo0
bash-3.2#
To delete"default" router without and with specifying interface:bash-3.2# route delete default 192.168.10.5
delete net default: gateway 192.168.10.5
bash-3.2# route delete default 192.168.10.21 -ifp e1000g0
delete net default: gateway 192.168.10.21
bash-3.2# netstat -rn
Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
-------------------- ----------------- ----- ----- ---------- ---------
192.168.10.0 192.168.10.21 U 1 32 e1000g0
224.0.0.0 192.168.10.21 U 1 0 e1000g0
127.0.0.1 127.0.0.1 UH 4 133 lo0
bash-3.2#
To make this changes effect across reboot we have put entry to /etc/defaultrouter file.Usually and by Default /etc/defaultrouter file will not be there , we have to create it manually. To set static routes: Use route command to add static route on fly (dynamic modification of routing table). We have two option to add static routes, persistent and non-persistent. To add static routes persistent: we have to use -p option with route command or we can create rc script and put the entry to the script which will add it across reboot.
Adding route using -p option(/etc/inet/static_routes):
bash-3.2#route -p add net 192.168.10.0/24 gateway 192.168.10.10
add persistent net 192.168.10.0/24: gateway 192.168.10.10
bash-3.2# route -p add 192.168.10.0 -netmask 255.255.255.0 192.168.10.1
add net 192.168.10.0: gateway 192.168.10.1
add persistent net 192.168.10.0: gateway 192.168.10.1
bash-3.2# netstat -rnv
IRE Table: IPv4
Destination Mask Gateway Device Mxfrg Rtt Ref Flg Out In/Fwd
-------------------- --------------- -------------------- ------ ----- ----- --- --- ----- ------
192.168.10.0 255.255.255.0 192.168.10.21 e1000g0 1500* 0 1 U 51 0
192.168.10.0 255.255.255.0 192.168.10.10 1500* 0 1 UG 0 0
192.168.10.0 255.255.255.0 192.168.10.1 1500* 0 1 UG 0 0
224.0.0.0 240.0.0.0 192.168.10.21 e1000g0 1500* 0 1 U 0 0
127.0.0.1 255.255.255.255 127.0.0.1 lo0 8232* 0 4 UH 133 0
bash-3.2# cat /etc/inet/static_routes
# File generated by route(1M) - do not edit.
192.168.10.0/24 192.168.10.10
192.168.10.0 -netmask 255.255.255.0 192.168.10.1
bash-3.2#
bash-3.2# route add 192.168.10.0 -netmask 255.255.255.0 192.168.10.1
add net 192.168.10.0: gateway 192.168.10.1
bash-3.2# route add 192.168.10.0/24 192.168.10.10
add net 192.168.10.0/24: gateway 192.168.10.10
bash-3.2# netstat -rnv
IRE Table: IPv4
Destination Mask Gateway Device Mxfrg Rtt Ref Flg Out In/Fwd
-------------------- --------------- -------------------- ------ ----- ----- --- --- ----- ------
192.168.10.0 255.255.255.0 192.168.10.21 e1000g0 1500* 0 1 U 49 0
192.168.10.0 255.255.255.0 192.168.10.1 1500* 0 1 UG 0 0
192.168.10.0 255.255.255.0 192.168.10.10 1500* 0 1 UG 0 0
224.0.0.0 240.0.0.0 192.168.10.21 e1000g0 1500* 0 1 U 0 0
127.0.0.1 255.255.255.255 127.0.0.1 lo0 8232* 0 4 UH 133 0
bash-3.2#
bash-3.2# route -p get 192.168.10.10
route to: 192.168.10.10
destination: 192.168.10.0
mask: 255.255.255.0
interface: e1000g0
flags:
recvpipe sendpipe ssthresh rtt,ms rttvar,ms hopcount mtu expire
0 0 0 0 0 0 1500 0
get persistent host 192.168.10.10: not in file
bash-3.2#
bash-3.2# route -p show
persistent: route add default 192.168.10.1
bash-3.2#
The -p option will not work earlier solaris verion as well as some earlier patch level of solaris 10. To avoid this we have a another optin to create a rc script under /etc/rc2.d/.
Add the route add command in this script :
i.e /etc/rc2.d/S90route
bash-3.2# cat /etc/rc2.d/S90route
/usr/sbin/route add 192.168.10.0 -netmask 255.255.255.0 192.168.10.1
bash-3.2#
To flush (remove) the routing table of all gateway entries, use the route flush command:bash-3.2# route flush
default 192.168.10.10 done
bash-3.2#
To add a route manually to the multicast address for range of 192-254:
bash-3.2# route add 224.0/24 `uname -n`
add net 224.0/24: gateway techpanel
bash-3.2# netstat -rn
Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
----------------- -------------------- ----- ----- ---------- ---------
192.168.10.0 192.168.10.21 U 1 26 e1000g0
224.0.0.0 192.168.10.21 UG 1 0
224.0.0.0 192.168.10.21 UG 1 0
127.0.0.1 127.0.0.1 UH 4 131 lo0
bash-3.2#
You can refer multicast address range here as well as in this link Netmask:
Net Class | Addr Range | NetMask | Net Addr Bits | Host Addr Bits | Total Number of hosts | Example Range |
---|---|---|---|---|---|---|
A | 0-127 | 255.0.0.0 | 8 | 24 | 16777216 | (i.e. 114.0.0.0) |
B | 128-191 | 255.255.0.0 | 16 | 16 | 65536 | (i.e. 150.0.0.0) |
C | 192-254 | 255.255.255.0 | 24 | 8 | 256 | (i.e. 199.0.0.0) |
D | 224-239 | (multicast) | ||||
E | 240-255 | (reserved) | ||||
F | 208-215 | 255.255.255.240 | 28 | 4 | 16 | |
G | 216/8 | ARIN North America | ||||
G | 217/8 | RIPE NCC Europe | ||||
G | 218-219/8 | APNIC | ||||
H | 220-221 | 255.255.255.248 | 29 | 3 | 8 | (reserved) |
K | 222-223 | 255.255.255.254 | 31 | 1 | 2 | (reserved) |
bash-3.2# cat /etc/gateways
net 192.168.10.0 gateway 192.168.10.1
bash-3.2#
Thanks for reading this article...
i am getting errot is route notfound
ReplyDelete