FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 01-24-2011, 02:15 PM
Amar Cosic
 
Default Adding more than one static IP

Hello list
My mind is just "locked" at the moment and I am trying to figure out what am I doing wrong here. I have 4 static IP's on server machine and I have something like this in /etc/conf.d/net :



config_eth0=( "77.xxx.104.14/24" )routes_eth0=( "default via 77.xxx.104.1" )config_eth0:1=( "77.xxx.104.100/24" )routes_eth0:1=( "default via 77.xxx.104.1" )
config_eth0:2=( "77.xxx.104.101/24" )routes_eth0:2=( "default via 77.xxx.104.1" )config_eth0:3=( "77.xxx.105.100/24" )routes_eth0:3=( "default via 77.xxx.105.1" )


eth0 works just fine while other ones fail. Could you help me with this one ?

ty.
--Amar Ćosić
amar.cosic@gmail.com
 
Old 01-24-2011, 02:28 PM
Alan McKinnon
 
Default Adding more than one static IP

Apparently, though unproven, at 17:15 on Monday 24 January 2011, Amar Cosic
did opine thusly:

> Hello list
>
> My mind is just "locked" at the moment and I am trying to figure out what
> am I doing wrong here. I have 4 static IP's on server machine and I have
> something like this in /etc/conf.d/net :
>
>
>
> config_eth0=( "77.xxx.104.14/24" )
> routes_eth0=( "default via 77.xxx.104.1" )
> config_eth0:1=( "77.xxx.104.100/24" )
> routes_eth0:1=( "default via 77.xxx.104.1" )
> config_eth0:2=( "77.xxx.104.101/24" )
> routes_eth0:2=( "default via 77.xxx.104.1" )
> config_eth0:3=( "77.xxx.105.100/24" )
> routes_eth0:3=( "default via 77.xxx.105.1" )
>
>
> eth0 works just fine while other ones fail. Could you help me with this one

You have aliased three additional IPs to a NIC. You cannot add routes to those
aliases, only individual IP addresses.

You will either have to come up with a routing scheme that routes_eth0 fully
satisfies or pony up the cash for three NIC cards.

I'd go for option 2 - NICs are dirt cheap.


--
alan dot mckinnon at gmail dot com
 
Old 01-24-2011, 04:59 PM
Graham Murray
 
Default Adding more than one static IP

Amar Cosic <amar.cosic@gmail.com> writes:

> Hello list
>
> My mind is just "locked" at the moment and I am trying to figure out
> what am I doing wrong here. I have 4 static IP's on server machine
> and I have something like this in /etc/conf.d/net :
>
>
>
> config_eth0=( "77.xxx.104.14/24" )
> routes_eth0=( "default via 77.xxx.104.1" )
> config_eth0:1=( "77.xxx.104.100/24" )
> routes_eth0:1=( "default via 77.xxx.104.1" )
> config_eth0:2=( "77.xxx.104.101/24" )
> routes_eth0:2=( "default via 77.xxx.104.1" )
> config_eth0:3=( "77.xxx.105.100/24" )
> routes_eth0:3=( "default via 77.xxx.105.1" )
>
>
> eth0 works just fine while other ones fail. Could you help me with
> this one ?

Try emerging 'iproute2' (if not already installed) and then adding the
following line to /etc/iproute2/rt_tables
1 altlan


and then using the following in /etc/conf.d/net

modules-"iproute2"
config_eth0=( "77.xxx.104.14/24" "77.xxx.104.100/32" "77.xxx.104.101/32"
"77.xxx.105.100/24" )
routes_eth0=( "default via 77.xxx.104.1"
"default via 77.xxx.105.1 table altlan"
"77.xxx.105.0/24 table altlan" )
rules_eth0=( "from 77.xxx.105.100 table altlan" )

postup() {
# This function could be used, for example, to register with a
# dynamic DNS service. Another possibility would be to
# send/receive mail once the interface is brought up.
# Here is an example that allows the use of iproute rules
# which have been configured using the rules_eth0 variable.
#rules_eth0="
# 'from 24.80.102.112/32 to 192.168.1.0/24 table localnet priority 100'
# 'from 216.113.223.51/32 to 192.168.1.0/24 table localnet priority 100'
#"
eval set -- $
ules_${IFVAR}
if [ $# != 0 ]; then
einfo "Adding IP policy routing rules"
eindent
# Ensure that the kernel supports policy routing
if ! ip rule list | grep -q "^"; then
eerror "You need to enable IP Policy Routing (CONFIG_IP_MULTIPLE_TABLES)"
eerror "in your kernel to use ip rules"
else
for x; do
ebegin "${x}"
ip rule add ${x} dev "${IFACE}"
eend $?
done
fi
eoutdent
# Flush the cache
ip route flush cache dev "${IFACE}"
fi
}

postdown() {
# Automatically erase any ip rules created in the example postup above
if interface_exists "${IFACE}"; then
# Remove any rules for this interface
local rule
ip rule list | grep " iif ${IFACE}[ ]*" | {
while read rule; do
rule="${rule#*:}"
ip rule del ${rule}
done
}
# Flush the route cache
ip route flush cache dev "${IFACE}"
fi

# Return 0 always
return 0
}
 
Old 01-25-2011, 02:35 AM
"Walter Dnes"
 
Default Adding more than one static IP

On Mon, Jan 24, 2011 at 04:15:14PM +0100, Amar Cosic wrote
> Hello list
>
> My mind is just "locked" at the moment and I am trying to figure out what am
> I doing wrong here. I have 4 static IP's on server machine

I have one nic on my desktop. It sits behind an ADSL router-modem
which has address 192.168.123.254.

* My little LAN is 192.168.123.248/29. I want that to always go via the
router/modem, so I give that path metric 0

* I have an HDHomerun TV tuner that pops up in the 169.254.0.0/16 block.
That path also gets gets metric 0

* Default (i.e. to the internet) is metric 2 via the router

* Because the default is metric 2, dialup (temporary ppp0) can take over
internet access, without interfering with LAN traffic or my TV tuner.

Here's my /etc/conf.d.net

config_eth0=(
"192.168.123.249 broadcast 192.168.123.255 netmask 255.255.255.248 mtu 1454"
"169.254.1.3 broadcast 169.254.255.255 netmask 255.255.0.0")
routes_eth0=(
"default via 192.168.123.254 metric 2"
"192.168.123.248/29 via 192.168.123.254 metric 0"
"169.254.0.0/16 via 169.254.1.3 metric 0"
)

--
Walter Dnes <waltdnes@waltdnes.org>
 
Old 01-25-2011, 07:01 AM
Adam Carter
 
Default Adding more than one static IP

config_eth0=( "77.xxx.104.14/24" )routes_eth0=( "default via 77.xxx.104.1" )
config_eth0:1=( "77.xxx.104.100/24" )routes_eth0:1=( "default via 77.xxx.104.1" )
config_eth0:2=( "77.xxx.104.101/24" )routes_eth0:2=( "default via 77.xxx.104.1" )config_eth0:3=( "77.xxx.105.100/24" )routes_eth0:3=( "default via 77.xxx.105.1" )


You should let us know what you're trying to achieve with this. Every time I have seen config like this, it has been because of fundamental misunderstandings of networking. More that one IP address on a subnet (unless there are VIPs) = fail.


Remember routing occurs at layer 3, and for most configs should have no reference physical interface. The OS knows which interface the next hop can be found. In your config you've set the same route three times which makes no sense.


(ok i've oversimplified, but for 99.9% of cases the above is true)
 
Old 01-25-2011, 10:08 AM
Amar Cosic
 
Default Adding more than one static IP

On Tue, Jan 25, 2011 at 9:01 AM, Adam Carter <adamcarter3@gmail.com> wrote:


config_eth0=( "77.xxx.104.14/24" )
routes_eth0=( "default via 77.xxx.104.1" )
config_eth0:1=( "77.xxx.104.100/24" )routes_eth0:1=( "default via 77.xxx.104.1" )
config_eth0:2=( "77.xxx.104.101/24" )routes_eth0:2=( "default via 77.xxx.104.1" )config_eth0:3=( "77.xxx.105.100/24" )routes_eth0:3=( "default via 77.xxx.105.1" )



You should let us know what you're trying to achieve with this. Every time I have seen config like this, it has been because of fundamental misunderstandings of networking. More that one IP address on a subnet (unless there are VIPs) = fail.



Remember routing occurs at layer 3, and for most configs should have no reference physical interface. The OS knows which interface the next hop can be found. In your config you've set the same route three times which makes no sense.



(ok i've oversimplified, but for 99.9% of cases the above is true)


I have this on Debian in /etc/network/interfaces:
auto loiface lo inet loopbackauto eth0iface eth0 inet staticaddress 82.xxx.148.194
netmask 255.255.255.128gateway 82.xxx.148.131auto eth0:1iface eth0:1 inet staticaddress 82.xxx.148.195netmask 255.255.255.128auto eth0:2iface eth0:2 inet static
address 82.xxx.148.196netmask 255.255.255.128auto eth0:3iface eth0:3 inet staticaddress 82.xxx.148.197netmask 255.255.255.128*

What I want to know is what is*equivalent for this on Gentoo. *Let's just say this is VPS server with 4 IP's assigned to me as customer

--
Amar Ćosić
amar.cosic@gmail.com
 
Old 01-25-2011, 03:48 PM
Marius Vaitiekunas
 
Default Adding more than one static IP

On Tue, Jan 25, 2011 at 1:08 PM, Amar Cosic <amar.cosic@gmail.com> wrote:



On Tue, Jan 25, 2011 at 9:01 AM, Adam Carter <adamcarter3@gmail.com> wrote:



config_eth0=( "77.xxx.104.14/24" )
routes_eth0=( "default via 77.xxx.104.1" )
config_eth0:1=( "77.xxx.104.100/24" )routes_eth0:1=( "default via 77.xxx.104.1" )
config_eth0:2=( "77.xxx.104.101/24" )routes_eth0:2=( "default via 77.xxx.104.1" )config_eth0:3=( "77.xxx.105.100/24" )routes_eth0:3=( "default via 77.xxx.105.1" )




You should let us know what you're trying to achieve with this. Every time I have seen config like this, it has been because of fundamental misunderstandings of networking. More that one IP address on a subnet (unless there are VIPs) = fail.




Remember routing occurs at layer 3, and for most configs should have no reference physical interface. The OS knows which interface the next hop can be found. In your config you've set the same route three times which makes no sense.




(ok i've oversimplified, but for 99.9% of cases the above is true)


I have this on Debian in /etc/network/interfaces:
auto loiface lo inet loopbackauto eth0iface eth0 inet staticaddress 82.xxx.148.194

netmask 255.255.255.128gateway 82.xxx.148.131auto eth0:1iface eth0:1 inet staticaddress 82.xxx.148.195netmask 255.255.255.128auto eth0:2iface eth0:2 inet static

address 82.xxx.148.196netmask 255.255.255.128auto eth0:3iface eth0:3 inet staticaddress 82.xxx.148.197netmask 255.255.255.128*


What I want to know is what is*equivalent for this on Gentoo. *Let's just say this is VPS server with 4 IP's assigned to me as customer

--

Amar Ćosić
amar.cosic@gmail.com





Hi,



I am using like that in /etc/conf.d/net

-----

config_eth0=( "ip1 netmask 255.255.255.224"

************** "ip2 netmask 255.255.255.255"

************** "ip3 netmask 255.255.255.255"

)



routes_eth0=( "default via your_gw" )

-----


ifconfig doesn't show this info. I use ip command for that:



# ip addr
I hope it helps.
--
mv
 
Old 01-31-2011, 01:54 PM
Bill Longman
 
Default Adding more than one static IP

On Mon, Jan 24, 2011 at 7:15 AM, Amar Cosic <amar.cosic@gmail.com> wrote:

Hello list
My mind is just "locked" at the moment and I am trying to figure out what am I doing wrong here. I have 4 static IP's on server machine and I have something like this in /etc/conf.d/net :




config_eth0=( "77.xxx.104.14/24" )routes_eth0=( "default via 77.xxx.104.1" )config_eth0:1=( "77.xxx.104.100/24" )routes_eth0:1=( "default via 77.xxx.104.1" )

config_eth0:2=( "77.xxx.104.101/24" )routes_eth0:2=( "default via 77.xxx.104.1" )config_eth0:3=( "77.xxx.105.100/24" )routes_eth0:3=( "default via 77.xxx.105.1" )



eth0 works just fine while other ones fail. Could you help me with this one ?
Amar,

You should read up some more on how IP networking is configured and how it works. A default route is, by definition, the next hop on the local network to which packets are sent when no other local interface matches the intended target IP address. Your IP stack looks for local interfaces which match the target network for the target IP address. If it cannot find any, it has no other recourse but to forward it to someone who might know better. That's your default gateway router, and that's its job. If you tell your IP stack that you have four default gateways, it will get very confused. Get rid of all but one of those default route statements.


If, on the other hand, you just want your local machine to know the gateways for those networks, your route statements should be of this form:

routes_eth:2=("77.xxx.104.101/24 via 77.xxx.104.1")
 

Thread Tools




All times are GMT. The time now is 09:22 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org