Results 1 to 5 of 5
Hello,
I'm new to Linux and was looking to setup a custom routing
for a specific network.
In windows, I used to type this command:
"route –p add 192.168.1.0 mask ...
- 09-11-2011 #1Just Joined!
- Join Date
- Sep 2011
- Posts
- 9
help with "route" command on CentOS
Hello,
I'm new to Linux and was looking to setup a custom routing
for a specific network.
In windows, I used to type this command:
"route –p add 192.168.1.0 mask 255.255.255.0 192.168.2.50"
which does set the PC (which belongs to 192.168.2.0 network)
to remember this route even on reboots, and tells it to route all
packages for network 192.168.1.0 via the gateway 192.168.2.50
which is my VPN crossing bridge to the other network...
Can anyone help me how I can do the same in Linux / CentOS?Last edited by mzraptor; 09-11-2011 at 10:59 AM.
- 09-11-2011 #2
I assume, that the device with the IP 192.168.2.x is eth0.
For a reboot safe config, create/edit /etc/sysconfig/network-scripts/route-eth0 with the following content:
To create the route adhoc, use thisCode:192.168.1.0/24 via 192.168.2.50 dev eth0
Code:route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.2.50 dev eth0
You must always face the curtain with a bow.
- 09-11-2011 #3
For additional informations, look here:
14.4.*Configuring Static RoutesYou must always face the curtain with a bow.
- 09-11-2011 #4Just Joined!
- Join Date
- Sep 2011
- Posts
- 9
- 09-13-2011 #5Just Joined!
- Join Date
- Sep 2011
- Posts
- 19
You can do this with iproute2's "ip" command from the commandline as well if you do not need the route to persist between reboots:
ip route add 192.168.1.0/24 via 192.168.2.50 dev eth0
If you need to change the route, you could do:
ip route replace 192.168.1.0/24 via 192.168.222.50 dev eth0


Reply With Quote
