How to add routes to the ip tables to see other subnets?

Issues related to configuring your network
Post Reply
Jessuz94
Posts: 12
Joined: 2015/07/20 19:57:46

How to add routes to the ip tables to see other subnets?

Post by Jessuz94 » 2015/07/20 20:04:17

If i have one server with a static ip, example (192.168.1.x) if i want to connect this server to one switch in one Site with others servrs and router and switches, and these devices had another subnets, like 192.168.2,3,4,5. How to add the routes in the CentOS server to ping these devices?

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: How to add routes to the ip tables to see other subnets?

Post by gerald_clark » 2015/07/20 21:48:40

You need routers.

User avatar
TrevorH
Site Admin
Posts: 33219
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How to add routes to the ip tables to see other subnets?

Post by TrevorH » 2015/07/20 22:21:04

You can add routes per interface by creating e.g /etc/sysconfig/network-scripts/route-eth0 (name varies according to interface name). The contents are the portion of e.g ip route add 10.0.0.0/8 via 172.16.1.1 but minus the "ip route add".
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

Jessuz94
Posts: 12
Joined: 2015/07/20 19:57:46

Re: How to add routes to the ip tables to see other subnets?

Post by Jessuz94 » 2015/07/21 16:38:55

172.16.1.1 is the example of mi ip server dont you?, and this is for each network that i want to go?

User avatar
TrevorH
Site Admin
Posts: 33219
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How to add routes to the ip tables to see other subnets?

Post by TrevorH » 2015/07/21 17:50:23

Yes, that was example that said, "any traffic destined host any hosts on 10.0.0.0/8 should be sent to the router 172.16.1.1". Neither of them would be your server IP, the first is the subnet you want to send a different route than the default, the IP address is the router than can send the traffic there for you.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

Jessuz94
Posts: 12
Joined: 2015/07/20 19:57:46

Re: How to add routes to the ip tables to see other subnets?

Post by Jessuz94 » 2015/07/28 18:54:31

Sorry for the soo late answer, i was in vacations :c, so, if i want to add more subnets i need to create another file or just another line?, suppossing that i only used one network card (eth0)

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: How to add routes to the ip tables to see other subnets?

Post by gerald_clark » 2015/07/28 19:02:34

If you only have one NIC and one router, just define the default GATEWAY in /etc/sysconfig/network.
If you have multiple routers to different networks, define those routes as stated previously.
Please read the FAQ http://wiki.centos.org/FAQ/CentOS7

Post Reply