How to set an additional route on the same gateway with systemd-networkd
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Due to some network peculiarities involving VPNs and conflicting IP ranges, I have two subnets routing to two different interfaces. I would like to make one IP address in one subnet go out via a different gateway.
I can accomplish this by running:
$ route add -host 1.2.3.4 gw 5.6.7.8
$ ip route show
1.2.3.4 via 5.6.7.8 dev eth0 scope link
I would like to make this change permanent. As I'm using systemd-networkd, I am trying to do this by updating the existing /etc/systemd/network/50-dhcp.conf
:
[Match]
Name=eth0
[Network]
DHCP=ipv4
[Route]
#Gateway=5.6.7.8
Destination=1.2.3.4/32
This works, but without the Gateway
line it doesn't set the route:
$ ip route show
1.2.3.4 dev eth0 proto static scope link
If I uncomment the Gateway
line then the new route does not appear at all!
How can I specify a gateway when adding the static route using systemd-networkd?
route systemd-networkd
add a comment |Â
up vote
0
down vote
favorite
Due to some network peculiarities involving VPNs and conflicting IP ranges, I have two subnets routing to two different interfaces. I would like to make one IP address in one subnet go out via a different gateway.
I can accomplish this by running:
$ route add -host 1.2.3.4 gw 5.6.7.8
$ ip route show
1.2.3.4 via 5.6.7.8 dev eth0 scope link
I would like to make this change permanent. As I'm using systemd-networkd, I am trying to do this by updating the existing /etc/systemd/network/50-dhcp.conf
:
[Match]
Name=eth0
[Network]
DHCP=ipv4
[Route]
#Gateway=5.6.7.8
Destination=1.2.3.4/32
This works, but without the Gateway
line it doesn't set the route:
$ ip route show
1.2.3.4 dev eth0 proto static scope link
If I uncomment the Gateway
line then the new route does not appear at all!
How can I specify a gateway when adding the static route using systemd-networkd?
route systemd-networkd
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Due to some network peculiarities involving VPNs and conflicting IP ranges, I have two subnets routing to two different interfaces. I would like to make one IP address in one subnet go out via a different gateway.
I can accomplish this by running:
$ route add -host 1.2.3.4 gw 5.6.7.8
$ ip route show
1.2.3.4 via 5.6.7.8 dev eth0 scope link
I would like to make this change permanent. As I'm using systemd-networkd, I am trying to do this by updating the existing /etc/systemd/network/50-dhcp.conf
:
[Match]
Name=eth0
[Network]
DHCP=ipv4
[Route]
#Gateway=5.6.7.8
Destination=1.2.3.4/32
This works, but without the Gateway
line it doesn't set the route:
$ ip route show
1.2.3.4 dev eth0 proto static scope link
If I uncomment the Gateway
line then the new route does not appear at all!
How can I specify a gateway when adding the static route using systemd-networkd?
route systemd-networkd
Due to some network peculiarities involving VPNs and conflicting IP ranges, I have two subnets routing to two different interfaces. I would like to make one IP address in one subnet go out via a different gateway.
I can accomplish this by running:
$ route add -host 1.2.3.4 gw 5.6.7.8
$ ip route show
1.2.3.4 via 5.6.7.8 dev eth0 scope link
I would like to make this change permanent. As I'm using systemd-networkd, I am trying to do this by updating the existing /etc/systemd/network/50-dhcp.conf
:
[Match]
Name=eth0
[Network]
DHCP=ipv4
[Route]
#Gateway=5.6.7.8
Destination=1.2.3.4/32
This works, but without the Gateway
line it doesn't set the route:
$ ip route show
1.2.3.4 dev eth0 proto static scope link
If I uncomment the Gateway
line then the new route does not appear at all!
How can I specify a gateway when adding the static route using systemd-networkd?
route systemd-networkd
route systemd-networkd
asked Aug 7 at 7:00
Malvineous
1,78511433
1,78511433
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
-1
down vote
You should look at this post:
What is the best way to add a permanent route?
It explains how you should:
Create a named routing table, in the case below the routing table is called "mgmt" and gets the number "200".
echo '200 mgmt' >> /etc/iproute2/rt_tables
Originally the /etc/iproute2/rt_tables file looks like this, with some reserved numbers:
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
The post goes on specifying how to add the routes:
Below, a Debian 7/8 interfaces file defines eth0 and eth1. eth1 is the 172 network. eth0 could use DHCP as well. 172.16.100.10 is the IP address to assign to eth1. 172.16.100.1 is the IP address of the router.
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The production network interface
auto eth0
allow-hotplug eth0
# iface eth0 inet dhcp
# Remove the stanzas below if using DHCP.
iface eth0 inet static
address 10.10.10.140
netmask 255.255.255.0
gateway 10.10.10.1
# The management network interface
auto eth1
allow-hotplug eth1
iface eth1 inet static
address 172.16.100.10
netmask 255.255.255.0
post-up ip route add 172.16.100.0/24 dev eth1 src 172.16.100.1 table mgmt
post-up ip route add default via 172.16.100.1 dev eth1 table mgmt
post-up ip rule add from 172.16.100.10/32 table mgmt
post-up ip rule add to 172.16.100.10/32 table mgmt
Reboot or restart networking.
Thanx to user Christopher for this answer.
Unfortunately this answer only applies to Debian, which I'm not using, so/etc/network
doesn't exist on my system. I am usingsystemd-networkd
instead of the Debian network manager, so I'm after a solution that works withsystemd
. Maybe you could update your answer with asystemd
solution instead of a Debian-only solution?
â Malvineous
Aug 9 at 1:08
Check out the link I posted in the answer.
â aliex
Aug 17 at 10:34
The link still only explains for Debian and RHEL, it does not mentionsystemd-networkd
at all!
â Malvineous
Aug 20 at 3:52
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
-1
down vote
You should look at this post:
What is the best way to add a permanent route?
It explains how you should:
Create a named routing table, in the case below the routing table is called "mgmt" and gets the number "200".
echo '200 mgmt' >> /etc/iproute2/rt_tables
Originally the /etc/iproute2/rt_tables file looks like this, with some reserved numbers:
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
The post goes on specifying how to add the routes:
Below, a Debian 7/8 interfaces file defines eth0 and eth1. eth1 is the 172 network. eth0 could use DHCP as well. 172.16.100.10 is the IP address to assign to eth1. 172.16.100.1 is the IP address of the router.
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The production network interface
auto eth0
allow-hotplug eth0
# iface eth0 inet dhcp
# Remove the stanzas below if using DHCP.
iface eth0 inet static
address 10.10.10.140
netmask 255.255.255.0
gateway 10.10.10.1
# The management network interface
auto eth1
allow-hotplug eth1
iface eth1 inet static
address 172.16.100.10
netmask 255.255.255.0
post-up ip route add 172.16.100.0/24 dev eth1 src 172.16.100.1 table mgmt
post-up ip route add default via 172.16.100.1 dev eth1 table mgmt
post-up ip rule add from 172.16.100.10/32 table mgmt
post-up ip rule add to 172.16.100.10/32 table mgmt
Reboot or restart networking.
Thanx to user Christopher for this answer.
Unfortunately this answer only applies to Debian, which I'm not using, so/etc/network
doesn't exist on my system. I am usingsystemd-networkd
instead of the Debian network manager, so I'm after a solution that works withsystemd
. Maybe you could update your answer with asystemd
solution instead of a Debian-only solution?
â Malvineous
Aug 9 at 1:08
Check out the link I posted in the answer.
â aliex
Aug 17 at 10:34
The link still only explains for Debian and RHEL, it does not mentionsystemd-networkd
at all!
â Malvineous
Aug 20 at 3:52
add a comment |Â
up vote
-1
down vote
You should look at this post:
What is the best way to add a permanent route?
It explains how you should:
Create a named routing table, in the case below the routing table is called "mgmt" and gets the number "200".
echo '200 mgmt' >> /etc/iproute2/rt_tables
Originally the /etc/iproute2/rt_tables file looks like this, with some reserved numbers:
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
The post goes on specifying how to add the routes:
Below, a Debian 7/8 interfaces file defines eth0 and eth1. eth1 is the 172 network. eth0 could use DHCP as well. 172.16.100.10 is the IP address to assign to eth1. 172.16.100.1 is the IP address of the router.
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The production network interface
auto eth0
allow-hotplug eth0
# iface eth0 inet dhcp
# Remove the stanzas below if using DHCP.
iface eth0 inet static
address 10.10.10.140
netmask 255.255.255.0
gateway 10.10.10.1
# The management network interface
auto eth1
allow-hotplug eth1
iface eth1 inet static
address 172.16.100.10
netmask 255.255.255.0
post-up ip route add 172.16.100.0/24 dev eth1 src 172.16.100.1 table mgmt
post-up ip route add default via 172.16.100.1 dev eth1 table mgmt
post-up ip rule add from 172.16.100.10/32 table mgmt
post-up ip rule add to 172.16.100.10/32 table mgmt
Reboot or restart networking.
Thanx to user Christopher for this answer.
Unfortunately this answer only applies to Debian, which I'm not using, so/etc/network
doesn't exist on my system. I am usingsystemd-networkd
instead of the Debian network manager, so I'm after a solution that works withsystemd
. Maybe you could update your answer with asystemd
solution instead of a Debian-only solution?
â Malvineous
Aug 9 at 1:08
Check out the link I posted in the answer.
â aliex
Aug 17 at 10:34
The link still only explains for Debian and RHEL, it does not mentionsystemd-networkd
at all!
â Malvineous
Aug 20 at 3:52
add a comment |Â
up vote
-1
down vote
up vote
-1
down vote
You should look at this post:
What is the best way to add a permanent route?
It explains how you should:
Create a named routing table, in the case below the routing table is called "mgmt" and gets the number "200".
echo '200 mgmt' >> /etc/iproute2/rt_tables
Originally the /etc/iproute2/rt_tables file looks like this, with some reserved numbers:
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
The post goes on specifying how to add the routes:
Below, a Debian 7/8 interfaces file defines eth0 and eth1. eth1 is the 172 network. eth0 could use DHCP as well. 172.16.100.10 is the IP address to assign to eth1. 172.16.100.1 is the IP address of the router.
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The production network interface
auto eth0
allow-hotplug eth0
# iface eth0 inet dhcp
# Remove the stanzas below if using DHCP.
iface eth0 inet static
address 10.10.10.140
netmask 255.255.255.0
gateway 10.10.10.1
# The management network interface
auto eth1
allow-hotplug eth1
iface eth1 inet static
address 172.16.100.10
netmask 255.255.255.0
post-up ip route add 172.16.100.0/24 dev eth1 src 172.16.100.1 table mgmt
post-up ip route add default via 172.16.100.1 dev eth1 table mgmt
post-up ip rule add from 172.16.100.10/32 table mgmt
post-up ip rule add to 172.16.100.10/32 table mgmt
Reboot or restart networking.
Thanx to user Christopher for this answer.
You should look at this post:
What is the best way to add a permanent route?
It explains how you should:
Create a named routing table, in the case below the routing table is called "mgmt" and gets the number "200".
echo '200 mgmt' >> /etc/iproute2/rt_tables
Originally the /etc/iproute2/rt_tables file looks like this, with some reserved numbers:
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
The post goes on specifying how to add the routes:
Below, a Debian 7/8 interfaces file defines eth0 and eth1. eth1 is the 172 network. eth0 could use DHCP as well. 172.16.100.10 is the IP address to assign to eth1. 172.16.100.1 is the IP address of the router.
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The production network interface
auto eth0
allow-hotplug eth0
# iface eth0 inet dhcp
# Remove the stanzas below if using DHCP.
iface eth0 inet static
address 10.10.10.140
netmask 255.255.255.0
gateway 10.10.10.1
# The management network interface
auto eth1
allow-hotplug eth1
iface eth1 inet static
address 172.16.100.10
netmask 255.255.255.0
post-up ip route add 172.16.100.0/24 dev eth1 src 172.16.100.1 table mgmt
post-up ip route add default via 172.16.100.1 dev eth1 table mgmt
post-up ip rule add from 172.16.100.10/32 table mgmt
post-up ip rule add to 172.16.100.10/32 table mgmt
Reboot or restart networking.
Thanx to user Christopher for this answer.
answered Aug 7 at 10:00
aliex
92
92
Unfortunately this answer only applies to Debian, which I'm not using, so/etc/network
doesn't exist on my system. I am usingsystemd-networkd
instead of the Debian network manager, so I'm after a solution that works withsystemd
. Maybe you could update your answer with asystemd
solution instead of a Debian-only solution?
â Malvineous
Aug 9 at 1:08
Check out the link I posted in the answer.
â aliex
Aug 17 at 10:34
The link still only explains for Debian and RHEL, it does not mentionsystemd-networkd
at all!
â Malvineous
Aug 20 at 3:52
add a comment |Â
Unfortunately this answer only applies to Debian, which I'm not using, so/etc/network
doesn't exist on my system. I am usingsystemd-networkd
instead of the Debian network manager, so I'm after a solution that works withsystemd
. Maybe you could update your answer with asystemd
solution instead of a Debian-only solution?
â Malvineous
Aug 9 at 1:08
Check out the link I posted in the answer.
â aliex
Aug 17 at 10:34
The link still only explains for Debian and RHEL, it does not mentionsystemd-networkd
at all!
â Malvineous
Aug 20 at 3:52
Unfortunately this answer only applies to Debian, which I'm not using, so
/etc/network
doesn't exist on my system. I am using systemd-networkd
instead of the Debian network manager, so I'm after a solution that works with systemd
. Maybe you could update your answer with a systemd
solution instead of a Debian-only solution?â Malvineous
Aug 9 at 1:08
Unfortunately this answer only applies to Debian, which I'm not using, so
/etc/network
doesn't exist on my system. I am using systemd-networkd
instead of the Debian network manager, so I'm after a solution that works with systemd
. Maybe you could update your answer with a systemd
solution instead of a Debian-only solution?â Malvineous
Aug 9 at 1:08
Check out the link I posted in the answer.
â aliex
Aug 17 at 10:34
Check out the link I posted in the answer.
â aliex
Aug 17 at 10:34
The link still only explains for Debian and RHEL, it does not mention
systemd-networkd
at all!â Malvineous
Aug 20 at 3:52
The link still only explains for Debian and RHEL, it does not mention
systemd-networkd
at all!â Malvineous
Aug 20 at 3:52
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f460978%2fhow-to-set-an-additional-route-on-the-same-gateway-with-systemd-networkd%23new-answer', 'question_page');
);
Post as a guest
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
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
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