Ubuntu 18.04 Network card with two IP addresses

Multi tool use
Multi tool use












1














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










share|improve this question





























    1














    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










    share|improve this question



























      1












      1








      1







      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










      share|improve this question















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 8 at 20:34









      dobey

      32.5k33586




      32.5k33586










      asked May 8 at 20:27









      Valerio Pregnolato

      612




      612






















          2 Answers
          2






          active

          oldest

          votes


















          2














          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.






          share|improve this answer





























            0














            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.






            share|improve this answer





















              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "89"
              };
              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: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              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
              });


              }
              });














              draft saved

              draft discarded


















              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

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              2














              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.






              share|improve this answer


























                2














                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.






                share|improve this answer
























                  2












                  2








                  2






                  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.






                  share|improve this answer












                  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.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered May 10 at 20:24









                  Mathieu Trudel-Lapierre

                  2,0521131




                  2,0521131

























                      0














                      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.






                      share|improve this answer


























                        0














                        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.






                        share|improve this answer
























                          0












                          0








                          0






                          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.






                          share|improve this answer












                          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.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 29 at 12:04









                          Holger Morgen

                          567




                          567






























                              draft saved

                              draft discarded




















































                              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.




                              draft saved


                              draft discarded














                              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





















































                              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







                              H0hIV,UsrgfewMFRnv7NopzxPKUK tDjD,JM7Zy2qxEuCXxbv AbLjyH0
                              jVPqNnC4yRshlTqMW1mzonteVVw

                              Popular posts from this blog

                              mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

                              How to change which sound is reproduced for terminal bell?

                              Can I use Tabulator js library in my java Spring + Thymeleaf project?