Can some one please share steps on how to add default gateway address route permanently to the route table on Ubuntu 16.04 LTS on Azure for the secondary nic?

As you know Azure DHCP only populate the default gateway address for the primary nic.

so basically, in my route table I want to have eth0 --> default gateway address pointing to the subnet gateway address (xx.1) that it is attached to (this is all fine since it's handled by the azure because it's a primary nic) and for the secondary nic i.e. eth1 --> i have to add a manual default gateway address for the subnet that this nic is attached. hoping this is clear and makes sense

Here is the document that I'm referring that provides the background.


Appreciate any help.



ip route add ???.16.5.0/24 via ??.0.0.101 dev eth?

You MUST make sure that the IP address is the start of the CIDR address range you have been allocated, otherwise it will fail.


will help you find the CIDR start, of you only have one IP address and mask to go by.

  • thanks @birdwes. I know the default gateway address (it's the first address that Azure reserved from the subnet. I'm looking for instructions for ubuntu distro running in Azure. Afaik, centos is a different distro. – csaif7 Oct 12 '18 at 22:19
  • Sorry if this is obvious, but you cannot have multiple default gw. You specicify the extra ones by subnet xx.xx.xx.xx/yy . – birdwes Oct 12 '18 at 22:48
  • no need to be sorry. I understand but things are little different in the azure. If you look at the article I sent to you, it discuss this and here is the output that I like to do; Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface UG 0 0 0 eth0 UG 0 0 0 eth1 U 0 0 0 eth0 U 0 0 0 eth1 – csaif7 Oct 12 '18 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.