Jump to content

Back To Basics: How Do You Bridge Or Nat Two Interfaces?


ascorbic
 Share

Recommended Posts

Here is my setup

[WIRELESS ROUTER] ----- [ eth1 <PC> eth0] ----- [INTERNET]

I have a PC which connects to the internet (via eht0). I want to share that connection with eth1 for the wireless router. Basically I am trying to set up my own little router here. The PC does not need to server DHCP, the wireless router can do that on its own. The PC just needs to forward all the traffic from eth1 to eth0.

I thought this would be as easy as setting the wireless router up with a static ip of 172.20.0.1 and executing the following on the PC

echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo ifconfig eth1 172.20.0.1 netmask 255.255.255.0

But something is getting lost along the lines. From the PC I can ping 172.20.0.1, but from the wireless clients I can't ping anything beyond the router, most ping attempts from the wireless get destination host unreachable.

Am I going about this the completely wrong way? If this is the correct path am I just missing settings? I have also tried configuring the router to use the PC's IP as the gateway.

Link to comment
Share on other sites

I'm going to guess that the wireless router is acting as a DHCP server, and doesn't have NAT configured. That would mean that it is setting itself as the default gateway, and so the clients cannot connect.

Install a DHCP server such as dnsmasq on your PC, and configure yourself as the gateway.

Link to comment
Share on other sites

I'm going to guess that the wireless router is acting as a DHCP server, and doesn't have NAT configured. That would mean that it is setting itself as the default gateway, and so the clients cannot connect.

Install a DHCP server such as dnsmasq on your PC, and configure yourself as the gateway.

Thanks for the response.

Yes the wireless router is acting as a DHCP server.

Even without a DHCP server on the PC, shouldn't the wireless clients be able to ping IP addresses?

Link to comment
Share on other sites

Thanks for the response.

Yes the wireless router is acting as a DHCP server.

Even without a DHCP server on the PC, shouldn't the wireless clients be able to ping IP addresses?

yes they should be able to ping any ip address on the network, unless it has not been configured properly.

Checked out this link, detailing how to configure a bridged connection in XP

http://www.home-network-help.com/network-bridge.html

Link to comment
Share on other sites

Thanks for the responses.

I am having some trouble with dnsmasq. I feel like the configuration I want is pretty simple, any ideas on how it should be set up? A basic tutorial would be great. I am looking online and I am seeing either the man descriptions or advanced configurations. The PC is running backtrack 4 by the way.

Link to comment
Share on other sites

Thanks for the responses.

I am having some trouble with dnsmasq. I feel like the configuration I want is pretty simple, any ideas on how it should be set up? A basic tutorial would be great. I am looking online and I am seeing either the man descriptions or advanced configurations. The PC is running backtrack 4 by the way.

I think this links might help u

http://wiki.debian.org/HowTo/dnsmasq

http://www.mythicalbeast.co.uk/linux/dnsmasq_howto.html

http://www.iceflatline.com/2010/02/how-to-...figure-dnsmasq/

Link to comment
Share on other sites

Awesome, thanks the first one really helped. I didn't realize the service starts after you install it. The steps I needed were

Edit /etc/dnsmasq.conf

Specify interface=eth1

Enable DHCP dhcp-range=192.168.0.50,192.168.0.150,12h

I also enabled an address for the host as well as set that address using ifconfig on the host, not sure if that is needed

Restarted the service /etc/init.d/dnsmasq restart

Link to comment
Share on other sites

Awesome, thanks the first one really helped. I didn't realize the service starts after you install it. The steps I needed were

Edit /etc/dnsmasq.conf

Specify interface=eth1

Enable DHCP dhcp-range=192.168.0.50,192.168.0.150,12h

I also enabled an address for the host as well as set that address using ifconfig on the host, not sure if that is needed

Restarted the service /etc/init.d/dnsmasq restart

No problems, I am glad could help.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...