Re: Bridge eth0 and eth1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Raymond Day wrote:

Hi. I have Fedora running as a server. It's working real good. I have 2 ethernet cards on it. One is a 10/100 and the other a 10/100/1000 What I would like to do is Bridge them. I like to plug my main PC in to the 1000 NIC and my LAN into the 100 NIC like it is now. I just don't know how to set it up. A ifconfig on the 2 NIC I get this:
eth0 Link encap:Ethernet HWaddr 00:0C:F1:97:98:6E
inet addr:192.168.101.10 Bcast:192.168.101.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:207880844 errors:0 dropped:0 overruns:0 frame:0
TX packets:118334357 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2494787937 (2379.2 Mb) TX bytes:1064255721 (1014.9 Mb)
Interrupt:5 Base address:0xb400 Memory:ff8ef000-ff8ef038
eth1 Link encap:Ethernet HWaddr 00:07:E9:3E:C3:83
inet addr:192.168.100.50 Bcast:192.168.100.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:354284112 errors:0 dropped:0 overruns:0 frame:0
TX packets:514821395 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2622181163 (2500.7 Mb) TX bytes:3227626141 (3078.1 Mb)
Base address:0xb800 Memory:ff8c0000-ff8e0000
I like to set it up like this because my PC has a 1000 NIC in it too. This way I can do Ethernet fast from my PC to the sever. But I still like to be on my LAN too.
I did this:
brctl addbr mybridge
brctl addif mybridge eth0
brctl addif mybridge eth1
ifconfig eth0 192.168.101.10
ifconfig eth1 192.168.100.50
ifconfig mybridge up
But a brctl show says under enabled no.
I did not have a monitor, mouse, or keyboard on it. When I started to do this I could not get to it any more. So I put a monitor, mouse and keyboard on it. But I still can't connect to it with Ethernet now.
I hope some one can help.
It was working before by using IP tables. But I could not FTP to some things on my LAN then. This is why I like to try and bridge it.
-Raymond Day

I don't see what the problem is, I used 10M Nic card (3com) to the outside world, and a 10/100 Nic (Intel) for my subnet via a simple switch. It worked automatically. There is sometimes some hardware driver tuning software, what you can download from the manufacturers tite and use with Windows or DOS.


I append a goodie pingscript for subnetting on (A)DSL:

#!/bin/bash
#
# check-if-ppp-up
#
# Peter de Freitas aka ghovs <ghovs@xxxxxxx>
# not-so-fast hack to keep ADSL alive. Include in crontab
#
# example:
# /usr/local/sbin/check-if-ppp-up
# and in /etc/crontab the following line:
# one-min check if ppp0 is up
*/1 * * * * root /usr/local/sbin/check-if-ppp-up 1> /dev/null


# variables

export PPP_INTERFACE=ppp0        # ppp device
export GATEWAY=195.190.242.109        # ip of ppp device
export ADSL_ROUTER=10.0.0.138        # ip of ADSL router

export INTERNAL_INTERFACE=eth0        # interface to LAN (if any)
export INTERNAL_NETWORK=10.0.0.0    # class c used for LAN (if any)
export EXTERNAL_INTERFACE=eth1        # interface to ADSL router
export EXTERNAL_NETWORK=10.0.0.0    # class c used for ADSL router
                   # ext and int class c's -can- be equal

export LOG=/var/log/ppp.log        # logfile


# functions

add_gateway ()
{
 # add default gateway
 echo "check-if-ppp-up: trying to add default gateway..." &&
 route add default gw $GATEWAY 2> /dev/null &&
 echo "check-if-ppp-up: default gateway added." >> $LOG ||
 echo "check-if-ppp-up: failed to add default gateway." >> $LOG
}

start_pppd ()
{
 # start up pppd
 echo "check-if-ppp-up: trying to restart pppd..." >> $LOG &&
 pptp 10.0.0.138 file /etc/ppp/options 1>> $LOG &&
 echo "check-if-ppp-up: $PPP_INTERFACE brought back up." >> $LOG ||
 echo "check-if-ppp-up: failed to bring $PPP_INTERFACE back up." >> $LOG &

 sleep 35 # matches pptp failure timeout

 # add default gateway
 add_gateway
}

raise_ppp ()
{
# bring up ppp device
echo "check-if-ppp-up: trying to bring up $PPP_INTERFACE..." >> $LOG &&
ifconfig $PPP_INTERFACE up 2> /dev/null &&
echo "check-if-ppp-up: $PPP_INTERFACE brought back up." >> $LOG ||
echo "check-if-ppp-up: attempt to bring $PPP_INTERFACE back up failed, DIY time." >> $LOG


 # add default gateway
 add_gateway
}

timestamp ()
{
 # timestamp for the log
 date >> $LOG
}

endstamp ()
{
# indicate end of check-if-ppp-up instance (comment out to keep quiet)
echo "-<->-" >> $LOG
}


# script

# first attempt, in case ppp0 interface is unavailable
# (most likely)
if ! ifconfig | grep $PPP_INTERFACE &&
   # if ppp device is not up
  ! ifconfig $PPP_INTERFACE 2> /dev/null | grep $PPP_INTERFACE > /dev/null;
   # if ppp device does not exist
 then

 timestamp

 # explain problem
 echo "check-if-ppp-up: $PPP_INTERFACE does not exist." >> $LOG;

 # fix problem
 start_pppd

 endstamp


# second attempt, in case only the default gw is missing
# (not too likely)
elif route -n | grep "$GATEWAY 0.0.0.0 255.255.255.255 UH 0 0 0 $INTERFACE" &&
# if route to default gateway exists
! route -n | grep "0.0.0.0 $GATEWAY 0.0.0.0 UG 0 0 0 $INTERFACE";
# if default gateway is not set as such
then


 timestamp

 # explain problem
 echo "check-if-ppp-up: the default gateway is unset." >> $LOG

 # fix problem
 add_gateway

 endstamp


# third attempt, in case someone did something like 'ifconfig ppp0 down'
# (not likely)
elif ifconfig $PPP_INTERFACE 2> /dev/null | grep $PPP_INTERFACE > /dev/null &&
# if ppp device exists
! ifconfig | grep $PPP_INTERFACE;
# if ppp device is not up
then


 timestamp

 # explain problem
 echo "check-if-ppp-up: $PPP_INTERFACE exists, but is down." >> $LOG

 # fix problem
 raise_ppp

 endstamp


# fourth attempt, in case someone messed up the routing table
# (hardly likely)
# this -only- tries to get ADSL back up, it does -not- try to fix beyond that
elif ! route -n | grep "0.0.0.0 $GATEWAY 0.0.0.0 UG 0 0 0 $PPP_INTERFACE" &&
# if default gateway is not set as such
! route -n | grep "$GATEWAY 0.0.0.0 255.255.255.255 UH 0 0 0 $PPP_INTERFACE" &&
# if route to default gateway does not exist
! route -n | grep "$EXTERNAL_NETWORK 0.0.0.0 255.255.255.0 U 0 0 0 $EXTERNAL_INTERFACE" ||
! route -n | grep "$ADSL_ROUTER 0.0.0.0 255.255.255.255 UH 0 0 0 $EXTERNAL_INTERFACE";
# if route to ADSL router does not exist
then


 timestamp

 # explain problem
 echo "check-if-ppp-up: the routing table is not set up correctly." >> $LOG

# fix problem
# set route to ADSL router
if [ "$INTERNAL_NETWORK" != "$EXTERNAL_NETWORK" ];
then
route add -net $EXTERNAL_NETWORK netmask 255.255.255.0 dev $EXTERNAL_INTERFACE 2> /dev/null &&
echo "check-if-ppp-up: added route to ADSL router." >> $LOG ||
echo "check-if-ppp-up: failed to add route to ADSL router, DIY time." >> $LOG


elif [ "$INTERNAL_NETWORK" = "$EXTERNAL_NETWORK" ];
# if internal and external network are on the same class c
then
route del -net $EXTERNAL_NETWORK netmask 255.255.255.0 dev $EXTERNAL_INTERFACE 2> /dev/null &&
route add -host $ADSL_ROUTER dev $EXTERNAL_INTERFACE 2> /dev/null &&
echo "check-if-ppp-up: added route to ADSL router." >> $LOG ||
echo "check-if-ppp-up: failed to add route to ADSL router, DIY time." >> $LOG
fi


 # now that the routes are all set, the ppp device can be brought back up
 start_pppd

 endstamp
fi


# changelog

# 05-nov-2001 <ghovs@xxxxxxx>
# - major overhaul, should function properly at last
# - added three less likely cases of ADSL breakdown, as well as
# - config variables, comments, log messages, functions
# 08-nov-2001 <ghovs@xxxxxxx>
# - fixed one message not going to $LOG

--
Vink



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux