Oracle linux route add

Routing IP Traffic on Linux

Most of the time routing will be done by your network hardware, but it can be done using Linux.

This article provides an introduction to routing IP traffic on Linux, with specific reference to the information needed for the RHCE EX300 certification exam.

Remember, the exams are hands-on, so it doesn’t matter which method you use to achieve the result, so long as the end product is correct.

Route IP Traffic

Routes are dynamically managed using the route or ip route commands.

A default routes can be managed as follows.

# route del default gw 192.168.0.1 # route add default gw 192.168.0.1 # ip route del default via 192.168.0.1 # ip route add default via 192.168.0.1

Specific routes can be added, with or without a default gateway setting, using the following commands.

# route add -net 172.168.2.0 netmask 255.255.255.0 dev eth0 # route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.0.1 dev eth0 # ip route add 172.168.3.0/24 dev eth0 # ip route add 172.168.4.0/24 via 192.168.0.1 dev eth0

Route information is be displayed as follows.

# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default 192.168.0.1 0.0.0.0 UG 0 0 0 eth0 link-local * 255.255.0.0 U 1002 0 0 eth0 172.168.2.0 * 255.255.255.0 U 0 0 0 eth0 172.168.3.0 * 255.255.255.0 U 0 0 0 eth0 172.168.4.0 192.168.0.1 255.255.255.0 UG 0 0 0 eth0 192.168.0.0 * 255.255.255.0 U 0 0 0 eth0 192.168.1.0 192.168.0.1 255.255.255.0 UG 0 0 0 eth0 # # ip route default via 192.168.0.1 dev eth0 proto static 169.254.0.0/16 dev eth0 scope link metric 1002 172.168.2.0/24 dev eth0 scope link 172.168.3.0/24 dev eth0 scope link 172.168.4.0/24 via 192.168.0.1 dev eth0 192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.190 192.168.1.0/24 via 192.168.0.1 dev eth0 #

Routes are removed using the following commands.

# route del -net 172.168.2.0 netmask 255.255.255.0 dev eth0 # route del -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.0.1 dev eth0 # ip route del 172.168.4.0/24 via 192.168.0.1 dev eth0 # ip route del 172.168.3.0/24 dev eth0

Create Permanent Static Routes

The static routes configured in the previous section are all transient, in that they are lost on reboot. To configure a permanent static route for an interface, create a file with the following format «/etc/sysconfig/network-scripts/route-«. For example, we could create the «/etc/sysconfig/network-scripts/route-eth0» file with the following entries.

172.168.2.0/24 via 192.168.0.1 dev eth0 172.168.4.0/24 via 192.168.0.1 dev eth0

We can then stop and start the interface as follows.

# cd /etc/sysconfig/network-scripts/ # ifdown eth0 # ifup eth0

In addition, the default gateway can be specified globally in the «/etc/sysconfig/network» file, for the interface in the «/etc/sysconfig/network-scripts/ifcfg-«.

Читайте также:  Linux delete path variable

Hope this helps. Regards Tim.

Created: 2013-02-06 Updated: 2015-06-27

Источник

Configuring and Managing Network Components in Oracle ® Solaris 11.3

You use the route command to manually manipulate the network routing tables. Because the /etc/defaultrouter file is deprecated in Oracle Solaris 11.3, you can no longer manage routes (default or otherwise) by using this file. Using the route command is the only way that you can manually make routes persistent across system reboots. To make the changes persist across system reboots, use the –p option with the route command.

In this release, naming of persistent static routes is also supported. Use the –name option with the route command to add, change, delete, and display information about persistent (static) routes. This support is limited to persistent static routes only. For more complete details about this option see the route(1M) man page.

When adding routes persistently make sure that routes that you add do not already exist in the persistent configuration. If these routes already exist in the persistent configuration, the network routing tables could change without updating the persistent route. An example would be a situation where the system’s default route is mapped to the system’s primary interface (which is frequently the case after an Oracle Solaris installation). If you subsequently change the system’s primary interface to another interface, then the system’s default route should also be updated persistently. A best practice is to delete the persistent route configuration prior to adding the new route. For more information, see Troubleshooting Issues When Adding a Persistent Route in Troubleshooting Network Administration Issues in Oracle Solaris 11.3.

Note the following additional information about creating and displaying information about persistent routes:

# route -p add default ip-address
# route -p add destination-address gateway-address -name name

For more information, see the netstat(1M) and route(1M) man pages.

How to Add a Persistent Static Route by Specifying Destination and Gateway

Routing Table: IPv4 Destination Gateway Flags Ref Use Interface -------------------- -------------------- ----- ----- ---------- --------- 192.0.2125 192.0.2.10 U 1 5879 net0 224.0.0.0 198.0.2.10 U 1 0 net0 default 192.0.2.10 UG 1 91908 127.0.0.1 127.0.0.1 UH 1 811302 lo0 Routing Table: IPv6 Destination/Mask Gateway Flags Ref Use If --------------------------- --------------------------- ----- --- ------- ----- ::1 ::1 UH 2 0 lo0
# route -p add -net network-address -gateway gateway-address

The following example shows how to add a static route to a router (Router 2). The static route is needed for the AS’s border router, 203.0.113.150. See Autonomous System With Multiple IPv4 Routers for an illustration of this particular setup.

You would view the routing table on Router 2 as follows:

# netstat -rn Routing Table: IPv4 Destination Gateway Flags Ref Use Interface -------------------- -------------------- ----- ----- ------ --------- default 198.51.100.10 UG 1 249 ce0 224.0.0.0 198.51.100.10 U 1 0 ce0 203.0.113.0 203.0.113.20 U 1 78 bge0 127.0.0.1 127.0.0.1 UH 1 57 lo0 Routing Table: IPv6 Destination/Mask Gateway Flags Ref Use If --------------------------- --------------------------- ----- --- ------- ----- ::1 ::1 UH 2 0 lo0

The routing table indicates that there are two routes that Router 2 knows about. The default route uses Router 2’s 198.51.100.10 interface as its gateway. The second route, 203.0.113.0, was discovered by the in.routed daemon that is running on Router 2. The gateway for this route is Router 1 and it has the IP address 203.0.113.20.

Читайте также:  Manjaro linux kde install

You would add a second route to network 203.0.113.0, which has its gateway as the border router, as follows:

# route -p add -net 203.0.113.0/24 -gateway 203.0.113.150 add net 203.0.113.0: gateway 203.0.113.150

The routing table now has a route for the border router, which has the IP address 203.0.113.150.

# netstat -rn Routing Table: IPv4 Destination Gateway Flags Ref Use Interface -------------------- -------------------- ----- ----- ------ --------- default 198.51.100.10 UG 1 249 ce0 224.0.0.0 198.51.100.10 U 1 0 ce0 203.0.113.0 203.0.113.20 U 1 78 bge0 203.0.113.0 203.0.113.150 U 1 375 bge0 127.0.0.1 127.0.0.1 UH 1 57 lo0 Routing Table: IPv6 Destination/Mask Gateway Flags Ref Use If --------------------------- --------------------------- ----- --- ------- ----- ::1 ::1 UH 2 0 lo0

How to Specify a Name for a Persistent Static Route

When you add a persistent static route, you can provide a name for the route by using the –name option. You can specify any name other than the name, default, as this name has a special meaning within the context of routing configuration. See the route(1M) man page for more information.

If you create a persistent route by specifying the –name option, you can display information about the route by specifying its name rather than the destination. You can also modify and delete the route by specifying its name. Note that you cannot use the –name option to name an existing route. Nor can you change the name of a route that you previously named by using this option. To assign a name to an existing route or to modify the name of an existing route that you previously named, first delete that route and then add the route again by specifying the –name option.

  1. Become an administrator.
  2. Add a persistent route by specifying a name.
# route -p add destination-address gateway-address -name name
# route get -name route-name

The following example shows how you would add a persistent static route (route1) by specifying a name.

# route -p add 9.9.9.9 3.3.3.9 -name route1 persistent: route add 9.9.9.9 3.3.3.9 -name route1
# route get -name route1 route to : 9.9.9.9 name : route1 destination : 9.9.9.9 mask : 255.255.255.25 gateway : 3.3.3.9 interface : net0 flags : recvpipe sendpipe ssthresh rtt,ms rttvar,ms hopcount mtu expire 0 0 0 0 0 0 1500 0

The following example shows how to modify information for a persistent route by specifying its name. In this example, the gateway information is changed. Note that the persistent route must have been added by specifying a name initially.

# route -p show persistent: route add 9.9.9.9 3.3.3.9 -name route1 # route change -name route1 9.9.8.8 change host -name route1 9.9.9.9: gateway 9.9.8.8

The following example shows how you would delete a persistent route by specifying its name. Note that the persistent route must have been added by specifying a name initially.

# route -p delete -name route1 delete host -name route1 9.9.9.9: gateway 3.3.3.9: not in table delete persistent host -name route1 9.9.9.9: gateway 3.3.3.9

If you do not speicfy the –p option with the –name option, the route is removed from the routing tables only, as shown in the following example:

# route delete -name route1 delete host -name route1 9.9.9.9: gateway 3.3.3.9

Источник

Oracle Linux Add route & Delete route Default Gateway

You can Change default gateway and routing settings. I will explain Oracle Linux Add route & Delete route Default Gateway in this post.

Linux Add route delete route default gateway

Add & Delete default gateway

You can add default gateway to the linux like below.

route add default gw 192.168.163.1

If you want to delete default gateway you can execute like following script.

route delete default gw 192.168.163.1 eth1

Add route & Delete route

You can add routing and gateway settings like below.

route add -net 192.168.63.0/24 gw 192.168.163.1

Or if you want to do permanent routing, you can create route file like below.

[[email protected] ~]# [[email protected] network-scripts]# cat route-eth1 192.168.63.0/24 via 192.168.163.1 dev eth1 192.168.161.0/24 via 192.168.161.1 dev eth0

If you create routing file like above then you can restart network service like below.

[[email protected] network-scripts]# service network restart

then Routing will be like below.

[[email protected] network-scripts]# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default 192.168.161.1 0.0.0.0 UG 0 0 0 eth0 link-local * 255.255.0.0 U 0 0 0 ibbond0 192.168.161.0 * 255.255.255.0 U 0 0 0 eth0 192.168.16.0 * 255.255.255.0 U 0 0 0 ibbond0 192.168.18.0 * 255.255.255.0 U 0 0 0 veth1 192.168.19.0 192.168.18.1 255.255.255.0 UG 0 0 0 veth1 192.168.63.0 192.168.163.1 255.255.255.0 UG 0 0 0 eth1 192.168.163.0 * 255.255.255.0 U 0 0 0 eth1

Do you want to learn Linux System Administration for Beginners, then read the following articles.

About Mehmet Salih Deveci

I am Founder of SysDBASoft IT and IT Tutorial and Certified Expert about Oracle & SQL Server database, Goldengate, Exadata Machine, Oracle Database Appliance administrator with 10+years experience.I have OCA, OCP, OCE RAC Expert Certificates I have worked 100+ Banking, Insurance, Finance, Telco and etc. clients as a Consultant, Insource or Outsource.I have done 200+ Operations in this clients such as Exadata Installation & PoC & Migration & Upgrade, Oracle & SQL Server Database Upgrade, Oracle RAC Installation, SQL Server AlwaysOn Installation, Database Migration, Disaster Recovery, Backup Restore, Performance Tuning, Periodic Healthchecks.I have done 2000+ Table replication with Goldengate or SQL Server Replication tool for DWH Databases in many clients.If you need Oracle DBA, SQL Server DBA, APPS DBA, Exadata, Goldengate, EBS Consultancy and Training you can send my email adress [email protected] .- -Oracle DBA, SQL Server DBA, APPS DBA, Exadata, Goldengate, EBS ve linux Danışmanlık ve Eğitim için [email protected] a mail atabilirsiniz.

Источник

Оцените статью
Adblock
detector