LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 10-20-2008, 11:19 PM   #1
noir911
Member
 
Registered: Apr 2004
Location: Baltimore, MD
Posts: 681

Rep: Reputation: Disabled
virtual interface routing


I have added a virtual interface (on opensuse 10.3) like ifconfig eth0:0 172.16.25.25 netmask 255.255.255.0

I was wondering how to setup the routing table so I can ping this IP from another box.

my eth0 is 192.168.25.66 with default gateway 192.168.25.254. My 172.16.20.25 has a default gateway of 172.16.25.254.

I have noticed that my virtual interface has the same MAC address as my physical interface. I am assuming that's normal.

Here's my routing table

Code:
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.25.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
172.16.25.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0
127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo
0.0.0.0         192.168.25.254   0.0.0.0         UG    0      0        0 eth0
 
Old 10-20-2008, 11:24 PM   #2
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,240

Rep: Reputation: 121Reputation: 121
I believe that eth0:0 is the same as just plain old eth0. I believe what you want is eth0:1 for your new virtual address. I don't think this requires a change to the routing table to get pinged. It would require a new route to connect out to a subnet, though.
 
Old 10-20-2008, 11:44 PM   #3
noir911
Member
 
Registered: Apr 2004
Location: Baltimore, MD
Posts: 681

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Quakeboy02 View Post
I believe that eth0:0 is the same as just plain old eth0. I believe what you want is eth0:1 for your new virtual address. I don't think this requires a change to the routing table to get pinged. It would require a new route to connect out to a subnet, though.
Thanks for your help.

I did a "ifconfig eth0:0 down" and ifconfig eth0:1 172.16.25.25 netmask 255.255.255.0

but seems like I still cannot ping that IP from outside.
 
Old 10-20-2008, 11:51 PM   #4
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,240

Rep: Reputation: 121Reputation: 121
From the man page for ifconfig, it looks like you must have an "up" eth0 (or eth0:0) before you can have an "up" eth0:1. I've never actually done this, so...
 
Old 10-21-2008, 12:06 AM   #5
noir911
Member
 
Registered: Apr 2004
Location: Baltimore, MD
Posts: 681

Original Poster
Rep: Reputation: Disabled
Ok, I have read the ifcfg-vlan man page and have setup /etc/sysconfig/network/ifcfg-vlan3:

STARTMODE=onboot
ETHERDEVICE=eth0
IPADDR=172.16.25.25/24

Now when I restart the network (service network restart) I can see vlan3. But still cannot ping or ssh to that IP address.
 
Old 10-21-2008, 12:13 AM   #6
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,240

Rep: Reputation: 121Reputation: 121
I'm sorry, I don't understand what you did. You have a working eth0, right? And you want to add an eth0:1? You should be able to do this with "ifconfig eth0:1 xxxxxxxx" where xxxxxxxx is the rest of it. But, according to the manual, if you take eth0 (aka eth0:0) down, then the rest go down, as well.
 
Old 10-21-2008, 12:25 AM   #7
noir911
Member
 
Registered: Apr 2004
Location: Baltimore, MD
Posts: 681

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Quakeboy02 View Post
I'm sorry, I don't understand what you did. You have a working eth0, right? And you want to add an eth0:1? You should be able to do this with "ifconfig eth0:1 xxxxxxxx" where xxxxxxxx is the rest of it. But, according to the manual, if you take eth0 (aka eth0:0) down, then the rest go down, as well.
All I'm trying to do is add an additional IP address to the server: be it a virtual IP address or vlan. Since ifconfig voodoo was not working, I read the ifcfg-vlan manpage that comes with OpenSUSE 10.3 and started the vlan with IP 172.16.25.25. I can now ssh to this IP from the server itself. But cannot from another server; so I'm guessing there is a routing issue.

Yes, I have a working eth0 and yes I tried "ifconfig eth0:1 xxxxxxxx" without luck. Also, when I do "ifconfig eth0:0 down" or "ifconfig eth0:1 down", it does not bring down the eth0 interface.

Last edited by noir911; 10-21-2008 at 12:26 AM.
 
Old 10-21-2008, 12:37 AM   #8
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 69
Quote:
Originally Posted by noir911 View Post
Ok, I have read the ifcfg-vlan man page and have setup /etc/sysconfig/network/ifcfg-vlan3:

STARTMODE=onboot
ETHERDEVICE=eth0
IPADDR=172.16.25.25/24

Now when I restart the network (service network restart) I can see vlan3. But still cannot ping or ssh to that IP address.
Huh? That's not how to create a VLAN interface on any Linux OSs that I'm familiar with. How are you verifying that it's a VLAN device? Why do you think you need a VLAN interface any way?
 
Old 10-21-2008, 12:40 AM   #9
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,240

Rep: Reputation: 121Reputation: 121
What exactly is the reply to the following?
Code:
ifconfig eth0:1 172.16.25.25
I have an eth1, and when I run the following:
Code:
ifconfig eth1:1 192.168.3.5
I get this when I then run ifconfig.
Code:
eth1:1    Link encap:Ethernet  HWaddr 00:26:54:0b:8f:4b  
          inet addr:192.168.3.5  Bcast:192.168.3.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          Interrupt:11 Base address:0xa000
I don't understand why it's not coming up on your end, unless you do not have eth0 up.
 
Old 10-21-2008, 12:36 PM   #10
BrianSnook
LQ Newbie
 
Registered: Jan 2008
Location: Atlanta, GA
Distribution: FreeBSD, RH9, RHEL5, CentOS5
Posts: 3

Rep: Reputation: 1
you need to add the route to the _other_ server

Quote:
Originally Posted by noir911 View Post
I have added a virtual interface (on opensuse 10.3) like ifconfig eth0:0 172.16.25.25 netmask 255.255.255.0

I was wondering how to setup the routing table so I can ping this IP from another box.

my eth0 is 192.168.25.66 with default gateway 192.168.25.254. My 172.16.20.25 has a default gateway of 172.16.25.254.

I have noticed that my virtual interface has the same MAC address as my physical interface. I am assuming that's normal.

Here's my routing table

Code:
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.25.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
172.16.25.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0
127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo
0.0.0.0         192.168.25.254   0.0.0.0         UG    0      0        0 eth0
As long as the two servers can communicate with each other normally on their primary interfaces, adding the route to get traffic to box1's alias/secondary interface is straightforward.

The issue is that you're trying to set up routing on box1 to tell box2 how to get to box1. Unless you're running gated on box1 to announce routes and have a router listening to those routes and announcing them to be picked up by a routing protocol on box2, you won't be able to do what you need from box1. What you need to do is tell box2 to use box1's eth0 interface as the gateway to get to box1's eth0:0 (or eth0:1 or whatever you want to name it -- it doesn't matter) interface.

I'm assuming that the two servers share a network in common (besides the 172 that you want to set up), so their primary interfaces (eth0) can talk to each other. If so, this is straightforward. On box2, you'd need to do this as root:

route add 172.16.25.25 gw 192.168.25.66

That is, you're adding a new route on box2 to get to 172.16.25.25 via the gateway of 192.168.25.66 (which it should already be able to reach).

Here's an illustration using two systems I have:

guildenstern# ifconfig eth0 | grep inet\ a
inet addr:10.30.38.168 Bcast:10.30.38.255 Mask:255.255.255.0
guildenstern# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
10.30.38.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 10.30.38.1 0.0.0.0 UG 0 0 0 eth0
guildenstern# ifconfig eth0:0 172.16.25.25 netmask 255.255.255.0
guildenstern# ifconfig eth0:0
eth0:0 Link encap:Ethernet HWaddr 00:0D:567:97:C5
inet addr:172.16.25.25 Bcast:172.16.25.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Base address:0xdf40 Memory:fcfe0000-fd000000

guildenstern# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
10.30.38.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
172.16.25.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 10.30.38.1 0.0.0.0 UG 0 0 0 eth0
guildenstern#

rosencrantz# ifconfig eth0 | grep inet\ a
inet addr:10.30.38.165 Bcast:10.30.38.255 Mask:255.255.255.0
rosencrantz# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
10.30.38.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 10.30.38.1 0.0.0.0 UG 0 0 0 eth0

rosencrantz# ping -qc 100 172.16.25.25
PING 172.16.25.25 (172.16.25.25) 56(84) bytes of data.

--- 172.16.25.25 ping statistics ---
100 packets transmitted, 0 received, 100% packet loss, time 99015ms

rosencrantz#
rosencrantz# route add 172.16.25.25 gw 10.30.38.168
rosencrantz# ping 172.16.25.25
PING 172.16.25.25 (172.16.25.25) 56(84) bytes of data.
64 bytes from 172.16.25.25: icmp_seq=1 ttl=64 time=0.385 ms
64 bytes from 172.16.25.25: icmp_seq=2 ttl=64 time=0.357 ms
64 bytes from 172.16.25.25: icmp_seq=3 ttl=64 time=0.297 ms
^C
rosencrantz# ping -qc 100 172.16.25.25
PING 172.16.25.25 (172.16.25.25) 56(84) bytes of data.

--- 172.16.25.25 ping statistics ---
100 packets transmitted, 100 received, 0% packet loss, time 99000ms
rtt min/avg/max/mdev = 0.271/0.394/0.530/0.078 ms
rosencrantz#
rosencrantz# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
172.16.25.25 10.30.38.168 255.255.255.255 UGH 0 0 0 eth0
10.30.38.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 10.30.38.1 0.0.0.0 UG 0 0 0 eth0
rosencrantz#

Note that this just lets you reach box1's eth0:0 interface and doesn't have anything directly to do with forwarding packets to the other network, so if you need to do something else with the packets once they reach box1's eth0:0, you'll need to do that in a firewall/nat (packet forwarding) config.
 
Old 10-21-2008, 07:59 PM   #11
noir911
Member
 
Registered: Apr 2004
Location: Baltimore, MD
Posts: 681

Original Poster
Rep: Reputation: Disabled
The main issue is with the internal routing table on the Linux box. The default route for eth0 (192.168.25.25) is 192.168.25.254. But the default route for eth0:1 (172.16.25.25) is 172.16.25.254. The server is physically connected to the switch port 192.168.25.x.

So, if I try to ping eth0:1 (172.16.25.25) from another computer in the network, it looks at the actual physical switch port for 172.16.25.25. The switch port doesn't know its existence since it is on another subnet.

I guess that's what happening.

here's the routing table:

Code:
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.16.25.25  172.16.25.254   255.255.255.255 UGH   0      0        0 eth0
192.168.25.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
172.16.20.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0
127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo
0.0.0.0         192.168.25.254   0.0.0.0         UG    0      0        0 eth0
ifconfig eth0 | grep inet

Code:
inet addr: 192.168.25.25  Bcast: 192.168.25.255 Mask:255.255.255.0
ifconfig eth0:1 | grep inet

Code:
inet addr: 172.16.25.25 Bcast: 172.16.25.255 Mask:255.255.255.0

Last edited by noir911; 10-21-2008 at 08:04 PM.
 
Old 10-22-2008, 06:11 PM   #12
noir911
Member
 
Registered: Apr 2004
Location: Baltimore, MD
Posts: 681

Original Poster
Rep: Reputation: Disabled
I have resolved this issue by having two IP address (for the two interface) from the same subnet.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create routing between virtual interface in linux attojung Linux - Networking 2 03-13-2009 01:06 PM
why lo interface is not in routing table? montyleesam Linux - Networking 1 06-10-2008 01:06 AM
Adding virtual interface for IP based virtual host pridefc Linux - General 6 03-16-2008 03:52 PM
routing traffic from one interface to another a550ee Linux - Networking 0 07-08-2007 03:28 PM
Routing between 2 Interface Cards ajkannan83 Linux - Networking 1 03-06-2006 07:04 AM


All times are GMT -5. The time now is 12:30 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration