Difference between revisions of "Route"
imported>ThorstenStaerk |
imported>ThorstenStaerk |
||
Line 10: | Line 10: | ||
<font color=blue>default 192.168.0.1 0.0.0.0 UG 0 0 0 eth1</font> | <font color=blue>default 192.168.0.1 0.0.0.0 UG 0 0 0 eth1</font> | ||
The first blue line means: If there is any IP package for an IP address 192.168.0.*, just send it over network device ''eth1''. The second blue line means: Every IP package that has not been handled yet, send over network device ''eth1'' to the default gateway 192.168.0.1. | The first blue line means: If there is any IP package for an IP address 192.168.0.*, just send it over network device ''eth1''. The second blue line means: Every IP package that has not been handled yet, send over network device ''eth1'' to the default gateway 192.168.0.1. | ||
+ | |||
+ | = Adding a rule = | ||
+ | |||
+ | == Gateway == | ||
+ | For a pc with typical network access, to add a gateway issue | ||
+ | route add default gw ''192.168.1.1'' | ||
+ | (where ''192.168.1.1'' is the address of your gateway) | ||
+ | |||
+ | == Adding a network == | ||
+ | To tell your [[Linux]] to send packages for the network 192.168.0.0[[subnet mask|/]]24 to the network device eth3: | ||
+ | route add -net 192.168.0.0 netmask 255.255.255.0 eth3 | ||
+ | The same with a default gateway of 192.168.0.1: | ||
+ | route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.0.1 eth3 | ||
= Removing a rule = | = Removing a rule = | ||
− | |||
# route -n | # route -n | ||
Kernel IP routing table | Kernel IP routing table |
Revision as of 01:57, 14 April 2009
The command route lets you view and modify your computer's network routing table. You can use it when troubleshooting network problems or when you have more than one network card.
If you just call route, you get a list of routing rules, like this:
# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.0.0 * 255.255.255.0 U 0 0 0 eth1 link-local * 255.255.0.0 U 0 0 0 eth1 loopback * 255.0.0.0 U 0 0 0 lo default 192.168.0.1 0.0.0.0 UG 0 0 0 eth1
The first blue line means: If there is any IP package for an IP address 192.168.0.*, just send it over network device eth1. The second blue line means: Every IP package that has not been handled yet, send over network device eth1 to the default gateway 192.168.0.1.
Adding a rule
Gateway
For a pc with typical network access, to add a gateway issue
route add default gw 192.168.1.1
(where 192.168.1.1 is the address of your gateway)
Adding a network
To tell your Linux to send packages for the network 192.168.0.0/24 to the network device eth3:
route add -net 192.168.0.0 netmask 255.255.255.0 eth3
The same with a default gateway of 192.168.0.1:
route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.0.1 eth3
Removing a rule
# 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 eth0 192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1 127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo 0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth1 # route delete -net 192.168.0.0 netmask 255.255.255.0 eth0 # 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 eth1 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1 127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo 0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth1