How To Persist ip Rule And Route Whenever Server Rebooted?
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm using Centos 7 Server And I Would Like To Save ip Rule And Route Whenever Server Rebooted.
ip rule add from x.x.x.x table 128
ip route add table 128 to y.y.y.y/y dev eth0
ip route add table 128 default via z.z.z.z
The mentioned Rule and Route lose once i reboot the server which means i need to run the 3 commands each time server rebooted.
I need to make ip rule and route persist whenever server is rebooted.
linux centos networking iptables networkmanager
add a comment |
I'm using Centos 7 Server And I Would Like To Save ip Rule And Route Whenever Server Rebooted.
ip rule add from x.x.x.x table 128
ip route add table 128 to y.y.y.y/y dev eth0
ip route add table 128 default via z.z.z.z
The mentioned Rule and Route lose once i reboot the server which means i need to run the 3 commands each time server rebooted.
I need to make ip rule and route persist whenever server is rebooted.
linux centos networking iptables networkmanager
access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/…
– Rui F Ribeiro
May 16 '17 at 13:54
RHEL7 Networking Guide: Configuring Static Routes in ifcfg files
– sebasth
Sep 21 '17 at 20:05
add a comment |
I'm using Centos 7 Server And I Would Like To Save ip Rule And Route Whenever Server Rebooted.
ip rule add from x.x.x.x table 128
ip route add table 128 to y.y.y.y/y dev eth0
ip route add table 128 default via z.z.z.z
The mentioned Rule and Route lose once i reboot the server which means i need to run the 3 commands each time server rebooted.
I need to make ip rule and route persist whenever server is rebooted.
linux centos networking iptables networkmanager
I'm using Centos 7 Server And I Would Like To Save ip Rule And Route Whenever Server Rebooted.
ip rule add from x.x.x.x table 128
ip route add table 128 to y.y.y.y/y dev eth0
ip route add table 128 default via z.z.z.z
The mentioned Rule and Route lose once i reboot the server which means i need to run the 3 commands each time server rebooted.
I need to make ip rule and route persist whenever server is rebooted.
linux centos networking iptables networkmanager
linux centos networking iptables networkmanager
edited Mar 10 at 4:27
Rui F Ribeiro
42k1483142
42k1483142
asked May 16 '17 at 12:34
αԋɱҽԃ αмєяιcαηαԋɱҽԃ αмєяιcαη
4542523
4542523
access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/…
– Rui F Ribeiro
May 16 '17 at 13:54
RHEL7 Networking Guide: Configuring Static Routes in ifcfg files
– sebasth
Sep 21 '17 at 20:05
add a comment |
access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/…
– Rui F Ribeiro
May 16 '17 at 13:54
RHEL7 Networking Guide: Configuring Static Routes in ifcfg files
– sebasth
Sep 21 '17 at 20:05
access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/…
– Rui F Ribeiro
May 16 '17 at 13:54
access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/…
– Rui F Ribeiro
May 16 '17 at 13:54
RHEL7 Networking Guide: Configuring Static Routes in ifcfg files
– sebasth
Sep 21 '17 at 20:05
RHEL7 Networking Guide: Configuring Static Routes in ifcfg files
– sebasth
Sep 21 '17 at 20:05
add a comment |
1 Answer
1
active
oldest
votes
Take a look at /etc/rc.d/rc.local
. The file states, "Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure that this script will be executed during boot." So...
chmod +x /etc/rc.d/rc.local
Then place your commands above the last line, touch /var/lock/subsys/local
.
There is better way using relevant configuration files. Rules and routes can be specified using corresponding file names. All the relevant configuration files are given below. (The device names may differ.)
/etc/iproute2/rt_tables
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-eth1
/etc/sysconfig/network-scripts/route-eth0
/etc/sysconfig/network-scripts/route-eth1
/etc/sysconfig/network-scripts/rule-eth0
/etc/sysconfig/network-scripts/rule-eth1
To create a named routing table, use /etc/iproute2/rt_tables
. I added 128 mynet
.
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
128 mynet
The EL 7.x /etc/sysconfig/network
file. The default route is GATEWAY
.
NETWORKING=yes
HOSTNAME=hostname.sld.tld
GATEWAY=10.10.10.1
THE EL 7.x /etc/sysconfig/network-scripts/ifcfg-eth0
file, without "HWADDR" and "UUID". This configures a static IP address for eth0
without using NetworkManager.
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTOCOL=none
IPADDR=10.10.10.140
NETMASK=255.255.255.0
NETWORK=10.10.10.0
BROADCAST=10.10.10.255
THE EL 7.x /etc/sysconfig/network-scripts/ifcfg-eth1
file, without "HWADDR" and "UUID". This configures a static IP address for eth1
without using NetworkManager.
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTOCOL=none
IPADDR=192.168.100.140
NETMASK=255.255.255.0
NETWORK=192.168.100.0
BROADCAST=192.168.100.255
The EL 7.x /etc/sysconfig/network-scripts/route-eth1
file. The default route was already specified in /etc/sysconfig/network
.
192.168.100.0/24 dev eth1 table mynet
default via 192.168.100.1 dev eth1 table mynet
The EL 7.x /etc/sysconfig/network-scripts/rule-eth1
file:
from 192.168.100.0/24 lookup mynet
in case if i gonna use the first option only are it's gonna save ip rule and ip route command even if server rebooted? and if yes, shall i insert the 3 commands as it is?
– αԋɱҽԃ αмєяιcαη
May 16 '17 at 13:16
It should, yes./etc/rc.d/rc.local
is a script that runs whichever commands we put in it.
– Christopher
May 16 '17 at 13:25
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f365380%2fhow-to-persist-ip-rule-and-route-whenever-server-rebooted%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
Take a look at /etc/rc.d/rc.local
. The file states, "Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure that this script will be executed during boot." So...
chmod +x /etc/rc.d/rc.local
Then place your commands above the last line, touch /var/lock/subsys/local
.
There is better way using relevant configuration files. Rules and routes can be specified using corresponding file names. All the relevant configuration files are given below. (The device names may differ.)
/etc/iproute2/rt_tables
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-eth1
/etc/sysconfig/network-scripts/route-eth0
/etc/sysconfig/network-scripts/route-eth1
/etc/sysconfig/network-scripts/rule-eth0
/etc/sysconfig/network-scripts/rule-eth1
To create a named routing table, use /etc/iproute2/rt_tables
. I added 128 mynet
.
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
128 mynet
The EL 7.x /etc/sysconfig/network
file. The default route is GATEWAY
.
NETWORKING=yes
HOSTNAME=hostname.sld.tld
GATEWAY=10.10.10.1
THE EL 7.x /etc/sysconfig/network-scripts/ifcfg-eth0
file, without "HWADDR" and "UUID". This configures a static IP address for eth0
without using NetworkManager.
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTOCOL=none
IPADDR=10.10.10.140
NETMASK=255.255.255.0
NETWORK=10.10.10.0
BROADCAST=10.10.10.255
THE EL 7.x /etc/sysconfig/network-scripts/ifcfg-eth1
file, without "HWADDR" and "UUID". This configures a static IP address for eth1
without using NetworkManager.
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTOCOL=none
IPADDR=192.168.100.140
NETMASK=255.255.255.0
NETWORK=192.168.100.0
BROADCAST=192.168.100.255
The EL 7.x /etc/sysconfig/network-scripts/route-eth1
file. The default route was already specified in /etc/sysconfig/network
.
192.168.100.0/24 dev eth1 table mynet
default via 192.168.100.1 dev eth1 table mynet
The EL 7.x /etc/sysconfig/network-scripts/rule-eth1
file:
from 192.168.100.0/24 lookup mynet
in case if i gonna use the first option only are it's gonna save ip rule and ip route command even if server rebooted? and if yes, shall i insert the 3 commands as it is?
– αԋɱҽԃ αмєяιcαη
May 16 '17 at 13:16
It should, yes./etc/rc.d/rc.local
is a script that runs whichever commands we put in it.
– Christopher
May 16 '17 at 13:25
add a comment |
Take a look at /etc/rc.d/rc.local
. The file states, "Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure that this script will be executed during boot." So...
chmod +x /etc/rc.d/rc.local
Then place your commands above the last line, touch /var/lock/subsys/local
.
There is better way using relevant configuration files. Rules and routes can be specified using corresponding file names. All the relevant configuration files are given below. (The device names may differ.)
/etc/iproute2/rt_tables
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-eth1
/etc/sysconfig/network-scripts/route-eth0
/etc/sysconfig/network-scripts/route-eth1
/etc/sysconfig/network-scripts/rule-eth0
/etc/sysconfig/network-scripts/rule-eth1
To create a named routing table, use /etc/iproute2/rt_tables
. I added 128 mynet
.
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
128 mynet
The EL 7.x /etc/sysconfig/network
file. The default route is GATEWAY
.
NETWORKING=yes
HOSTNAME=hostname.sld.tld
GATEWAY=10.10.10.1
THE EL 7.x /etc/sysconfig/network-scripts/ifcfg-eth0
file, without "HWADDR" and "UUID". This configures a static IP address for eth0
without using NetworkManager.
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTOCOL=none
IPADDR=10.10.10.140
NETMASK=255.255.255.0
NETWORK=10.10.10.0
BROADCAST=10.10.10.255
THE EL 7.x /etc/sysconfig/network-scripts/ifcfg-eth1
file, without "HWADDR" and "UUID". This configures a static IP address for eth1
without using NetworkManager.
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTOCOL=none
IPADDR=192.168.100.140
NETMASK=255.255.255.0
NETWORK=192.168.100.0
BROADCAST=192.168.100.255
The EL 7.x /etc/sysconfig/network-scripts/route-eth1
file. The default route was already specified in /etc/sysconfig/network
.
192.168.100.0/24 dev eth1 table mynet
default via 192.168.100.1 dev eth1 table mynet
The EL 7.x /etc/sysconfig/network-scripts/rule-eth1
file:
from 192.168.100.0/24 lookup mynet
in case if i gonna use the first option only are it's gonna save ip rule and ip route command even if server rebooted? and if yes, shall i insert the 3 commands as it is?
– αԋɱҽԃ αмєяιcαη
May 16 '17 at 13:16
It should, yes./etc/rc.d/rc.local
is a script that runs whichever commands we put in it.
– Christopher
May 16 '17 at 13:25
add a comment |
Take a look at /etc/rc.d/rc.local
. The file states, "Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure that this script will be executed during boot." So...
chmod +x /etc/rc.d/rc.local
Then place your commands above the last line, touch /var/lock/subsys/local
.
There is better way using relevant configuration files. Rules and routes can be specified using corresponding file names. All the relevant configuration files are given below. (The device names may differ.)
/etc/iproute2/rt_tables
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-eth1
/etc/sysconfig/network-scripts/route-eth0
/etc/sysconfig/network-scripts/route-eth1
/etc/sysconfig/network-scripts/rule-eth0
/etc/sysconfig/network-scripts/rule-eth1
To create a named routing table, use /etc/iproute2/rt_tables
. I added 128 mynet
.
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
128 mynet
The EL 7.x /etc/sysconfig/network
file. The default route is GATEWAY
.
NETWORKING=yes
HOSTNAME=hostname.sld.tld
GATEWAY=10.10.10.1
THE EL 7.x /etc/sysconfig/network-scripts/ifcfg-eth0
file, without "HWADDR" and "UUID". This configures a static IP address for eth0
without using NetworkManager.
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTOCOL=none
IPADDR=10.10.10.140
NETMASK=255.255.255.0
NETWORK=10.10.10.0
BROADCAST=10.10.10.255
THE EL 7.x /etc/sysconfig/network-scripts/ifcfg-eth1
file, without "HWADDR" and "UUID". This configures a static IP address for eth1
without using NetworkManager.
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTOCOL=none
IPADDR=192.168.100.140
NETMASK=255.255.255.0
NETWORK=192.168.100.0
BROADCAST=192.168.100.255
The EL 7.x /etc/sysconfig/network-scripts/route-eth1
file. The default route was already specified in /etc/sysconfig/network
.
192.168.100.0/24 dev eth1 table mynet
default via 192.168.100.1 dev eth1 table mynet
The EL 7.x /etc/sysconfig/network-scripts/rule-eth1
file:
from 192.168.100.0/24 lookup mynet
Take a look at /etc/rc.d/rc.local
. The file states, "Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure that this script will be executed during boot." So...
chmod +x /etc/rc.d/rc.local
Then place your commands above the last line, touch /var/lock/subsys/local
.
There is better way using relevant configuration files. Rules and routes can be specified using corresponding file names. All the relevant configuration files are given below. (The device names may differ.)
/etc/iproute2/rt_tables
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-eth1
/etc/sysconfig/network-scripts/route-eth0
/etc/sysconfig/network-scripts/route-eth1
/etc/sysconfig/network-scripts/rule-eth0
/etc/sysconfig/network-scripts/rule-eth1
To create a named routing table, use /etc/iproute2/rt_tables
. I added 128 mynet
.
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
128 mynet
The EL 7.x /etc/sysconfig/network
file. The default route is GATEWAY
.
NETWORKING=yes
HOSTNAME=hostname.sld.tld
GATEWAY=10.10.10.1
THE EL 7.x /etc/sysconfig/network-scripts/ifcfg-eth0
file, without "HWADDR" and "UUID". This configures a static IP address for eth0
without using NetworkManager.
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTOCOL=none
IPADDR=10.10.10.140
NETMASK=255.255.255.0
NETWORK=10.10.10.0
BROADCAST=10.10.10.255
THE EL 7.x /etc/sysconfig/network-scripts/ifcfg-eth1
file, without "HWADDR" and "UUID". This configures a static IP address for eth1
without using NetworkManager.
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTOCOL=none
IPADDR=192.168.100.140
NETMASK=255.255.255.0
NETWORK=192.168.100.0
BROADCAST=192.168.100.255
The EL 7.x /etc/sysconfig/network-scripts/route-eth1
file. The default route was already specified in /etc/sysconfig/network
.
192.168.100.0/24 dev eth1 table mynet
default via 192.168.100.1 dev eth1 table mynet
The EL 7.x /etc/sysconfig/network-scripts/rule-eth1
file:
from 192.168.100.0/24 lookup mynet
answered May 16 '17 at 13:08
ChristopherChristopher
10.8k33249
10.8k33249
in case if i gonna use the first option only are it's gonna save ip rule and ip route command even if server rebooted? and if yes, shall i insert the 3 commands as it is?
– αԋɱҽԃ αмєяιcαη
May 16 '17 at 13:16
It should, yes./etc/rc.d/rc.local
is a script that runs whichever commands we put in it.
– Christopher
May 16 '17 at 13:25
add a comment |
in case if i gonna use the first option only are it's gonna save ip rule and ip route command even if server rebooted? and if yes, shall i insert the 3 commands as it is?
– αԋɱҽԃ αмєяιcαη
May 16 '17 at 13:16
It should, yes./etc/rc.d/rc.local
is a script that runs whichever commands we put in it.
– Christopher
May 16 '17 at 13:25
in case if i gonna use the first option only are it's gonna save ip rule and ip route command even if server rebooted? and if yes, shall i insert the 3 commands as it is?
– αԋɱҽԃ αмєяιcαη
May 16 '17 at 13:16
in case if i gonna use the first option only are it's gonna save ip rule and ip route command even if server rebooted? and if yes, shall i insert the 3 commands as it is?
– αԋɱҽԃ αмєяιcαη
May 16 '17 at 13:16
It should, yes.
/etc/rc.d/rc.local
is a script that runs whichever commands we put in it.– Christopher
May 16 '17 at 13:25
It should, yes.
/etc/rc.d/rc.local
is a script that runs whichever commands we put in it.– Christopher
May 16 '17 at 13:25
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f365380%2fhow-to-persist-ip-rule-and-route-whenever-server-rebooted%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/…
– Rui F Ribeiro
May 16 '17 at 13:54
RHEL7 Networking Guide: Configuring Static Routes in ifcfg files
– sebasth
Sep 21 '17 at 20:05