Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linux: system wide static /etc/network/routes #71

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

imgtec
Copy link

@imgtec imgtec commented Aug 9, 2017

please refer to:

https://askubuntu.com/questions/168033/how-to-set-static-routes-in-ubuntu-server

There is a package ifupdown-extra avaible in Ubuntu.
It provides automatic scripts (installed in /etc/network/*/), one of which is used to add static routes.

The configuration file for this is /etc/network/routes

The top of this config file has a good description:

This configuration file is read by the static-routes if-updown script and the /etc/init.d/networking-routes script to setup a list of routes associated either with a given interface or global routes.
An example route I use is:

192.168.240.0 255.255.255.0 192.168.130.3 em3

How to use, in case your default gateway interface is 'enp0s29f7u2c4i2'

$ python chnroutes.py -p routes
$ sed -i 's/Interface/enp0s29f7u2c4i2/g' routes
$
$ # if you didn't have ifupdown-extra installed
$ sudo apt-get install ifupdown-extra
$
$ sudo cat routes >>/etc/network/routes

this is a very draft commit, I don't know have any experience with
python. if any thing goes into issues, please help...

the routes will automatic added when the interface brings up, and also
removed when the interface is down or removed (usb hotspot or usb network
adapter).

the poster writen the nic as 'em3', I guess this maybe also works under
pfsense or *BSD gateways, never know.

Signed-off-by: Du Huanpeng u74147@gmail.com

Du Huanpeng added 2 commits August 9, 2017 10:50
please refer to:

https://askubuntu.com/questions/168033/how-to-set-static-routes-in-ubuntu-server
-----
There is a package ifupdown-extra avaible in Ubuntu.
It provides automatic scripts (installed in /etc/network/*/), one of which is used to add static routes.

The configuration file for this is  /etc/network/routes

The top of this config file has a good description:

This configuration file is read by the static-routes if-updown script and the /etc/init.d/networking-routes script to setup a list of routes associated either with a given interface or global routes.
An example route I use is:

192.168.240.0 255.255.255.0 192.168.130.3 em3
-----

How to use, in case your default gateway interface is 'enp0s29f7u2c4i2'

 $ python chnroutes.py -p routes
 $ sed -i 's/___Interface___/enp0s29f7u2c4i2/g' routes
 $
 $ # if you didn't have ifupdown-extra installed
 $ sudo apt-get install ifupdown-extra
 $
 $ sudo cat routes >>/etc/network/routes

this is a very draft commit, I don't know have any experience with
python. if any thing goes into issues, please help...

the routes will automatic added when the interface brings up, and also
removed when the interface is down or removed (usb hotspot or usb network
adapter).

the poster writen the nic as 'em3', I guess this maybe also works under
pfsense or *BSD gateways, never know.

Signed-off-by: Du Huanpeng <u74147@gmail.com>
Signed-off-by: Du Huanpeng <u74147@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant