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.
Hello
Well today i had a hard time getting some of the base concept
The case is on one of our servers which host openvz vms i asked datacenter to give us extra ip
the ip they gave us was on diffrent subnet and had diffrent gateway than the main server ip address
I set the ip on the vm and it worked but yet i have some hard time figure out how it actually works
how can an ip address with different gateway and subnet works on a server which its main ip address and gateway is diffrent ?
was not the extra ip supposed to be in same network and have the same gateway as main ip address ?
Also how does linux handle diffrent gateway for extra virtual interfaces ? there is actually one pyhsical network card which can be assgined one gateway as far as i know how adding extra ips to the box is handled ?
though in our case the extra ip is added to openvz vps which makes it harder for me to understand what really happens
You can have any number of logical IP networks share the same physical (layer 2) network. It's not exactly common practice, but there's nothing intrinsically wrong with it either.
Gateways are handled per host. In your case, you have an OpenVZ host in a different subnet from that of the main physical server. That's not fundamentally different from having the two in the same subnet: In both cases, both hosts need an IP address and a gateway. They are, after all, two completely separate systems with separate network configurations. The virtual NIC on the OpenVZ host just happens to be using the NIC of the physical host to send and receive data.
The only somewhat unusual aspect of this setup is that you have two subnets sharing the same layer 2 link.
Thank you Ser
But something still bugging me
lets go one step further
Possibly the server is connected to a switch along with some other servers that are connected to the switch
And eventually this switch is connected to one of the datacenter routers
as far as i know about networking this should be normall setup
But here my problem Each port of router can have one subnet assigned to it and this port of router will have one ip address which will be used as gateway for all machine behind this router right ?
ALso by the means the routers work router advertise the network it has via (eigrp,ospf,etc)so it can actually advertise one network for each of its connected port
So how this router can route two diffrent subnet at the same time from a single port (the port that our switch is connected )
If it helps our datacenter is hetzner and they use juniper tech instead of cisco
But here my problem Each port of router can have one subnet assigned to it and this port of router will have one ip address which will be used as gateway for all machine behind this router right ?
No, it is possible to assign several IP addresses to a router interface, which is probably what the hosting company has done here.
A router may act as a gateway for several different networks, and in this case, at least two of those networks share the same Ethernet link.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.