Jump to content

How to Add Multiple Routes in Linux Using ip Command Examples


securitybreach

Recommended Posts

securitybreach

Apart from the default route, you can also configure additional routes.

For example, your server you might have 2 interfaces (eth0 and eth1). By default, all the traffic is routed through interface eth0 irrespective of what IP address you have configured on eth1.

To route the incoming and outgoing traffic through eth1, other than the default route (eth0), you also need to add additional routes for eth1 .

 

In this tutorial, let us use the following example:

  • eth0 has been configured with IP address 19.86.101.54 with netmask 255.255.255.0 and default gateway of 19.86.101.1
  • eth1 has been configured with IP address 19.86.100.176 with netmask 255.255.255.0 and it’s gateway IP address is 19.86.100.1

You can view your current ip-address of your interface cards using ifconfig command as shown below.

# ifconfig -a
eth0	  Link encap:Ethernet  HWaddr 00:50:56:8E:0B:EC
	  inet addr:19.86.101.54  Bcast:19.86.101.255  Mask:255.255.255.0
	  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
	  RX packets:3735 errors:0 dropped:0 overruns:0 frame:0
	  TX packets:336 errors:0 dropped:0 overruns:0 carrier:0
	  collisions:0 txqueuelen:1000
	  RX bytes:295679 (288.7 Kb)  TX bytes:50312 (49.1 Kb)

eth1	  Link encap:Ethernet  HWaddr 00:50:56:8E:27:0D
	  inet addr:19.86.100.176  Bcast:19.86.100.255  Mask:255.255.255.0
	  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
	  RX packets:14 errors:0 dropped:0 overruns:0 frame:0
	  TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
	  collisions:0 txqueuelen:1000
	  RX bytes:840 (840.0   TX bytes:0 (0.0 

Also, the netstat command output indicates that the default gateway is pointing to eth0,.........

 

 

 

http://www.thegeekst...ute-ip-command/

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...