how i add route
how i add route
I want to add a route to this server. How do I add a route. After adding a route, Should the network service be restart. If I do, the server access is broken?
I intend to use this command for bond0. Can I add with this command. ( route add -net IP netmask IP gw IP )
Thanks for helping
I intend to use this command for bond0. Can I add with this command. ( route add -net IP netmask IP gw IP )
Thanks for helping
Last edited by good_face on 2020/09/11 18:22:37, edited 2 times in total.
Re: how i add route
If you want to change configuration, then you should use whatever you are using to configure the network settings.
While you can temporarily change runtime config, it is important to store more persistent config too.
The default in CentOs 7 is to use NetworkManager.service. The alternative is network.service.
If you get main bits of config from DHCP server with either of those, then your DHCP server can offer the additional routes too.
The "route" is a tool that could have been forgotten two decades ago, when iproute2 package did appear.
I like the output of ip ro because it shows routes in same syntax that ip ro add will accept.
It seems that you do already have some static routes. (Hard to tell, I never did learn to read output of 'route'.)
How did you configure those?
While you can temporarily change runtime config, it is important to store more persistent config too.
The default in CentOs 7 is to use NetworkManager.service. The alternative is network.service.
If you get main bits of config from DHCP server with either of those, then your DHCP server can offer the additional routes too.
The "route" is a tool that could have been forgotten two decades ago, when iproute2 package did appear.
I like the output of ip ro because it shows routes in same syntax that ip ro add will accept.
It seems that you do already have some static routes. (Hard to tell, I never did learn to read output of 'route'.)
How did you configure those?
Re: how i add route
I'm sorry, I didnt understand. I'll add a new route here what are the how to add commands.
Re: how i add route
I usually use nmcli to add routes. Command would be:
nmcli c m NIC +ipv4.routes "destination/subnet gateway"
example: nmcli c m ens33 +ipv4.routes "192.168.10.0/24 192.168.1.254"
A few notes, if you're routing to a specific address you don't need to add the subnet and if you want to replace routes remove the + from ipv4.routes.
nmcli has a decent example man page as well: man nmcli-examples
nmcli c m NIC +ipv4.routes "destination/subnet gateway"
example: nmcli c m ens33 +ipv4.routes "192.168.10.0/24 192.168.1.254"
A few notes, if you're routing to a specific address you don't need to add the subnet and if you want to replace routes remove the + from ipv4.routes.
nmcli has a decent example man page as well: man nmcli-examples
Re: how i add route
is it true ? i will add route like that . the method may be different. I just want to find out if it's true
Last edited by good_face on 2020/09/12 18:39:40, edited 1 time in total.
static route
i will add static route but file is empt so why it is empty . how i can add new route
i want to add this 192.168.1.0/24 via 192.168.1.1
Where are the rope definitions I see written ?
i want to add this 192.168.1.0/24 via 192.168.1.1
Where are the rope definitions I see written ?
Last edited by good_face on 2020/09/12 18:39:25, edited 1 time in total.
Re: static route
You don't seem to have an interface on that subnet so you don't have a way to get to 192.168.1.1 without sending the packets out via your default route.i want to add this 192.168.1.0/24 via 192.168.1.1
Use ip route get $ip and it will tell you which route it will take.
Edit: merged this and your other thread since they appear to be the same thing.
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
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
Re: how i add route
I guess I asked my question wrong. my question is, I'll add a new route. everyone says Write a new route into /etc/sysconfig/network-scripts/route-interface. but I see the file/etc/sysconfig/network-scripts / route-bond empty. why is the file hollow and I see routes when I type the route command. I wrote down the IP addresses I gave as examples . do not pay attention to the ip address I will write a different ip address. a different method for writing a route is written ? how do I see it when I add a new route and type the route command. I don't use linux. I just started learning
Re: how i add route
You only need to use those route files if you are adding non-standard routes. All interfaces automatically get used for routing the traffic for their local subnet without needing to add a specific route. For example, if you have an interface called eth9 and it has an ip address of 192.168.66.5 with netmask 255.255.255.0 then it automatically gets a route added to say that 192.168.66./024 goes via it.
For your example where you want to ip route add 192.168.1.0/24 via 192.168.1.1, that can only work if you have an interface that knows how to get to 192.168.1.1 in the first place so it's not going to work. You can only route via things that it knows how to get to in the first place so if you run ip route get 192.168.1.1 it will currently tell you that it will go via your default route since you have no interface on 192.168.1.0/24 and nor do you have an existing route that tells it how to get to 192.168.1.1. And if you did have an interface on 192.168.1.0/24 then you wouldn't need to add that route anyway as 192.168.1.1 is within 192.168.1.0/24 so it would already know that it had to use that interface to get there.
Also, the route command is deprecated and has been for about 15 years. Please use the ip route command as it's better maintained, gives better output and knows things that route does not.
Also, if you're going to ask for help for networking questions, it is important to use the actual information you want to use and not obscure actual ip addresses and routes. That way will just lead to misleading answers and wrong information that won't help you.
For your example where you want to ip route add 192.168.1.0/24 via 192.168.1.1, that can only work if you have an interface that knows how to get to 192.168.1.1 in the first place so it's not going to work. You can only route via things that it knows how to get to in the first place so if you run ip route get 192.168.1.1 it will currently tell you that it will go via your default route since you have no interface on 192.168.1.0/24 and nor do you have an existing route that tells it how to get to 192.168.1.1. And if you did have an interface on 192.168.1.0/24 then you wouldn't need to add that route anyway as 192.168.1.1 is within 192.168.1.0/24 so it would already know that it had to use that interface to get there.
Also, the route command is deprecated and has been for about 15 years. Please use the ip route command as it's better maintained, gives better output and knows things that route does not.
Also, if you're going to ask for help for networking questions, it is important to use the actual information you want to use and not obscure actual ip addresses and routes. That way will just lead to misleading answers and wrong information that won't help 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
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
Re: how i add route
I got it. I'll write a route definition for 10.183.248.0. gw: 10.181.20.65 mask 255.255.255.0 how can I add a route in this way. can you type the command? for my machine. I'd be very happy if you'd write how to write or do it because I'm a beginner. I don't want it to be deleted when the server is restarted. When I add a new route, will I reboot the service? And also running apps on it will be affected before reboot the service ?
thank you very much
thank you very much