Ubuntu 18.04 Network card with two IP addresses
up vote
0
down vote
favorite
I would like to learn how to setup my network card with two IP addresses
I tried as bellow, but now
network:
version: 2
renderer: NetworkManager
ethernets:
enp0s3:
dhcp4: no
dhcp6: no
addresses: [ 192.168.0.2/32, 172.16.0.2/16 ]
gateway4: 192.168.0.1
gateway4: 172.16.0.1
nameservers:
search: [usp.br]
addresses: [ 192.168.0.100, 192.168.0.102 ]
optional: true
Each IP has its own gateway....
Could you please help me how to it?
Thank you
netplan
add a comment |
up vote
0
down vote
favorite
I would like to learn how to setup my network card with two IP addresses
I tried as bellow, but now
network:
version: 2
renderer: NetworkManager
ethernets:
enp0s3:
dhcp4: no
dhcp6: no
addresses: [ 192.168.0.2/32, 172.16.0.2/16 ]
gateway4: 192.168.0.1
gateway4: 172.16.0.1
nameservers:
search: [usp.br]
addresses: [ 192.168.0.100, 192.168.0.102 ]
optional: true
Each IP has its own gateway....
Could you please help me how to it?
Thank you
netplan
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I would like to learn how to setup my network card with two IP addresses
I tried as bellow, but now
network:
version: 2
renderer: NetworkManager
ethernets:
enp0s3:
dhcp4: no
dhcp6: no
addresses: [ 192.168.0.2/32, 172.16.0.2/16 ]
gateway4: 192.168.0.1
gateway4: 172.16.0.1
nameservers:
search: [usp.br]
addresses: [ 192.168.0.100, 192.168.0.102 ]
optional: true
Each IP has its own gateway....
Could you please help me how to it?
Thank you
netplan
I would like to learn how to setup my network card with two IP addresses
I tried as bellow, but now
network:
version: 2
renderer: NetworkManager
ethernets:
enp0s3:
dhcp4: no
dhcp6: no
addresses: [ 192.168.0.2/32, 172.16.0.2/16 ]
gateway4: 192.168.0.1
gateway4: 172.16.0.1
nameservers:
search: [usp.br]
addresses: [ 192.168.0.100, 192.168.0.102 ]
optional: true
Each IP has its own gateway....
Could you please help me how to it?
Thank you
netplan
netplan
edited May 8 at 20:34
dobey
32.4k33585
32.4k33585
asked May 8 at 20:27
Valerio Pregnolato
112
112
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
2
down vote
There are often issues with having multiple gateways set for interfaces. Routing packets over to one and then the other may lead to confusion on the network, so you're often best served by having a single default gateway unless you really know what you are doing.
In short, you usually want only one
gateway4: xx.xx.xx.xx
line in your config.
If you must have multiple routes for the individual IPs of the interface, you can control exactly how they will behave by writing static routes (and setting the metric based on the priority of the addresses), like so:
network:
version: 2
renderer: NetworkManager
ethernets:
enp0s3:
dhcp4: no
dhcp6: no
addresses: [ 192.168.0.2/32, 172.16.0.2/16 ]
nameservers:
search: [usp.br]
addresses: [ 192.168.0.100, 192.168.0.102 ]
routes:
- to: 0.0.0.0/0
via: 192.168.0.1
- to: 0.0.0.0/0
via: 172.168.0.1
You also don't need optional: true: it only stops delaying boot if the interface isn't coming up fast enough, which shouldn't be an issue given that you specific static addresses. Adding optional: true also has the side effect of not blocking for some targets in systemd, which might mean a server will not start all the services it should right away if these services need the network.
add a comment |
up vote
0
down vote
A bit late, but...
It makes little sense to have 2 default gateways. Think about it:
If i do ping 8.8.8.8, what gateway should it use?
You CAN setup priority, if one line is slower/more expensive/only for backup/...
If both have same priority, I suspect it will try to do round-robbin.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
There are often issues with having multiple gateways set for interfaces. Routing packets over to one and then the other may lead to confusion on the network, so you're often best served by having a single default gateway unless you really know what you are doing.
In short, you usually want only one
gateway4: xx.xx.xx.xx
line in your config.
If you must have multiple routes for the individual IPs of the interface, you can control exactly how they will behave by writing static routes (and setting the metric based on the priority of the addresses), like so:
network:
version: 2
renderer: NetworkManager
ethernets:
enp0s3:
dhcp4: no
dhcp6: no
addresses: [ 192.168.0.2/32, 172.16.0.2/16 ]
nameservers:
search: [usp.br]
addresses: [ 192.168.0.100, 192.168.0.102 ]
routes:
- to: 0.0.0.0/0
via: 192.168.0.1
- to: 0.0.0.0/0
via: 172.168.0.1
You also don't need optional: true: it only stops delaying boot if the interface isn't coming up fast enough, which shouldn't be an issue given that you specific static addresses. Adding optional: true also has the side effect of not blocking for some targets in systemd, which might mean a server will not start all the services it should right away if these services need the network.
add a comment |
up vote
2
down vote
There are often issues with having multiple gateways set for interfaces. Routing packets over to one and then the other may lead to confusion on the network, so you're often best served by having a single default gateway unless you really know what you are doing.
In short, you usually want only one
gateway4: xx.xx.xx.xx
line in your config.
If you must have multiple routes for the individual IPs of the interface, you can control exactly how they will behave by writing static routes (and setting the metric based on the priority of the addresses), like so:
network:
version: 2
renderer: NetworkManager
ethernets:
enp0s3:
dhcp4: no
dhcp6: no
addresses: [ 192.168.0.2/32, 172.16.0.2/16 ]
nameservers:
search: [usp.br]
addresses: [ 192.168.0.100, 192.168.0.102 ]
routes:
- to: 0.0.0.0/0
via: 192.168.0.1
- to: 0.0.0.0/0
via: 172.168.0.1
You also don't need optional: true: it only stops delaying boot if the interface isn't coming up fast enough, which shouldn't be an issue given that you specific static addresses. Adding optional: true also has the side effect of not blocking for some targets in systemd, which might mean a server will not start all the services it should right away if these services need the network.
add a comment |
up vote
2
down vote
up vote
2
down vote
There are often issues with having multiple gateways set for interfaces. Routing packets over to one and then the other may lead to confusion on the network, so you're often best served by having a single default gateway unless you really know what you are doing.
In short, you usually want only one
gateway4: xx.xx.xx.xx
line in your config.
If you must have multiple routes for the individual IPs of the interface, you can control exactly how they will behave by writing static routes (and setting the metric based on the priority of the addresses), like so:
network:
version: 2
renderer: NetworkManager
ethernets:
enp0s3:
dhcp4: no
dhcp6: no
addresses: [ 192.168.0.2/32, 172.16.0.2/16 ]
nameservers:
search: [usp.br]
addresses: [ 192.168.0.100, 192.168.0.102 ]
routes:
- to: 0.0.0.0/0
via: 192.168.0.1
- to: 0.0.0.0/0
via: 172.168.0.1
You also don't need optional: true: it only stops delaying boot if the interface isn't coming up fast enough, which shouldn't be an issue given that you specific static addresses. Adding optional: true also has the side effect of not blocking for some targets in systemd, which might mean a server will not start all the services it should right away if these services need the network.
There are often issues with having multiple gateways set for interfaces. Routing packets over to one and then the other may lead to confusion on the network, so you're often best served by having a single default gateway unless you really know what you are doing.
In short, you usually want only one
gateway4: xx.xx.xx.xx
line in your config.
If you must have multiple routes for the individual IPs of the interface, you can control exactly how they will behave by writing static routes (and setting the metric based on the priority of the addresses), like so:
network:
version: 2
renderer: NetworkManager
ethernets:
enp0s3:
dhcp4: no
dhcp6: no
addresses: [ 192.168.0.2/32, 172.16.0.2/16 ]
nameservers:
search: [usp.br]
addresses: [ 192.168.0.100, 192.168.0.102 ]
routes:
- to: 0.0.0.0/0
via: 192.168.0.1
- to: 0.0.0.0/0
via: 172.168.0.1
You also don't need optional: true: it only stops delaying boot if the interface isn't coming up fast enough, which shouldn't be an issue given that you specific static addresses. Adding optional: true also has the side effect of not blocking for some targets in systemd, which might mean a server will not start all the services it should right away if these services need the network.
answered May 10 at 20:24
Mathieu Trudel-Lapierre
2,0521131
2,0521131
add a comment |
add a comment |
up vote
0
down vote
A bit late, but...
It makes little sense to have 2 default gateways. Think about it:
If i do ping 8.8.8.8, what gateway should it use?
You CAN setup priority, if one line is slower/more expensive/only for backup/...
If both have same priority, I suspect it will try to do round-robbin.
add a comment |
up vote
0
down vote
A bit late, but...
It makes little sense to have 2 default gateways. Think about it:
If i do ping 8.8.8.8, what gateway should it use?
You CAN setup priority, if one line is slower/more expensive/only for backup/...
If both have same priority, I suspect it will try to do round-robbin.
add a comment |
up vote
0
down vote
up vote
0
down vote
A bit late, but...
It makes little sense to have 2 default gateways. Think about it:
If i do ping 8.8.8.8, what gateway should it use?
You CAN setup priority, if one line is slower/more expensive/only for backup/...
If both have same priority, I suspect it will try to do round-robbin.
A bit late, but...
It makes little sense to have 2 default gateways. Think about it:
If i do ping 8.8.8.8, what gateway should it use?
You CAN setup priority, if one line is slower/more expensive/only for backup/...
If both have same priority, I suspect it will try to do round-robbin.
answered Nov 29 at 12:04
Holger Morgen
316
316
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- 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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2faskubuntu.com%2fquestions%2f1033747%2fubuntu-18-04-network-card-with-two-ip-addresses%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