Difference between revisions of "Redhat: Network Routing"

From Define Wiki
Jump to navigation Jump to search
(Created page with "== View the current routing tables == There are two equivalent commands to view the current routing tables. Using the -n flag displays ip address instead of hostnames <bash...")
 
 
Line 46: Line 46:
  
 
{| class="wikitable"
 
{| class="wikitable"
|-
 
 
| Flag  || Purpose  
 
| Flag  || Purpose  
 
|-
 
|-
|-a || Show all networks
+
| a || Show all networks
 
|-
 
|-
|-t || Using TCP
+
| t || Using TCP
 
|-
 
|-
|-u || Using UDP
+
| u || Using UDP
 
|-
 
|-
|-n || Using Numeric format
+
| n || Using Numeric format
 
|-
 
|-
|
 
 
|}
 
|}

Latest revision as of 12:00, 18 August 2013

View the current routing tables

There are two equivalent commands to view the current routing tables. Using the -n flag displays ip address instead of hostnames

netstat -nr
route -n
[root@compute011 ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 ib0
172.16.0.0      0.0.0.0         255.255.0.0     U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1005   0        0 ib0
239.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 ib0
0.0.0.0         172.16.1.1      0.0.0.0         UG    0      0        0 eth0

Each Destination is a network. The default destination (0.0.0.0) refers to all other networks.

A gateway is supplied only if the gateway is not on the same network, otherwise the default gateway is 0.0.0.0.

Networks look for the route that applies by comparing its IP address to each destination in order. If there is a gateway, packets are sent to the system with that IP.


Adding a route

The netstat and route commands have different uses. The route command is used to add and edit routing information in the route table.

To add a route

route add default gw 192.168.122.1 #default route
route add -net 192.168.100.0 netmask 255.255.255.0 dev eth1 #routes the network through device eth1


Identify Open Ports

The netstat command can be used to identify open ports on the system when used with the right flags.

Running netstart -atunp will list all open ports on the system

Flag Purpose
a Show all networks
t Using TCP
u Using UDP
n Using Numeric format