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










share|improve this question




























    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










    share|improve this question


























      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










      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.4k33585




      32.4k33585










      asked May 8 at 20:27









      Valerio Pregnolato

      112




      112






















          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.






          share|improve this answer




























            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.






            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',
              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








              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.






              share|improve this answer

























                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.






                share|improve this answer























                  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.






                  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
























                      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.






                      share|improve this answer

























                        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.






                        share|improve this answer























                          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.






                          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

                          316




                          316






























                              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







                              Popular posts from this blog

                              數位音樂下載

                              When can things happen in Etherscan, such as the picture below?

                              格利澤436b