View previous topic :: View next topic |
Author |
Message |
apasuper8 n00b
Joined: 04 Aug 2002 Posts: 9 Location: Charleston SC
|
Posted: Thu Aug 08, 2002 6:19 pm Post subject: Default Gateway |
|
|
When going through the installation proceedures for Gentoo I had to set up the default gateway by doing:
/sbin/ifconfig add -net default gw x.x.x.x netmask x.x.x.x metric 1
Everything communicated out to the internet just fine.
After finishing the installation ... Every time I reboot the box it looses it's gateway and I have to then drop to a terminal window and retype the line above to get it back up and running...
My question is:
Should I create a simple script file that has the above line in it and place it in the "/etc/init.d" directory and then do a "rc-update add" to that script file? Or is there a better/easier way to do this?
Thanks!
APASuper8 |
|
Back to top |
|
|
Kosmo n00b
Joined: 24 May 2002 Posts: 74
|
Posted: Thu Aug 08, 2002 6:26 pm Post subject: |
|
|
I believe there is an option in the file where you configure your network card. IIRC it is at the bottom of that file. I can't check this information, since my pc is broken, and i'm not allowed to put Gentoo (or any non-M$ os for that matter) on my mothers pc. |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20588
|
Posted: Thu Aug 08, 2002 6:30 pm Post subject: |
|
|
I'd set it in /etc/conf.d/net (think that is what Kosmo was referring to). _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
Kosmo n00b
Joined: 24 May 2002 Posts: 74
|
Posted: Thu Aug 08, 2002 6:35 pm Post subject: |
|
|
Yes it is, but it really is difficult to know where files are when you don't have the chance to check it. I'm getting a new pc in 2 weeks (that will do me good: from a celeron 500 to a athlon xp 2200+ ) and i already can't wait to see how long gentoo takes compiling. |
|
Back to top |
|
|
apasuper8 n00b
Joined: 04 Aug 2002 Posts: 9 Location: Charleston SC
|
Posted: Thu Aug 08, 2002 6:39 pm Post subject: |
|
|
So at the bottom of the /etc/conf.d/net file I should insert the following:
# For setting the default gateway
#
#gateway="eth0/x.x.x.x"
and that should solve my problem? |
|
Back to top |
|
|
Kosmo n00b
Joined: 24 May 2002 Posts: 74
|
Posted: Thu Aug 08, 2002 6:49 pm Post subject: |
|
|
Yes, just uncomment gateway=... and edit to your needs. |
|
Back to top |
|
|
cynninge n00b
Joined: 03 Jul 2002 Posts: 31
|
Posted: Thu Aug 08, 2002 8:39 pm Post subject: default gateway multiple interfaces |
|
|
how do you put multiple interfaces on the gateway line?
gateway="eth0/IP,eth1/IP...."
it isnt really covered in the manual |
|
Back to top |
|
|
rac Bodhisattva
Joined: 30 May 2002 Posts: 6553 Location: Japanifornia
|
Posted: Thu Aug 08, 2002 8:44 pm Post subject: Re: default gateway multiple interfaces |
|
|
cynninge wrote: | how do you put multiple interfaces on the gateway line? |
What is your network setup? I can see wanting iface_eth0 and iface_eth1 for multiple network cards, but a gateway is a default route that catches all packets that don't match other explicit routes, and you should only want one of those. _________________ For every higher wall, there is a taller ladder |
|
Back to top |
|
|
nE0 Tux's lil' helper
Joined: 08 Aug 2002 Posts: 146 Location: The Netherlands, Breda
|
Posted: Fri Aug 09, 2002 6:37 am Post subject: |
|
|
You will never need more then 1 default gateway.
That is the host to go to, if your system does noet know the correcte route.
What you could do, is create an own script that sets up your correct routing table is you are running gentoo on a router that routes to multiple interfaces.
for instance:
If your'e gentoo system is connected to 3 separate lans, and a internet connection, you could setup some own routes for this system. (besides the routes the system already knows.)
create a script that does these routes for you
make is depend on network
Code: |
#!/sbin/runscript
depend() {
need net
}
route add ......
|
rc-update add <your script> default
read the init manual: here
that could be an option. goodluck _________________ All things considerring! I'm considerring to...never mind! |
|
Back to top |
|
|
Lemma Guru
Joined: 19 Apr 2002 Posts: 416 Location: Uppsala, Sweden
|
Posted: Sun Jan 12, 2003 10:33 am Post subject: |
|
|
Hm, maby I am missing something here, but I in rc.conf you set a specific interface (like eth0, eth1...) to a specific gateway, right?
Code: | gateway="eth0/192.168.0.1" | or
Code: | gateway="eth1/192.168.0.1" | and I use both, eth0 at work and eth1 at home (eth1 is a wlan). How do I set a non NIC-specific gateway? I cant have both in rc.conf enabled, that does not work... _________________ Always make it as simple as possible, but no simpler
/Einstein |
|
Back to top |
|
|
Sven Vermeulen Retired Dev
Joined: 29 Aug 2002 Posts: 1345 Location: Mechelen, Belgium
|
Posted: Mon Jan 13, 2003 5:29 pm Post subject: |
|
|
Go to /etc/init.d/net.ethX and change
Code: |
/sbin/route add default gw ${gateway#*/} dev ${gateway%/*} \
|
to
Code: |
/sbin/route add default gw ${gateway} \
|
With this changed, you must now remove the "ethX/" in the gateway-definition.
Do remember that you have changed this file accordingly: when Portage (well, actually etc-update) asks you if you want to remove the "old" /etc/init.d/net.ethX and use the new one, this new one _won't_ have you changes in it anymore, so you'll have to add it manually again. |
|
Back to top |
|
|
steveb Advocate
Joined: 18 Sep 2002 Posts: 4564
|
Posted: Thu Apr 24, 2003 2:29 am Post subject: |
|
|
hello
I have the same problem and I just added gentoo bug report 19864 with a small change to the net.ethX script wich allows you to set up multiple gateways for diffrend interfaces.
cheers
SteveB |
|
Back to top |
|
|
EnricoHorn Apprentice
Joined: 23 Apr 2003 Posts: 165 Location: Koenigsee, Thuringia, Germany
|
Posted: Thu Apr 24, 2003 10:13 am Post subject: |
|
|
Hi,
I think you understand something wrong.
The gateway entry in /etc/conf.d/net is for setting the default route.
Since you cant have more then one default route, it makes no sense to have more than one gateway entry.
For instance you have a computer connected with three networks:
eth0 -> 192.168.1.2 broadcast 192.168.1.255 netmask 255.255.255.0
eth1 -> 192.168.2.2 broadcast 192.168.2.255 netmask 255.255.255.0
eth2 -> 192.168.3.2 broadcast 192.168.3.255 netmask 255.255.255.0
Furthermore:
gateway="eth0/192.168.1.3"
(assuming 192.168.1.3 is connected to the internet)
What does happen if the following packets arrive?
A Packet from 192.168.1.4 to 192.168.2.8 -> output to eth1 -> no gateway needed
A Packet from 192.168.2.5 to 192.168.3.17 -> output to eth2 -> no gateway needed
A Packet from 192.168.3.7 to 192.168.1.5 -> output to eth0 -> no gateway needed
A Packet from 192.168.2.7 to 193.99.144.71 (www.heise.de) -> now we need a default route -> output to eth0 with destination 192.168.1.3
Did you understand it?
Or are you totally confused now?
Yours,
Enrico. |
|
Back to top |
|
|
steveb Advocate
Joined: 18 Sep 2002 Posts: 4564
|
Posted: Thu Apr 24, 2003 1:39 pm Post subject: |
|
|
hallo enrico
yes, i am confused now!
EnricoHorn wrote: | A Packet from 192.168.1.4 to 192.168.2.8 -> output to eth1 -> no gateway needed
A Packet from 192.168.2.5 to 192.168.3.17 -> output to eth2 -> no gateway needed
A Packet from 192.168.3.7 to 192.168.1.5 -> output to eth0 -> no gateway needed
A Packet from 192.168.2.7 to 193.99.144.71 (www.heise.de) -> now we need a default route -> output to eth0 with destination 192.168.1.3 |
i understand all the output stuff, but how do you force that the packet is comming from the specific ip?
when you work on that computer, then normaly eth0 is the ip address used for sending packets.
anyway... my problem is, the following scenario:
eth0 -> 192.168.0.115 broadcast 192.168.0.255 netmask 255.255.255.0
eth1 -> 195.xxx.xxx.147 broadcast 195.xxx.xxx.147 netmask 255.255.255.248
outgoing internet traffic:
-> eth0 -> 192.168.0.115 -> 192.168.0.254 [NAT] -> isp
-> eth1 -> 195.xxx.xxx.147 -> 192.168.0.254 [NAT] -> isp
pinging heise.de: Code: | # ping -c 4 www.heise.de
PING www.heise.de (193.99.144.71): 56 octets data
64 octets from 193.99.144.71: icmp_seq=0 ttl=242 time=24.3 ms
64 octets from 193.99.144.71: icmp_seq=1 ttl=242 time=19.5 ms
64 octets from 193.99.144.71: icmp_seq=2 ttl=242 time=28.1 ms
64 octets from 193.99.144.71: icmp_seq=3 ttl=242 time=23.3 ms
--- www.heise.de ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 19.5/23.8/28.1 ms |
traceroute www.heise.de: Code: | # traceroute -n -w 2 www.heise.de
traceroute to www.heise.de (193.99.144.71), 30 hops max, 40 byte packets
1 192.168.0.254 1.899 ms 1.648 ms 1.603 ms
2 10.208.112.1 9.708 ms 11.596 ms 13.545 ms
3 62.2.9.9 13.893 ms 13.945 ms 13.816 ms
4 62.2.6.34 14.659 ms 14.077 ms 13.968 ms
5 208.175.232.197 13.784 ms 10.187 ms 11.278 ms
6 208.175.232.129 11.426 ms 12.862 ms 13.580 ms
7 166.63.195.185 16.249 ms 18.818 ms 17.556 ms
8 166.63.194.6 18.151 ms 16.867 ms 17.755 ms
9 208.175.236.14 21.191 ms 17.759 ms 18.712 ms
10 213.83.57.27 20.166 ms 17.759 ms 21.044 ms
11 213.83.19.83 18.522 ms 17.659 ms 21.684 ms
12 * * *
13 * * *
14 * * *
15 * * *
16 * * *
17 * * 193.99.144.71 16.662 ms |
okay... now a traceroute to www.heise.de over the eth1 interface: Code: | # route -n && traceroute -n -w 2 -i eth1 www.heise.de
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
195.xxx.xxx.144 0.0.0.0 255.255.255.248 U 0 0 0 eth1
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 192.168.0.254 0.0.0.0 UG 1 0 0 eth0
traceroute to www.heise.de (193.99.144.71), 30 hops max, 40 byte packets
1 * * *
2 * * *
3 * * *
4 * * *
5 * * *
6 * * *
7 * * *
8 * * *
9 * * *
10 * * *
11 * * *
12 * * *
13 * * *
14 * * *
15 * * *
16 * * *
17 * * *
18 * * *
19 * * *
20 * * *
21 * * *
22 * * *
23 * * *
24 * * *
25 * * *
26 * * *
27 * * *
28 * * *
29 * * *
30 * * * |
you see? it does not work! because this interface will try to go out over the internal c class network and this will not work! but when i add another entry to the routing table to act as a default gateway for eth1, then it works: Code: | # route add default gw 195.xxx.xxx.145 dev eth1 && route -n && traceroute -n -w 2 -i eth1 www.heise.de
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
195.xxx.xxx.144 0.0.0.0 255.255.255.248 U 0 0 0 eth1
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 195.xxx.xxx.145 0.0.0.0 UG 0 0 0 eth1
0.0.0.0 192.168.0.254 0.0.0.0 UG 1 0 0 eth0
traceroute to www.heise.de (193.99.144.71), 30 hops max, 40 byte packets
1 195.xxx.xxx.145 5.585 ms 1.041 ms 1.029 ms
2 195.xxx.xxx.104 4.927 ms 4.625 ms 4.717 ms
3 195.xxx.xxx.97 11.071 ms 10.717 ms 10.324 ms
4 195.xxx.xxx.137 13.455 ms 11.546 ms 11.921 ms
5 212.249.5.1 15.564 ms 13.908 ms 13.698 ms
6 146.188.0.221 14.519 ms 14.478 ms 38.243 ms
7 146.188.10.17 14.621 ms 14.802 ms 16.193 ms
8 146.188.3.29 14.581 ms 14.495 ms 14.044 ms
9 146.188.6.117 19.539 ms 21.165 ms 20.351 ms
10 146.188.6.110 19.529 ms 20.316 ms 19.544 ms
11 166.63.195.181 19.913 ms 19.955 ms 20.579 ms
12 166.63.194.6 20.875 ms 20.257 ms 20.550 ms
13 208.175.236.14 44.047 ms 21.867 ms 22.260 ms
14 213.83.57.27 22.965 ms 21.939 ms 20.909 ms
15 213.83.19.83 21.954 ms 23.269 ms 21.915 ms
16 * * *
17 * * 193.99.144.71 22.434 ms |
so please tell me now, how to solve that kind of problem, without adding another default gateway for that interface?
and i don't want to use subnet masks to mask the traffic to eth0 or eth1. because both interfaces have the right to go to the internet and both interfaces can reach any public internet server (the path is just diffrent! eth0 -> NAT gateway -> isp -> internet... eth1 -> SDSL Router -> isp -> internet...)
i could live with that, that i go on that computer over eth0 to the internet. but what is happening, when i get a public request from outside to open apache on that server?
browser --> [HTTP request] -> eth1 -> 195.xxx.xxx.147
and now my server would try to go that way back:
apache --> [HTTP response] -> eth0 -> NAT gateway -> ...
and this does not work! no way!
just for the fun... a attempt to connect to webmin from outside to the eth1 interface (eth1 has a public reachable tcp/ip address): Code: | # netstat -a | grep -i tcp
tcp 0 0 *:32768 *:* LISTEN
tcp 0 0 *:imaps *:* LISTEN
tcp 0 0 *:pop3s *:* LISTEN
tcp 0 0 *:mysql *:* LISTEN
tcp 0 0 *:pop-3 *:* LISTEN
tcp 0 0 *:imap2 *:* LISTEN
tcp 0 0 *:sunrpc *:* LISTEN
tcp 0 0 *:10000 *:* LISTEN
tcp 0 0 *:3632 *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 *:smtp *:* LISTEN
tcp 0 0 spok.vunet.local:33881 gentoo.vunet.local:3632 TIME_WAIT
tcp 0 0 spok.vunet.local:ssh work.vunet.local:3249 ESTABLISHED
tcp 0 48 spok.vunet.local:ssh work.vunet.local:3250 ESTABLISHED
tcp 0 0 spok.vunet.local:ssh work.vunet.local:3251 ESTABLISHED
tcp 0 0 xxxxxxxxxx-147.sp:10000 dclient217-162-14:62065 TIME_WAIT
tcp 0 1942 xxxxxxxxxx-147.sp:10000 dclient217-162-14:62067 FIN_WAIT1
tcp 0 0 xxxxxxxxxx-147.sp:10000 dclient217-162-14:62066 TIME_WAIT |
the package gets to the eth1 interface, but as soon it trys to send the package back it will use the default gateway of eth0 and this is not what i want! i want it to go back over eth1. and this leaves the requestor from outside the network to recieve a time-out on his browser....
maybe i confused you now?
gruss
SteveB |
|
Back to top |
|
|
STEDevil Apprentice
Joined: 24 Apr 2003 Posts: 156
|
Posted: Thu Apr 24, 2003 2:05 pm Post subject: |
|
|
EnricoHorn wrote: |
Did you understand it?
Or are you totally confused now?
|
I sure am confused.
Lets take my situation.
I have 2 NICs connecting to the internet through the SAME Gateway at my ISP.
With Gentoos current implementation
Code: |
ping -I eth0 Gateway
ping -I eth1 Gateway
|
will only work with 1 of the 2 NICs
However if I manually do
Code: |
/sbin/route add -net default gw GW netmask 0.0.0.0 metric 1 eth0
/sbin/route add -net default gw GW netmask 0.0.0.0 metric 1 eth1
|
then it works just fine.
Now please explain if you will, why does a n00b like me have to spend several hours trying to figure out "what is wrong with one of his NICs" when it's basicly an "error" in the startup script that you cannot bind the (same or different) GW to 2+ NICs.
To me (just having spent many hours trying to figure thisone out) it seems like a nobrainer to be able to set GW to more then 1 NIC in the startupscript.
The route app sure allows for just that, so any way you look at it it's just a bad implementation of the startup script as I see it. |
|
Back to top |
|
|
steveb Advocate
Joined: 18 Sep 2002 Posts: 4564
|
Posted: Thu Apr 24, 2003 2:46 pm Post subject: |
|
|
STEDevil wrote: | EnricoHorn wrote: |
Did you understand it?
Or are you totally confused now?
|
I sure am confused.
Lets take my situation.
I have 2 NICs connecting to the internet through the SAME Gateway at my ISP.
With Gentoos current implementation
Code: |
ping -I eth0 Gateway
ping -I eth1 Gateway
|
will only work with 1 of the 2 NICs
However if I manually do
Code: |
/sbin/route add -net default gw GW netmask 0.0.0.0 metric 1 eth0
/sbin/route add -net default gw GW netmask 0.0.0.0 metric 1 eth1
|
then it works just fine.
Now please explain if you will, why does a n00b like me have to spend several hours trying to figure out "what is wrong with one of his NICs" when it's basicly an "error" in the startup script that you cannot bind the (same or different) GW to 2+ NICs.
To me (just having spent many hours trying to figure thisone out) it seems like a nobrainer to be able to set GW to more then 1 NIC in the startupscript.
The route app sure allows for just that, so any way you look at it it's just a bad implementation of the startup script as I see it. |
2 nic's connected having the same gateway?
then just add to your /etc/conf.d/net the following
gateway="eth0/<gateway-address>"
and then just do: Code: | /etc/init.d/net.eth0 restart
/etc/init.d/net.eth1 restart |
btw: please post the output of:and the output of: Code: | grep -i ^gateway /etc/conf.d/net | and the output of: Code: | ifconfig eth0;ifconfig eth1 |
cheers
SteveB |
|
Back to top |
|
|
steveb Advocate
Joined: 18 Sep 2002 Posts: 4564
|
Posted: Thu Apr 24, 2003 2:54 pm Post subject: |
|
|
this is the complete /etc/init.d/net.ethX script I am now using: Code: | #!/sbin/runscript
# Copyright 1999-2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /home/cvsroot/gentoo-src/rc-scripts/init.d/net.eth0,v 1.23 2002/11/26 12:32:28 azarah Exp $
#NB: Config is in /etc/conf.d/net
# For pcmcia users. note that pcmcia must be added to the same
# runlevel as the net.* script that needs it.
depend() {
use pcmcia
}
checkconfig() {
if [ -z "$(eval echo \$\{iface_${IFACE}\})" ]
then
eerror "Please make sure that /etc/conf.d/net has \$iface_$IFACE set"
return 1
fi
}
start() {
checkconfig || return 1
local iface_args="$(eval echo \$\{iface_${IFACE}\})"
local dhcp_args="$(eval echo \$\{dhcpcd_${IFACE}\})"
local retval=0
ebegin "Bringing ${IFACE} up"
if [ "$(eval echo \$\{iface_${IFACE}\})" != "dhcp" ]
then
/sbin/ifconfig ${IFACE} ${iface_args} >/dev/null || {
retval=$?
eend ${retval} "Failed to bring ${IFACE} up"
return ${retval}
}
# ifconfig do not always return failure ..
/sbin/ifconfig ${IFACE} &> /dev/null || {
retval=$?
eend ${retval} "Failed to bring ${IFACE} up"
return ${retval}
}
else
/sbin/dhcpcd ${dhcp_args} ${IFACE} >/dev/null || {
retval=$?
eend ${retval} "Failed to bring ${IFACE} up"
return ${retval}
}
fi
eend 0
if [ -n "$(eval echo \$\{alias_${IFACE}\})" ]
then
local x=""
local num=0
local aliasbcast=""
local aliasnmask=""
ebegin " Adding aliases"
for x in $(eval echo \$\{alias_${IFACE}\})
do
aliasbcast="$(eval echo \$\{broadcast_${IFACE}\} \| awk \'\{ print \$$((num + 1)) \}\')"
if [ -n "${aliasbcast}" ]
then
aliasbcast="broadcast ${aliasbcast}"
fi
aliasnmask="$(eval echo \$\{netmask_${IFACE}\} \| awk \'\{ print \$$((num + 1)) \}\')"
if [ -n "${aliasnmask}" ]
then
aliasnmask="netmask ${aliasnmask}"
fi
ebegin " ${IFACE}:${num}"
/sbin/ifconfig ${IFACE}:${num} ${x} \
${aliasbcast} ${aliasnmask} >/dev/null
num=$((num + 1))
eend 0
done
save_options "alias" "$(eval echo \$\{alias_${IFACE}\})"
fi
if [ -n "$(eval echo \$\{inet6_${IFACE}\})" ]
then
local x=""
ebegin " Adding inet6 addresses"
for x in $(eval echo \$\{inet6_${IFACE}\})
do
ebegin " ${IFACE} inet6 add ${x}"
/sbin/ifconfig ${IFACE} inet6 add ${x} >/dev/null
eend 0
done
save_options "inet6" "$(eval echo \$\{inet6_${IFACE}\})"
fi
## take care of multi gateway entries separated by space
## syntax: gateway="iface1/gw-address1 iface2/gw-address2 iface3/gw-address3"
for gateway_entry in ${gateway}
do
if [ -n "${gateway_entry}" ] && [ "${gateway_entry%/*}" = "${IFACE}" ]
then
ebegin " Setting default gateway"
/sbin/route add default gw ${gateway_entry#*/} dev ${gateway_entry%/*} \
netmask 0.0.0.0 metric 1 >/dev/null || {
local error=$?
ifconfig ${IFACE} down &>/dev/null
eend ${error} "Failed to bring ${IFACE} up"
stop
return ${error}
}
eend 0
fi
done
# Enabling rp_filter causes wacky packets to be auto-dropped by
# the kernel
if [ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter ]
then
echo 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
fi
}
stop() {
local myalias="$(get_options alias)"
ebegin "Bringing ${IFACE} down"
# Also down the inet6 interfaces
local myinet6="$(get_options inet6)"
if [ -n "${myinet6}" ]
then
local x=""
for x in ${myinet6}
do
/sbin/ifconfig ${IFACE} inet6 del ${x} >/dev/null
done
fi
# Do some cleanup in case the amount of aliases change
if [ -n "${myalias}" ]
then
local x=""
local num=0
for x in ${myalias}
do
/sbin/ifconfig ${IFACE}:${num} down >/dev/null
num=$((num + 1))
done
fi
if [ "$(eval echo \$\{iface_${IFACE}\})" = "dhcp" ]
then
/sbin/dhcpcd -k ${IFACE} &>/dev/null
# Give dhcpcd time to properly shutdown
local count=0
einfon " Waiting for dhcpcd to shutdown"
while [ "${count}" -lt 5 ]
do
echo -n "."
sleep 1
count=$((count + 1))
done
echo "done"
else
/sbin/ifconfig ${IFACE} down >/dev/null
fi
eend 0
}
# vim:ts=4 |
and in your /etc/rc.conf you can now activate a gateway per interface: Code: | gateway="eth0/192.168.0.254 eth1/195.xxx.xxx.145" |
the only change I did is in the way the gateway is handled: Code: | ## take care of multi gateway entries separated by space
## syntax: gateway="iface1/gw-address1 iface2/gw-address2 iface3/gw-address3"
for gateway_entry in ${gateway}
do
if [ -n "${gateway_entry}" ] && [ "${gateway_entry%/*}" = "${IFACE}" ]
then
ebegin " Setting default gateway"
/sbin/route add default gw ${gateway_entry#*/} dev ${gateway_entry%/*} \
netmask 0.0.0.0 metric 1 >/dev/null || {
local error=$?
ifconfig ${IFACE} down &>/dev/null
eend ${error} "Failed to bring ${IFACE} up"
stop
return ${error}
}
eend 0
fi
done |
btw: I have submit this issue to bugs.gentoo.org (report 19864)
cheers
SteveB |
|
Back to top |
|
|
STEDevil Apprentice
Joined: 24 Apr 2003 Posts: 156
|
Posted: Thu Apr 24, 2003 3:23 pm Post subject: |
|
|
steveb wrote: |
2 nic's connected having the same gateway?
then just add to your /etc/conf.d/net the following
gateway="eth0/<gateway-address>"
and then just do: Code: | /etc/init.d/net.eth0 restart
/etc/init.d/net.eth1 restart |
|
I had gateway="eth0/<gateway-address>" all along, but what is that restarting supposed to do that is not done by normal reboot?
Anyway, I solved my problem by a "bruteforce" hack of net.eth1 (I just hardcoded the gateway right in there, instead of the fancy if fi statement that doesn't work).
Just mentioned my problem here, because a lot of people seems convinced that there is no need for even the possibility of adding multiple GW - NIC bindings in the default script. IMO something like your script enhancment should definitly be added. Will save a lot of headaces for at least a few people down the line |
|
Back to top |
|
|
EnricoHorn Apprentice
Joined: 23 Apr 2003 Posts: 165 Location: Koenigsee, Thuringia, Germany
|
Posted: Thu Apr 24, 2003 7:40 pm Post subject: |
|
|
@steveb
Im confused.
Correct me if im wrong:
If you dont force the packets to the internet to go over a specific interface, doesnt it go over eth1 with your routing configuration?
So how do you force packets to go over eth0? (for instance if they come from a internal network)
@STEDevil
2 NICs to the same gateway?
So the 2 cards are in the same subnet? If this is the case, how does the machine knows which NIC to use, if you dont specify it? Maybe its just using the first?
Maybe Im just stupid. |
|
Back to top |
|
|
steveb Advocate
Joined: 18 Sep 2002 Posts: 4564
|
Posted: Thu Apr 24, 2003 8:23 pm Post subject: |
|
|
EnricoHorn wrote: | @steveb
Im confused.
Correct me if im wrong:
If you dont force the packets to the internet to go over a specific interface, doesnt it go over eth1 with your routing configuration?
So how do you force packets to go over eth0? (for instance if they come from a internal network) |
NO! It does not go over eth1!
the reason why it does not go over eth1 is because the main interface is eth0 and when I log into that computer (over ssh and i am loging into eth0, because this is my internal network and no reason that i use the external interface... eaven if the computer is sitting near me) then traffic leaving the local network will go over eth0.
I could force the travel over eth1 by deleting the default route of eth0, but this is not my problem.
the problem is, that if someone is accessing outside the local network the ip address assigned to eth1, then all the traffic wich should travel back to the person accessing from outside the local network that interface does NOT go over eth1! it goes over eth0 back... and this is just wrong! but when i add a default route using eth1, then everything goes the right way back.
okay... and now in german, because i know you understand it and i can write better in german then in english....
nochmals ganz kurz. ich habe einen web-server, der auf eth1 direkt eine verbindung ins internet hat. also ist diese karte/ip-adresse direkt aufrufbar. hingegen ist eth0 nicht direkt zum internet angeschlossen und geht über einen nat-router ins internet. wenn nun ein benutzer über einen browser die adresse von eth1 eintippt, dann kommt er zwar physisch auf die eth1 karte aber der computer sendet NICHT über eth1 zurück... sondern sieht nur eine anfrage die er beantworten muss und sieht, dass es sich um eine externe adresse handelt und versucht über den default gateway die syn/ack anfrage zu beantworten und das geht natürlich nicht!
wenn ich aber nun noch einen weitere default gateway eintrag mache und diesen nur auf eth1 limitiere, dann geht der mist ohne problem. demzufolge ist dieser eintrag einfach notwendig. denn ohne ihn geht es nicht.
so wie ich die sache momentan interpretiere, ist es etwa so:
zuerst wird nach dem default gateway der karte gesucht die ein packet versenden muss. wenn da kein eintrag vorhanden ist (also kein eth1 gw eintrag, wenn wir die anfrage über eth1 bekommen) dann wird der nächste default gateway genommen (ich weiss nicht, ob es dann sofort zu eth0 springt oder ob es die nächst tiefere ethx gw route nehmen würde. ich habe halt nur eth1 und eth0...)
ich glaube dass dieser gw eintrag einfach notwendig ist! und es wird ein gw eintrag favorisiert, der auf dem gleichen ethX strang ist und danach wird erst der nächste routing eintrag genommen...
gruss/cheers
SteveB |
|
Back to top |
|
|
STEDevil Apprentice
Joined: 24 Apr 2003 Posts: 156
|
Posted: Fri Apr 25, 2003 5:16 am Post subject: |
|
|
EnricoHorn wrote: |
@STEDevil
2 NICs to the same gateway?
So the 2 cards are in the same subnet? If this is the case, how does the machine knows which NIC to use, if you dont specify it? |
But I DO specify it
ping -I eth0 Gateway
ping -I eth1 Gateway
If the gateway is bound to eth0, then ping -I eth1 host will fail and vice versa (with the Gentoo default startup script).
And once I get up my Counterstrike servers on it they will ALSO be bound to different NICs.
What I'm saying here is, sure, for MOST uses you don't need more then 1 bind to a default GW. But in some cases you do, and since it's trivial to add this functionallity to the Gentoo default script it makes no scense to NOT do it...
In short, we have two basicly equal scripts, one that caters for the needs of 99% of the users and one that caters for 100% of the users. My vote would be for the one that works for 100% of the users to be the default
(BTW, running your script now SteveB, and it's working just wonderfully |
|
Back to top |
|
|
steveb Advocate
Joined: 18 Sep 2002 Posts: 4564
|
Posted: Fri Apr 25, 2003 9:30 pm Post subject: |
|
|
STEDevil wrote: | (BTW, running your script now SteveB, and it's working just wonderfully |
it is not my script i just edited some lines to fit more to my needs. but i am happy that it works for you.
cheers
SteveB |
|
Back to top |
|
|
|