Linux How to setup multi homing network

Following tip is submitted by Raj.

Sample Scenario

If you have 2 NIC (network Lan card) each connected to different networks:
=> eth0:
=> eth1:

Consider above setup. Now if you want to route traffic to connected network only (eth0 and eth1) w/o setting Linux server as a router. This is generally called multi homing setup. You don’t have to setup Linux box as a router to use multi homing :). Just assign as IP address to each NIC and you are done.

How do I configure Linux multi homing?

Just assign each interface IP address using ifconfig or use DHCP and multi homing will be turned on:
# ifconfig eth0 up
# ifconfig eth1 up

Commonly, most admin confuse the idea of multi-homing with the concept of routing or IP forwarding. Once two IP address assigned your system follows the default. No special configuration needed. Your multi-homing is up and running :).

Additional routing

You can turn on additional routing feature, with multi-homing. Just enable forwarding:
# echo 1 > /proc/sys/net/ipv4/ip_forwarding

If you reboot system you will lost additional routing setup. Add following line to your /etc/sysctl.conf file:
# vi /etc/sysctl.conf Add following line:net.ipv4.ip_forward = 1
Save and type command:# sysctl -p

But, what is the difference between routing and multi homing setup?

=> Multi homing route traffic to each connected network but no frames are forwarded between two networks.
=> Routing forward frames between two networks. See these (setup Linux as a router for DSL, T1 line etc) previous articles (setup vmware host router) on how to setup Linux as a router.

Updated for accuracy by nixCraft.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 14 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
14 comments… add one
  • Sean Nov 8, 2006 @ 13:17

    This one has me lost. First it says that it’s not necessary to route in order to multihome, then it turns on ip_forwarding which will turn the device into a router.

    You can’t turn off routing. Every device routes — even a windows box has a routing table. Every time you send a packet the device has to decide whether to send it to a device on the local host, or choose a better route via a default router or something more specific.

    If all you want to do is have a Linux box sit on two networks, then light up two NICs and turn OFF ip_forwarding. Look at the routing table, you’ll see two network entries for the two NICs plus any default routes.

    Maybe this is just a language thing, but anything sitting on two networks, regardless of forwarding status, is multihomed. I think this is more properly called a “multi-homed bastion host” in firewall terminology.


  • 🐧 nixCraft Nov 8, 2006 @ 14:01


    >Maybe this is just a language thing, but anything sitting on two networks, regardless of forwarding status, is multihomed

    Agreed and it is default no need to turn on ip forwarding. After multi homing you can turn on additional routing with net.ipv4.ip_forward = 1.

    In short it shows how to setup multi-homing networking by simply assigning an IP address and nothing special. I have updated post and title also.

    Sorry for mixing up things. Next time before posting user submitted tips/how to; I will verify information.

    Appreciate your post.

  • Aneesh Nov 24, 2006 @ 23:28

    >=> Multi homing route traffic to each connected >network but no frames are forwarded between two >networks.
    >=> Routing forward frames between two networks. See >these (setup Linux as a router for DSL, T1 line >etc) previous articles (setup vmware host router) >on how to setup Linux as a router.

    Sorry, I can’t understand the defferences between the two. Can anyaone clarify please

  • 🐧 nixCraft Nov 25, 2006 @ 8:44


    Multi homing does not enables Linux act as a router.

    If you need to Linux act as router just follow the link.

  • Sanjay Jun 7, 2007 @ 5:44

    Hi I have 2 NIC on linux box. Surprisingly I found that though having two different networks it is doing routing. How to solve this problem? Can anybody help me on this?

  • vipin Oct 11, 2007 @ 13:44

    how can i make linux as router .I have install xorp and zebra.but unable to perform multihoming .can u pls help me for the same ?

    Reply soon,

  • George Mar 1, 2008 @ 1:41

    What do you guys think about this. I have a webserver that has 2 nic cards. I can connect to it throught the one nic, but the second nic is connected to another linux box with MySQL installed. I’m trying to connect to the MySQL database. How can I connect to it through the web server?

  • Schemie44 Mar 25, 2009 @ 17:58

    Hi all

    I also need to route between two networks. The first is 172.20.2(LAN) range the other is 192.168.1(ADSL). I need to come in from 192 which is setup with dyndns name ip’s going through to 172 ip.

    What will be the easiest.

  • jameswatson3 Apr 1, 2009 @ 19:54

    I have a very specific multihoming need, but I’m not sure if it will be met by default.

    I have one sql database on network 1
    I have 3 application servers multihomed on networks 1 and 2

    Clients will access the application servers via dns records that will point to their addresses on network 2.

    The Application servers and DB will communicate on network 1.

    Will this happen by itself through standard tcp operations? Or will the traffic to the DB on network 1 travel out of the application server interface on network 2?

  • Andreas Mar 3, 2010 @ 13:48

    By default, most server applications will bind to ANY address, which means it can be reached via any of the network interfaces (lo, eth0, eth1)

    If this is not what you want, check each application for config settings like “bind” or “listen”. If the application does not support this, you can also use iptables to limit access to the application.

  • Shaheer May 16, 2011 @ 5:41

    I have a web site with ubuntu linux 10.10
    my web sites is very slow
    I want to increase response time of my web site specially my videos

    should i use routing or multi homed?

  • Vishal Shinde Jun 9, 2014 @ 12:44

    Can we assign 3 different ip Ranges in single Network Interface (eth0) ?

  • Ian Allen Dec 26, 2015 @ 20:12

    This won’t work for incoming traffic from both networks. As you have it, one of the two networks will be the default route for all outgoing traffic, and so packets arriving from the other network will try to return via the first (and fail). You need Linux “ip rule” statements to give different default routes depending on the source address of the packet.

  • Hugo May 19, 2016 @ 14:46

    Please correct the title or the text in this article.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum