Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting virtual ips on a single network card

Status
Not open for further replies.

Helmsley

Programmer
Dec 17, 2001
18
0
0
SG
Hi,

I have a question regarding virtual ips. I'm running Linux enterprise version and I need to set up 2 different virtual ips on my server, which has a ethernet card with 4 ports (eth0-eth3).

To make it clearer, my server has an ip address of 10.10.10.15. The 2 virtual ips that i need has to be of different subnets from the server ip. Which means I need a virtual ip like 10.20.30.40 and 50.60.70.80, or something like that. Is it possible to do it? I know its possible to create virtual ips of the same subnet on 1 port, but for different subnets, i am not sure.

Would appreciate any help on this issue. Thanks
 
Yes, I think it's possible, if a little odd. Just configure eth0:1 and eth0:2 with those IP addresses.

Annihilannic.
 
i tried setting it, but it does not seem to work, as in i cannot ping the virtual ips that are of a different subnet as the actual ip of the server.

I looked into the ifcfg-eth0 file in /etc/sysconfig/network-scripts and created another file called ifcfg-eth0:0 with almost the same content, except changing the field IPADDRR to the virtual ip i wanted.

My question is : if the virtual ip i wanted to create is of the different subnet, what values should i input into the fields NETWORK, SUBNET and GATEWAY of my new ifcfg-eth0:0 file?

Thanks
 
It probably worked but you need to be able to forward packets to the additional subnets/addresses on your box

Try

echo 1 > /proc/sys/net/ipv4/ip_forward

to enable forwarding.

Then on a different box, set routes to the networks of the virtual interfaces. Set the gateway to the ip on the same subnet you have access to. Ping to test.

As for the values, they depend on what you want to accomplish.

Lorenzo Wacondo (System Administrator)

## Just because you can do something doesn't mean you should.
 
You should use eth0:1, not eth0:0.

The network, subnet and gateway information for those subnets should be provided by your network guys. If you are the network guy... I'd strongly recommend sticking to just the one subnet.

Annihilannic.
 

I haven't used a multi-port ethernet card but if it works as you say with eth0-eth3 then they can each be assigned an ip address. You do not need to use virtual ip addressing also called ip aliasing. As long as linux sees those ports as four different interfaces, you can use the server as a bridge to your subnets.
 
Hi, thanks for the response. But i'm still not sure how to resolve the problem.

i can create 2 virtual ips of the same subnet (for eg, 10.10.10.20 and 10.10.10.21) and the server is pingable, but i can't create 2 ips like 10.20.30.40 and 10.30.40.50, which is of different subnets. I'm supposed to set up the network and its driving me crazy as in what did i do wrong or what are the exact steps to take? Please advice
 
Do you have anything else on that 10.30.40 network? Unless you enable routing or forwarding of some kind you will only be able to ping those IPs from another system on the same subnet. Why are you creating separate subnets anyway?

Annihilannic.
 
Since you are still talking about virtual ip addressing for your NIC, I will assume that it is a hub and not a bridge. In this case you will need to setup linux to act as a router/bridge. You should be able to do this with iptables.
 
Hi, how do enable routing or forwarding then? thanks
 
Hi, I've tried his suggestion, but it still cannot ping my virtual ip. however, i can ping my virtual ip from the server itself. i just cannot ping it from my other pcs connecting to the server.
 

Helmsley, sorry but it sounds like networking isn't really your field?! Are there no network people in your company? Who has given you this task?

Anyway, there's nothing complicated about what you're doing and what you have setup probably works fine. As long as the network you connect it to knows about these new networks there shouldn't be a problem. You don't need to enable forwarding unless you're doing something weird.

If you want to make these addresses available on a network where they don't belong it's getting a bit weird. Is that what you want?

The gateway will be an address set on the router connected to that network in the same subnet as the addresses you are setting up. Can you ping the gateway address?
 
Hi, i've kinda solved the virtual ip issues. That means i can now configure eth0 to be an ip like 10.10.10.35 and my virtual ip of a different subnet 10.20.30.40 on eth0:1.

However, I have another problem now. I need to configure my eth1 to be of a different subnet as eth0. That means since my eth0 is 10.10.10.35, I need eth1 to be like 130.20.10.6 (an example). I understand this is not a simple issue of ip-aliasing, but a multihoming issue. How do i go abt doing it?

I tried modifying the file ifcfg-eth1 in /etc/sysconfig/network-scripts. I set my desired ip isndie the file. How abt the subnet, network, broadcast and gateway fields? Will these fields be similar to that of eth0?

Sorry to bother u guys with so many questions and thanks for any help in advance!
 
If its your network *you* should be deciding what the netmask, broadcast and gateway are based on the design of your network. If the IP address was provided by a third party, such as an ISP, they should give you the correct details.

Annihilannic.
 
hi, i understand. What i am asking is that shd the netmask, broadcast and gateway settings of eth1 (ip: 130.20.10.6) be the same as that of eth0 (10.10.10.35)? This is because i can ping eth0 and not eth1. Thanks
 
No, they are specific to the network it is connecting to, not necessarily the same for all interfaces on a server.

Annihilannic.
 
Even though both IPs are on the same physical interface, if they are masked so they are in different subnets you will only be able to talk to the interfaces from other IP addresses that are on the same subnet.

For example:

Address 1 = 1.1.1.1
Address 2 = 1.1.2.1

If your subnet mask is 255.255.255.0, then they are on different subnets and won't be able to talk to each other without a router. If your subnet mask is 255.255.0.0 then they are on the same subnet and may talk. If the subnet mask for 1 is 255.255.0.0 and the subnet mask for 2 is 255.0.0.0, then your network administrator is an idiot, but you will still be able to talk to one from the other.

If you have machine a on the same subnet as your 130.20.10.6 interface and you try to ping the 10.10.10.35 it will probably fail because it isn't on the 10 network, so it will send those packets to it's default gateway. If you tell it that the gateway to the 10 network is 130.20.10.6, then it will send the packets to that address and your machine should respond.

Does that help clear things up?

If not, then need to explain what you're trying to accomplish so we can better help you. You sound like you don't really know what you're doing and don't have the support of a network administrator.
 
hi all, thanks for the advice. eric, what i am trying to accomplish is to enable my machine to talk to clients from 2 different networks, hence the need for the eth0 and eth1 to be of different subnets. eth0 needs to connect to network 1 of subnet 10.10.10 and eth1 to subnet 130.20.10.

my problem now is that when i use another pc with ip on the 10.10.10 network and ping my machine, it works. However when i set my pc to a 130.10.20 network and ping the same machine, it fails. does that mean my eth1 is not working?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top