centos 7 persistent static routeBonding and default gateway problem (CentOS)help with a static route on centos 5.6 pleasePersistent static route stops working after VPN drops and reconnectsAdd Persistent Static Route in Centos 5CentOS 7 (Dracut) - Network boot with gateway in different subnetRoute traffic through private IP for only certain hosts - CentOS 6.6Can't bridge traffic between a wireless and wired interface of a windows 7 laptopConfigure network for Firewall serverConfiguring a Hurricane Electric IPv6 tunnel without being the default gatewayStatic routing in Linux (as a router)

Is it possible to have battery technology that can't be duplicated?

Is it a good security practice to force employees hide their employer to avoid being targeted?

Why can't we feel the Earth's revolution?

Realistic, logical way for men with medieval-era weaponry to compete with much larger and physically stronger foes

What's the reason for the decade jump in the recent X-Men trilogy?

Why did Robert pick unworthy men for the White Cloaks?

New Site Design!

Placement of positioning lights on A320 winglets

What is the color associated with lukewarm?

What is the theme of analysis?

Why does this Apple //e drops into system monitor when booting?

Short story about psychologist analyzing demon

Can Mage Hand be used to indirectly trigger an attack?

usage of mir gefallen

Keeping track of theme when improvising

Idiom for 'person who gets violent when drunk"

Why is Skinner so awkward in Hot Fuzz?

Does WiFi affect the quality of images downloaded from the internet?

Must a CPU have a GPU if the motherboard provides a display port (when there isn't any separate video card)?

Someone who is granted access to information but not expected to read it

Is it true that "only photographers care about noise"?

Is this equation correct? And if so, is this famous?

Why is C++ template use not recommended in space/radiated environment?

Approach sick days in feedback meeting



centos 7 persistent static route


Bonding and default gateway problem (CentOS)help with a static route on centos 5.6 pleasePersistent static route stops working after VPN drops and reconnectsAdd Persistent Static Route in Centos 5CentOS 7 (Dracut) - Network boot with gateway in different subnetRoute traffic through private IP for only certain hosts - CentOS 6.6Can't bridge traffic between a wireless and wired interface of a windows 7 laptopConfigure network for Firewall serverConfiguring a Hurricane Electric IPv6 tunnel without being the default gatewayStatic routing in Linux (as a router)






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have a centos 7 server, with 4 interfaces. i am trying to give each of these interfaces a different ip, gateway and netmask.



I want each interface to respond requests itself. so if a request has came in on interface enp2s0, i want enp2s0 to respond to request.



I have one interface for Management (guess enp2s0) and it should be only available in internal network and stuff like that.



So, i have a default gateway set in /etc/sysconfigs/network :



GATEWAY=192.168.0.1


in the test case, 192.168.0.1 has access to internet.



then, i have my interfaces setup this way:



enp2s0 (static ip: 192.168.0.176):



192.168.0.0/24 via 192.168.0.176 dev enp2s0


enp3s0(static ip: 192.168.50.40):



default via 192.168.0.1 dev enp3s0
192.168.50.0/24 via 192.168.50.1 dev enp3s0


enp4s0 (static ip: 192.168.30.40):



192.168.30.0/24 via 192.168.30.1 dev enp4s0


and this is my ip route show all command:



default via 192.168.0.1 dev enp2s0 proto static metric 100 
default via 192.168.0.1 dev enp4s0 proto static metric 101
192.168.0.0/24 dev enp2s0 proto kernel scope link src 192.168.0.176 metric 100
192.168.0.1 dev enp4s0 proto static scope link metric 100
192.168.30.0/24 dev enp4s0 proto kernel scope link src 192.168.30.40 metric 100
192.168.50.0/24 dev enp3s0 proto kernel scope link src 192.168.50.40 metric 100


what should i change? i want to be able to respond to all requests coming in, from the same interface that got the request.



all of the interfaces are connected to a router, so i don't have ip range matching problem, and can receive all the traffic.










share|improve this question






















  • By default Linux uses a single TCP/IP stack and routing table shared by all interfaces on your system. That is usually very efficient, but it sounds like you want to have each interface completely independent from the others, with their own ip-address and different (default) routes. You usually achieve that by creating separate network namespaces. See for instance man7.org/linux/man-pages/man8/ip-netns.8.html

    – HBruijn
    Jun 13 '18 at 7:15











  • @HBruijn since no one answered, is there anyway to do it with persistent routes? i am trying to code a script that does it, so we can change networking settings instantly and easily, we have previously have done it with route tables in each ifcfg-X file, but i came up with static routes.

    – senaps
    Jun 17 '18 at 6:09

















0















I have a centos 7 server, with 4 interfaces. i am trying to give each of these interfaces a different ip, gateway and netmask.



I want each interface to respond requests itself. so if a request has came in on interface enp2s0, i want enp2s0 to respond to request.



I have one interface for Management (guess enp2s0) and it should be only available in internal network and stuff like that.



So, i have a default gateway set in /etc/sysconfigs/network :



GATEWAY=192.168.0.1


in the test case, 192.168.0.1 has access to internet.



then, i have my interfaces setup this way:



enp2s0 (static ip: 192.168.0.176):



192.168.0.0/24 via 192.168.0.176 dev enp2s0


enp3s0(static ip: 192.168.50.40):



default via 192.168.0.1 dev enp3s0
192.168.50.0/24 via 192.168.50.1 dev enp3s0


enp4s0 (static ip: 192.168.30.40):



192.168.30.0/24 via 192.168.30.1 dev enp4s0


and this is my ip route show all command:



default via 192.168.0.1 dev enp2s0 proto static metric 100 
default via 192.168.0.1 dev enp4s0 proto static metric 101
192.168.0.0/24 dev enp2s0 proto kernel scope link src 192.168.0.176 metric 100
192.168.0.1 dev enp4s0 proto static scope link metric 100
192.168.30.0/24 dev enp4s0 proto kernel scope link src 192.168.30.40 metric 100
192.168.50.0/24 dev enp3s0 proto kernel scope link src 192.168.50.40 metric 100


what should i change? i want to be able to respond to all requests coming in, from the same interface that got the request.



all of the interfaces are connected to a router, so i don't have ip range matching problem, and can receive all the traffic.










share|improve this question






















  • By default Linux uses a single TCP/IP stack and routing table shared by all interfaces on your system. That is usually very efficient, but it sounds like you want to have each interface completely independent from the others, with their own ip-address and different (default) routes. You usually achieve that by creating separate network namespaces. See for instance man7.org/linux/man-pages/man8/ip-netns.8.html

    – HBruijn
    Jun 13 '18 at 7:15











  • @HBruijn since no one answered, is there anyway to do it with persistent routes? i am trying to code a script that does it, so we can change networking settings instantly and easily, we have previously have done it with route tables in each ifcfg-X file, but i came up with static routes.

    – senaps
    Jun 17 '18 at 6:09













0












0








0








I have a centos 7 server, with 4 interfaces. i am trying to give each of these interfaces a different ip, gateway and netmask.



I want each interface to respond requests itself. so if a request has came in on interface enp2s0, i want enp2s0 to respond to request.



I have one interface for Management (guess enp2s0) and it should be only available in internal network and stuff like that.



So, i have a default gateway set in /etc/sysconfigs/network :



GATEWAY=192.168.0.1


in the test case, 192.168.0.1 has access to internet.



then, i have my interfaces setup this way:



enp2s0 (static ip: 192.168.0.176):



192.168.0.0/24 via 192.168.0.176 dev enp2s0


enp3s0(static ip: 192.168.50.40):



default via 192.168.0.1 dev enp3s0
192.168.50.0/24 via 192.168.50.1 dev enp3s0


enp4s0 (static ip: 192.168.30.40):



192.168.30.0/24 via 192.168.30.1 dev enp4s0


and this is my ip route show all command:



default via 192.168.0.1 dev enp2s0 proto static metric 100 
default via 192.168.0.1 dev enp4s0 proto static metric 101
192.168.0.0/24 dev enp2s0 proto kernel scope link src 192.168.0.176 metric 100
192.168.0.1 dev enp4s0 proto static scope link metric 100
192.168.30.0/24 dev enp4s0 proto kernel scope link src 192.168.30.40 metric 100
192.168.50.0/24 dev enp3s0 proto kernel scope link src 192.168.50.40 metric 100


what should i change? i want to be able to respond to all requests coming in, from the same interface that got the request.



all of the interfaces are connected to a router, so i don't have ip range matching problem, and can receive all the traffic.










share|improve this question














I have a centos 7 server, with 4 interfaces. i am trying to give each of these interfaces a different ip, gateway and netmask.



I want each interface to respond requests itself. so if a request has came in on interface enp2s0, i want enp2s0 to respond to request.



I have one interface for Management (guess enp2s0) and it should be only available in internal network and stuff like that.



So, i have a default gateway set in /etc/sysconfigs/network :



GATEWAY=192.168.0.1


in the test case, 192.168.0.1 has access to internet.



then, i have my interfaces setup this way:



enp2s0 (static ip: 192.168.0.176):



192.168.0.0/24 via 192.168.0.176 dev enp2s0


enp3s0(static ip: 192.168.50.40):



default via 192.168.0.1 dev enp3s0
192.168.50.0/24 via 192.168.50.1 dev enp3s0


enp4s0 (static ip: 192.168.30.40):



192.168.30.0/24 via 192.168.30.1 dev enp4s0


and this is my ip route show all command:



default via 192.168.0.1 dev enp2s0 proto static metric 100 
default via 192.168.0.1 dev enp4s0 proto static metric 101
192.168.0.0/24 dev enp2s0 proto kernel scope link src 192.168.0.176 metric 100
192.168.0.1 dev enp4s0 proto static scope link metric 100
192.168.30.0/24 dev enp4s0 proto kernel scope link src 192.168.30.40 metric 100
192.168.50.0/24 dev enp3s0 proto kernel scope link src 192.168.50.40 metric 100


what should i change? i want to be able to respond to all requests coming in, from the same interface that got the request.



all of the interfaces are connected to a router, so i don't have ip range matching problem, and can receive all the traffic.







centos centos7 static-routes






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 13 '18 at 5:00









senapssenaps

1137




1137












  • By default Linux uses a single TCP/IP stack and routing table shared by all interfaces on your system. That is usually very efficient, but it sounds like you want to have each interface completely independent from the others, with their own ip-address and different (default) routes. You usually achieve that by creating separate network namespaces. See for instance man7.org/linux/man-pages/man8/ip-netns.8.html

    – HBruijn
    Jun 13 '18 at 7:15











  • @HBruijn since no one answered, is there anyway to do it with persistent routes? i am trying to code a script that does it, so we can change networking settings instantly and easily, we have previously have done it with route tables in each ifcfg-X file, but i came up with static routes.

    – senaps
    Jun 17 '18 at 6:09

















  • By default Linux uses a single TCP/IP stack and routing table shared by all interfaces on your system. That is usually very efficient, but it sounds like you want to have each interface completely independent from the others, with their own ip-address and different (default) routes. You usually achieve that by creating separate network namespaces. See for instance man7.org/linux/man-pages/man8/ip-netns.8.html

    – HBruijn
    Jun 13 '18 at 7:15











  • @HBruijn since no one answered, is there anyway to do it with persistent routes? i am trying to code a script that does it, so we can change networking settings instantly and easily, we have previously have done it with route tables in each ifcfg-X file, but i came up with static routes.

    – senaps
    Jun 17 '18 at 6:09
















By default Linux uses a single TCP/IP stack and routing table shared by all interfaces on your system. That is usually very efficient, but it sounds like you want to have each interface completely independent from the others, with their own ip-address and different (default) routes. You usually achieve that by creating separate network namespaces. See for instance man7.org/linux/man-pages/man8/ip-netns.8.html

– HBruijn
Jun 13 '18 at 7:15





By default Linux uses a single TCP/IP stack and routing table shared by all interfaces on your system. That is usually very efficient, but it sounds like you want to have each interface completely independent from the others, with their own ip-address and different (default) routes. You usually achieve that by creating separate network namespaces. See for instance man7.org/linux/man-pages/man8/ip-netns.8.html

– HBruijn
Jun 13 '18 at 7:15













@HBruijn since no one answered, is there anyway to do it with persistent routes? i am trying to code a script that does it, so we can change networking settings instantly and easily, we have previously have done it with route tables in each ifcfg-X file, but i came up with static routes.

– senaps
Jun 17 '18 at 6:09





@HBruijn since no one answered, is there anyway to do it with persistent routes? i am trying to code a script that does it, so we can change networking settings instantly and easily, we have previously have done it with route tables in each ifcfg-X file, but i came up with static routes.

– senaps
Jun 17 '18 at 6:09










1 Answer
1






active

oldest

votes


















1














I have configured static and persistent rule using nmtui utility. You can play around with route metric to give proper gateway precedence. Attached an example of route config across two NICs. And here is the sample o/p:



[root@demo-host ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.15.1.1 0.0.0.0 UG 100 0 0 ens224
10.10.0.0 192.168.7.254 255.255.255.0 UG 0 0 0 ens192
10.70.0.0 192.168.7.254 255.255.255.0 UG 0 0 0 ens192
172.15.1.0 0.0.0.0 255.255.255.0 U 100 0 0 ens224
192.168.7.0 0.0.0.0 255.255.255.0 U 100 0 0 ens192
192.168.8.0 192.168.7.254 255.255.255.0 UG 0 0 0 ens192
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
[root@demo-host ~]#


nmtui edit ens192






share|improve this answer























  • I needed a way to change the routes from the code. while this method of yours works, is not the correct answer to my question. thank you for the answer, I gave you a + for the question.

    – senaps
    Jun 1 at 4:47











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "2"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f916381%2fcentos-7-persistent-static-route%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














I have configured static and persistent rule using nmtui utility. You can play around with route metric to give proper gateway precedence. Attached an example of route config across two NICs. And here is the sample o/p:



[root@demo-host ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.15.1.1 0.0.0.0 UG 100 0 0 ens224
10.10.0.0 192.168.7.254 255.255.255.0 UG 0 0 0 ens192
10.70.0.0 192.168.7.254 255.255.255.0 UG 0 0 0 ens192
172.15.1.0 0.0.0.0 255.255.255.0 U 100 0 0 ens224
192.168.7.0 0.0.0.0 255.255.255.0 U 100 0 0 ens192
192.168.8.0 192.168.7.254 255.255.255.0 UG 0 0 0 ens192
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
[root@demo-host ~]#


nmtui edit ens192






share|improve this answer























  • I needed a way to change the routes from the code. while this method of yours works, is not the correct answer to my question. thank you for the answer, I gave you a + for the question.

    – senaps
    Jun 1 at 4:47















1














I have configured static and persistent rule using nmtui utility. You can play around with route metric to give proper gateway precedence. Attached an example of route config across two NICs. And here is the sample o/p:



[root@demo-host ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.15.1.1 0.0.0.0 UG 100 0 0 ens224
10.10.0.0 192.168.7.254 255.255.255.0 UG 0 0 0 ens192
10.70.0.0 192.168.7.254 255.255.255.0 UG 0 0 0 ens192
172.15.1.0 0.0.0.0 255.255.255.0 U 100 0 0 ens224
192.168.7.0 0.0.0.0 255.255.255.0 U 100 0 0 ens192
192.168.8.0 192.168.7.254 255.255.255.0 UG 0 0 0 ens192
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
[root@demo-host ~]#


nmtui edit ens192






share|improve this answer























  • I needed a way to change the routes from the code. while this method of yours works, is not the correct answer to my question. thank you for the answer, I gave you a + for the question.

    – senaps
    Jun 1 at 4:47













1












1








1







I have configured static and persistent rule using nmtui utility. You can play around with route metric to give proper gateway precedence. Attached an example of route config across two NICs. And here is the sample o/p:



[root@demo-host ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.15.1.1 0.0.0.0 UG 100 0 0 ens224
10.10.0.0 192.168.7.254 255.255.255.0 UG 0 0 0 ens192
10.70.0.0 192.168.7.254 255.255.255.0 UG 0 0 0 ens192
172.15.1.0 0.0.0.0 255.255.255.0 U 100 0 0 ens224
192.168.7.0 0.0.0.0 255.255.255.0 U 100 0 0 ens192
192.168.8.0 192.168.7.254 255.255.255.0 UG 0 0 0 ens192
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
[root@demo-host ~]#


nmtui edit ens192






share|improve this answer













I have configured static and persistent rule using nmtui utility. You can play around with route metric to give proper gateway precedence. Attached an example of route config across two NICs. And here is the sample o/p:



[root@demo-host ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.15.1.1 0.0.0.0 UG 100 0 0 ens224
10.10.0.0 192.168.7.254 255.255.255.0 UG 0 0 0 ens192
10.70.0.0 192.168.7.254 255.255.255.0 UG 0 0 0 ens192
172.15.1.0 0.0.0.0 255.255.255.0 U 100 0 0 ens224
192.168.7.0 0.0.0.0 255.255.255.0 U 100 0 0 ens192
192.168.8.0 192.168.7.254 255.255.255.0 UG 0 0 0 ens192
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
[root@demo-host ~]#


nmtui edit ens192







share|improve this answer












share|improve this answer



share|improve this answer










answered May 29 at 17:50









m_r_nadhm_r_nadh

113




113












  • I needed a way to change the routes from the code. while this method of yours works, is not the correct answer to my question. thank you for the answer, I gave you a + for the question.

    – senaps
    Jun 1 at 4:47

















  • I needed a way to change the routes from the code. while this method of yours works, is not the correct answer to my question. thank you for the answer, I gave you a + for the question.

    – senaps
    Jun 1 at 4:47
















I needed a way to change the routes from the code. while this method of yours works, is not the correct answer to my question. thank you for the answer, I gave you a + for the question.

– senaps
Jun 1 at 4:47





I needed a way to change the routes from the code. while this method of yours works, is not the correct answer to my question. thank you for the answer, I gave you a + for the question.

– senaps
Jun 1 at 4:47

















draft saved

draft discarded
















































Thanks for contributing an answer to Server Fault!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f916381%2fcentos-7-persistent-static-route%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to write a 12-bar blues melodyI-IV-V blues progressionHow to play the bridges in a standard blues progressionHow does Gdim7 fit in C# minor?question on a certain chord progressionMusicology of Melody12 bar blues, spread rhythm: alternative to 6th chord to avoid finger stretchChord progressions/ Root key/ MelodiesHow to put chords (POP-EDM) under a given lead vocal melody (starting from a good knowledge in music theory)Are there “rules” for improvising with the minor pentatonic scale over 12-bar shuffle?Confusion about blues scale and chords

What if the end-user didn't have the required library?What is setup.py?What is a clean, pythonic way to have multiple constructors in Python?What does Ruby have that Python doesn't, and vice versa?What is the reason for having '//' in Python?How do I create a namespace package in Python?How to package shared objects that python modules depend on?setuptools vs. distutils: why is distutils still a thing?Navigation in Windows 10 vs code not going to virtualenv library when the same library is installed at user levelPython create package for local usePackaging a project that uses multiple python versionsWhy is permission denied on pip install except for when “--user” is included at end of command?

Why did Thanos need his ship to help him in the battle scene?Which actor plays Thanos in the Avengers mid-credits scene?Are there economic implications portrayed in comics where the buildings and cities are ruined almost daily?Old X-Men comic where team travels to alien world with a ring-like sun that needs recharging?Why does Ego need help sleeping?Is there an objective answer to who “the strongest Avenger” is?How did Banner get unstuck?Why did Thanos get hit?How did Thanos (or anyone) know the Infinity Stones would give him this power?Did Thanos leave Eitri alive for his after-sales service?In Avengers 1, why does Thanos need Loki?