Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Bridge or Route Wired/Wireless NICs? [Solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
nilecirb
Tux's lil' helper
Tux's lil' helper


Joined: 15 Jan 2004
Posts: 127

PostPosted: Mon Feb 27, 2006 1:59 am    Post subject: Bridge or Route Wired/Wireless NICs? [Solved] Reply with quote

My laptop has two NICs: one wired, the other wireless. I have successfully configured both (with static IP), and now I would like to set up my laptop so that my desktop can connect to my laptop via the wired NIC, while my laptop forwards those packets via the wireless to my wireless router. Meanwhile, I would like my laptop to retain its connection to the router so that I can still use the internet. After researching, I discovered that a bridge might serve my purpose. After emerging bridge-utils and reading the documentation, I attempted to set up a bridge between my wireless and wired NICs on my laptop. However, while both NICs work fine independently, when I add them to the bridge, neither works as intended.

I set the bridge up with
Code:
brctl addbr br0
brctl addif ath0
brctl addif eth0
ifconfig ath0 0.0.0.0
ifconfig eth0 0.0.0.0
ifconfig br0 up

Would bridging my two NICs solve my problem? Thanks for any assistance.


Last edited by nilecirb on Tue Feb 28, 2006 8:04 am; edited 2 times in total
Back to top
View user's profile Send private message
JeliJami
Veteran
Veteran


Joined: 17 Jan 2006
Posts: 1086
Location: Belgium

PostPosted: Mon Feb 27, 2006 12:40 pm    Post subject: Reply with quote

just config your laptop to be a router:
Code:
# iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
# echo "1" > /proc/sys/net/ipv4/ip_forward

(replace wlan0 with your wireless NICs name)

and use your laptop's wired IP address as default gateway on your desktop
_________________
Unanswered Post Initiative | Search | FAQ
Former username: davjel
Back to top
View user's profile Send private message
nilecirb
Tux's lil' helper
Tux's lil' helper


Joined: 15 Jan 2004
Posts: 127

PostPosted: Tue Feb 28, 2006 6:48 am    Post subject: Reply with quote

Thanks for replying, davjel. Since I configured net.ath0 already, I performed the following commands:
Code:
/etc/init.d/net.ath0 start
iptables -t nat -A POSTROUTING -o ath0 -j MASQUERADE
echo "1" > /proc/sys/net/ipv4/ip_forward
ifconfig eth0 192.168.2.1

However, that does not work. How exactly does eth0 (or any ethernet device, for that matter) know to access ath0 for its gateway?
Back to top
View user's profile Send private message
JeliJami
Veteran
Veteran


Joined: 17 Jan 2006
Posts: 1086
Location: Belgium

PostPosted: Tue Feb 28, 2006 7:08 am    Post subject: Reply with quote

on your laptop, make sure to set the default gateway to the wireless router (over ath0)
Code:
[root@laptop]# route add default gw <ip of wireless router>


on the machines that are connected via eth0 (wired), make sure to set the default gateway to the wired NIC
Code:
[root@otherPC]# route del default
[root@otherPC]# route add default gateway 192.168.2.1

_________________
Unanswered Post Initiative | Search | FAQ
Former username: davjel
Back to top
View user's profile Send private message
nilecirb
Tux's lil' helper
Tux's lil' helper


Joined: 15 Jan 2004
Posts: 127

PostPosted: Tue Feb 28, 2006 7:21 am    Post subject: Reply with quote

Since the desktop is a Windows box, I manually entered the IP 192.168.2.2, subnet mask 255.255.255.0, and gateway 192.168.2.1, with the DNS pointing to 192.168.2.1. However, I still can't access the internet from it.

The following is the output of route from the laptop:
Code:
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.2.0     *               255.255.255.0   U     0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     0      0        0 ath0
loopback        localhost       255.0.0.0       UG    0      0        0 lo
default         192.168.1.1     0.0.0.0         UG    0      0        0 ath0
Back to top
View user's profile Send private message
JeliJami
Veteran
Veteran


Joined: 17 Jan 2006
Posts: 1086
Location: Belgium

PostPosted: Tue Feb 28, 2006 7:55 am    Post subject: Reply with quote

nilecirb wrote:
...with the DNS pointing to 192.168.2.1. However, I still can't access the internet from it.


Does this laptop run a dns server or dns proxy?
If not, just use your regular DNS server (your ISP's ?).

Try to ping 192.168.2.1 from the windows box.
If that's OK, try to ping 192.168.1.1 from the windows box.
If that's OK, you should be able to ping for example 1.1.1.1 from the windows box.
_________________
Unanswered Post Initiative | Search | FAQ
Former username: davjel
Back to top
View user's profile Send private message
nilecirb
Tux's lil' helper
Tux's lil' helper


Joined: 15 Jan 2004
Posts: 127

PostPosted: Tue Feb 28, 2006 8:01 am    Post subject: Reply with quote

At first I thought that the laptop would act as a DNS server, but after you suggested I use my regular one, everything worked wonderfully. Thanks a lot for your help, davjel!
Back to top
View user's profile Send private message
JeliJami
Veteran
Veteran


Joined: 17 Jan 2006
Posts: 1086
Location: Belgium

PostPosted: Tue Feb 28, 2006 8:08 am    Post subject: Reply with quote

nilecirb wrote:
Thanks a lot for your help, davjel!


You're welcome :)

For those with similar problems or setup, there is more information available at http://gentoo-wiki.org:

http://www.gentoo-wiki.org/HOWTO_setup_a_home-server
http://www.gentoo-wiki.org/HOWTO_Building_a_Wireless_Access_Point_With_Gentoo
http://www.gentoo-wiki.org/HOWTO_Iptables_for_newbies
_________________
Unanswered Post Initiative | Search | FAQ
Former username: davjel
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum