Search My Techie Guy

Showing posts with label ip route. Show all posts
Showing posts with label ip route. Show all posts

Saturday, May 14, 2016

Adding a Static IP route in a Windows Routing Table

Summary: 

This short post is to show you how to add a static IP route in a windows routing table.

Problem or Goal: 

Statically add an IP route in a windows routing table.

Cause: 

For my case, my laptop had two interfaces (The Local Area Connection on cable and the Wireless Network Connection), and i wanted to force traffic to a certain destination network out the LAN cable interface.

Solution: 

Statically define an IP route to your desired destination network and force it through the gateway that connects to the right interface.

Syntax:
route ADD xxx.xxx.xxx.xxx MASK xxx.xxx.xxx.xxx  xxx.xxx.xxx.xxx
Means:
route ADD “network” MASK “subnet mask”  “gateway ip”
Example:
route ADD 10.10.10.0 MASK 255.255.255.0 192.168.1.12
You can use this command to print the status of your routing table:
netstat -rn
Your routing table should now reflect that change, and all traffic to the 10.10.10.x network will now be sent through the interface that connects to the 192.168.1.12 gateway. 
The route add change will only stick across reboots if you add it with the -p flag, for example:
route -p ADD 10.10.10.0 MASK 255.255.255.0 192.168.1.12

Problem Solved?

YES

Monday, November 17, 2014

Print routing table - Add route - Del route - Unix - SunOS 5.10 - Example

Here is my server OS:
root@myserver# showrev 
Hostname: myserver
Hostid: 84623972
Release: 5.10
Kernel architecture: sun4u
Application architecture: sparc
Hardware provider: Sun_Microsystems
Domain: 
Kernel version: SunOS 5.10 Generic_118833-23
root@myserver #

1. Display the current routing table:

root@myserver# netstat -rn

Routing Table: IPv4
  Destination           Gateway           Flags  Ref   Use   Interface
-------------------- -------------------- ----- ----- ------ ---------

10.6.40.0            10.6.40.40           U         1   2747  bge0
10.6.40.0            10.6.40.60           UG        1      0  
192.168.199.0        10.6.40.60           UG        1   4783  
192.168.199.0        10.6.40.60           UG        1      0  
default              192.168.4.254       UG        1 128435  
127.0.0.1            127.0.0.1            UH        7   4277  lo0
root@myserver # 

2. Add the new route entry into the routing table:

root@myserver # route add -net 172.27.97.0 -netmask 255.255.255.0 10.6.40.60
add net 172.27.97.0: gateway 10.6.40.60
root@myserver #

3. Print the new routing table again to comfirm entry:

root@myserver# netstat -rn

Routing Table: IPv4
  Destination           Gateway           Flags  Ref   Use   Interface
-------------------- -------------------- ----- ----- ------ ---------

10.6.40.0            10.6.40.40           U         1   2747  bge0
10.6.40.0            10.6.40.60           UG        1      0  
192.168.199.0        10.6.40.60           UG        1   4783  
192.168.199.0        10.6.40.60           UG        1      0  
172.27.97.0          10.6.40.60           UG        1      1 
default              192.168.4.254       UG        1 128435  
127.0.0.1            127.0.0.1            UH        7   4277  lo0
root@myserver # 

4. And if you need to delete the route entry:

root@myserver #route delete -net 172.27.97.0 -netmask 255.255.255.0 10.6.40.60
delete net 172.27.97.0: gateway 10.6.40.61

5. Print the routing table again to confirm that it has been deleted:

root@myserver# netstat -rn

Routing Table: IPv4
  Destination           Gateway           Flags  Ref   Use   Interface
-------------------- -------------------- ----- ----- ------ ---------

10.6.40.0            10.6.40.40           U         1   2747  bge0
10.6.40.0            10.6.40.60           UG        1      0  
192.168.199.0        10.6.40.60           UG        1   4783  
192.168.199.0        10.6.40.60           UG        1      0  
default              192.168.4.254       UG        1 128435  
127.0.0.1            127.0.0.1            UH        7   4277  lo0
root@myserver #