How to create post-up and pre-down routes in interfaces file?
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
0
down vote
favorite
I recently installed a new VM using Ubuntu 16.04, but I am unable to copy the post-up
and pre-down
rules that I use in my 14.04 install.
Can you please advise what to use? I've added a few notes to indicate what each of my edited out ips are
Example of the 14.04 config:
# The primary network interface
auto eth0
iface eth0 inet static
address x.x.x.109 #vm ip
netmask 255.255.255.255
broadcast x.x.x.109 #vm ip
post-up route add x.x.x.254 dev eth0 #root machine gateway
post-up route add default gw x.x.x.254 #root machine gateway
pre-down route del x.x.x.254 dev eth0 #root machine gateway
pre-down route del default gw x.x.x.254 #root machine gateway
dns-nameservers 213.186.33.99 8.8.8.8
networking server routing
add a comment |Â
up vote
0
down vote
favorite
I recently installed a new VM using Ubuntu 16.04, but I am unable to copy the post-up
and pre-down
rules that I use in my 14.04 install.
Can you please advise what to use? I've added a few notes to indicate what each of my edited out ips are
Example of the 14.04 config:
# The primary network interface
auto eth0
iface eth0 inet static
address x.x.x.109 #vm ip
netmask 255.255.255.255
broadcast x.x.x.109 #vm ip
post-up route add x.x.x.254 dev eth0 #root machine gateway
post-up route add default gw x.x.x.254 #root machine gateway
pre-down route del x.x.x.254 dev eth0 #root machine gateway
pre-down route del default gw x.x.x.254 #root machine gateway
dns-nameservers 213.186.33.99 8.8.8.8
networking server routing
Sorry, but can anyone help?
â Biff
May 3 at 8:58
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I recently installed a new VM using Ubuntu 16.04, but I am unable to copy the post-up
and pre-down
rules that I use in my 14.04 install.
Can you please advise what to use? I've added a few notes to indicate what each of my edited out ips are
Example of the 14.04 config:
# The primary network interface
auto eth0
iface eth0 inet static
address x.x.x.109 #vm ip
netmask 255.255.255.255
broadcast x.x.x.109 #vm ip
post-up route add x.x.x.254 dev eth0 #root machine gateway
post-up route add default gw x.x.x.254 #root machine gateway
pre-down route del x.x.x.254 dev eth0 #root machine gateway
pre-down route del default gw x.x.x.254 #root machine gateway
dns-nameservers 213.186.33.99 8.8.8.8
networking server routing
I recently installed a new VM using Ubuntu 16.04, but I am unable to copy the post-up
and pre-down
rules that I use in my 14.04 install.
Can you please advise what to use? I've added a few notes to indicate what each of my edited out ips are
Example of the 14.04 config:
# The primary network interface
auto eth0
iface eth0 inet static
address x.x.x.109 #vm ip
netmask 255.255.255.255
broadcast x.x.x.109 #vm ip
post-up route add x.x.x.254 dev eth0 #root machine gateway
post-up route add default gw x.x.x.254 #root machine gateway
pre-down route del x.x.x.254 dev eth0 #root machine gateway
pre-down route del default gw x.x.x.254 #root machine gateway
dns-nameservers 213.186.33.99 8.8.8.8
networking server routing
edited Apr 30 at 10:15
asked Apr 30 at 10:02
Biff
11
11
Sorry, but can anyone help?
â Biff
May 3 at 8:58
add a comment |Â
Sorry, but can anyone help?
â Biff
May 3 at 8:58
Sorry, but can anyone help?
â Biff
May 3 at 8:58
Sorry, but can anyone help?
â Biff
May 3 at 8:58
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
Try with up
and down
instead of post-up
and pre-down
.
Example :
auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
up route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.1
Or, but I didn't test it, you can write a bash script and put it in the folder /etc/network/if-up.d/
and /etc/network/if-down.d/
(you can use the variable $IFACE to know which interface is getting a connection).
In /etc/network/if-up.d/some-script
:
#!/bin/bash
if [[ $IFACE == "eth0" ]]; then
ip route add x.x.x.0/24 via x.x.x.254 dev $IFACE
fi
Hope this help.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Try with up
and down
instead of post-up
and pre-down
.
Example :
auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
up route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.1
Or, but I didn't test it, you can write a bash script and put it in the folder /etc/network/if-up.d/
and /etc/network/if-down.d/
(you can use the variable $IFACE to know which interface is getting a connection).
In /etc/network/if-up.d/some-script
:
#!/bin/bash
if [[ $IFACE == "eth0" ]]; then
ip route add x.x.x.0/24 via x.x.x.254 dev $IFACE
fi
Hope this help.
add a comment |Â
up vote
0
down vote
Try with up
and down
instead of post-up
and pre-down
.
Example :
auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
up route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.1
Or, but I didn't test it, you can write a bash script and put it in the folder /etc/network/if-up.d/
and /etc/network/if-down.d/
(you can use the variable $IFACE to know which interface is getting a connection).
In /etc/network/if-up.d/some-script
:
#!/bin/bash
if [[ $IFACE == "eth0" ]]; then
ip route add x.x.x.0/24 via x.x.x.254 dev $IFACE
fi
Hope this help.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Try with up
and down
instead of post-up
and pre-down
.
Example :
auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
up route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.1
Or, but I didn't test it, you can write a bash script and put it in the folder /etc/network/if-up.d/
and /etc/network/if-down.d/
(you can use the variable $IFACE to know which interface is getting a connection).
In /etc/network/if-up.d/some-script
:
#!/bin/bash
if [[ $IFACE == "eth0" ]]; then
ip route add x.x.x.0/24 via x.x.x.254 dev $IFACE
fi
Hope this help.
Try with up
and down
instead of post-up
and pre-down
.
Example :
auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
up route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.1
Or, but I didn't test it, you can write a bash script and put it in the folder /etc/network/if-up.d/
and /etc/network/if-down.d/
(you can use the variable $IFACE to know which interface is getting a connection).
In /etc/network/if-up.d/some-script
:
#!/bin/bash
if [[ $IFACE == "eth0" ]]; then
ip route add x.x.x.0/24 via x.x.x.254 dev $IFACE
fi
Hope this help.
edited May 7 at 12:25
answered May 7 at 11:10
Eraseth
1299
1299
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1030048%2fhow-to-create-post-up-and-pre-down-routes-in-interfaces-file%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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
Sorry, but can anyone help?
â Biff
May 3 at 8:58