Question on assigning ip addresses to multiple nics on Linux router
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Question on assigning ip addresses to multiple nics on Linux router
I'm using VirutalBox to host three Lubuntu machines which have static ip addresses (class c) and I want to have another Lubuntu machine server as a router and another Lubuntu machine provide DNS/DHCP services.
My question is on the router, since it has two nics, can the gateway address also be one of the addresses for eth1?
Code:
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.111
netmask 255.255.255.0
gateway 192.168.1.110
auto eth1
iface eth0 inet static
address 192.168.1.110
netmask 255.255.255.0
gateway 192.168.1.110
You have two NICs with IP addresses in the same IP network (192.168.1.0/24). That in itself is uncommon, but not necessarily wrong. If you're trying to set up a router, then it most certainly is wrong, because routing implies different IP networks.
Then you have two gateways on the same system, which is pointless, and both refer to the machine itself, which makes absolutely no sense at all.
Exactly what are you trying to accomplish? Is this system to act like a router between two network segments (physical or virtual)?
What I'm trying to learn right now is setting up a small network on Linux machines in VirutalBox. Along with one of the machines serving as a router, and then set up another one as a DHCP/DNS Server.
I didn't know that on the router, that we need to have different ip addresses for the two NICS. Now that I know this, that make total sense. Thanks for pointing that out.
NICs on VirtualBox VMs can be configured in four different ways:
Internal network: A virtual switch with no connection to the outside world.
Host network: Much the same as an "internal" network, except the VirtualBox hypervisor has a virtual NIC in each host network.
Bridged: The VM NIC is bridged to one of the NICs on the hypervisor host.
NAT: The VM NICs are placed in a special, virtual network with a virtual router. This router has DNS and DHCP functionality (the default IP network is 192.168.56.0/24), and will NAT outbound traffic behind the IP address of the hypervisor host.
Your router will need one NIC in an "internal" zone and one which is either bridged to a NIC on the hypervisor host or put in the "NAT" zone. The VMs that are to be served by this router should have their NICs in the same "internal" zone.
The IP network in the "internal" zone will have to be different from all your other networks. Any private IP network you're not already using will do fine.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.