Havoc

How to share internet connection using second NIC ?

7 posts in this topic

Right now my network setup looks like this

CABLE_MODEM -> ROUTER -> CENTOS & OTHER_PC

and I want it change to

CABLE_MODEM -> CENTOS -> ROUTER -> OTHER_PC

I have two NICs, the first one (WAN side) should be dhcp and the second one can provide static or dynamic address for the router

Can you point me what tools should I use or what tutorial to look for ?

I'm trying to use 'Routing and Gateways' under 'Webmin' but still no luck.

0

Share this post


Link to post
Share on other sites

Unless you can uplink the router, there's no way you can put your CentOS PC (or any other device for that matter) "above" the router.

0

Share this post


Link to post
Share on other sites
Unless you can uplink the router, there's no way you can put your CentOS PC (or any other device for that matter) "above" the router.

I'm not sure what you mean by uplink the router but I would do this using iptables. That way the centos box is acting as a hardware firewall and routes packets to the router (or from the router to the internet) by forwarding from one nic to the other.

This is what you are trying to do right?

-Dr^ZigMan

0

Share this post


Link to post
Share on other sites
and I want it change to

CABLE_MODEM -> CENTOS -> ROUTER -> OTHER_PC

I have two NICs, the first one (WAN side) should be dhcp and the second one can provide static or dynamic address for the router

I assume you mean that you have 2 NIC in the CentOS machine. You have a number of options.

1). DMZ CentOS machine from your router so that the CentOS is 'fully' connected on the public IP (via LAN). Or just port forward all of the ports you need.

2). If your cable provider will allocate you 2 public IP's install another hub (or router without using the WAN port) up stream of CentOS machine.

3). If your cable provider will allocate you 2 public IP's then you can bridge the connection between the 2 NIC's with a single IP public address, whilst the router will claim another public IP. Packets meant for the router will be relayed. The OtherPC will be on a private network.

4). You could install a software firewall on the CentOS machine so that there is 1 public IP on 1 NIC and use NAT to create a private LAN on the other to the router. You can just use LAN ports on the router (ie. disable WAN port) or use a third private LAN for the OtherPC (multiple layers of NAT is a pain).

5). If your Router supports alternate firmwares (ie. OpenWRT) you can configure more than 1 physical port (RJ45) to be the WAN. Plug 1 WAN into cable modem and the other WAN into CentosOS machine.

Should give you a few things to try....

Mungewell.

0

Share this post


Link to post
Share on other sites
1). DMZ CentOS machine from your router so that the CentOS is 'fully' connected on the public IP (via LAN). Or just port forward all of the ports you need.

I've tried this many times and does not work and I have no idea why. Port forwarding neither does work.

When I dmz or port forward and for example connect to PUBLIC_IP:80 it connects me to my router (which isn't running anything on this port) instead of linux box.

4). You could install a software firewall on the CentOS machine so that there is 1 public IP on 1 NIC and use NAT to create a private LAN on the other to the router. You can just use LAN ports on the router (ie. disable WAN port) or use a third private LAN for the OtherPC (multiple layers of NAT is a pain).

that's what I want to do, right now my linux box is 'PBX in a Flash' distro running CentOS 5 with iptables enabled

and trying this tutorial

http://ubuntulinuxhowto.blogspot.com/2006/...-be-router.html

5). If your Router supports alternate firmwares (ie. OpenWRT) you can configure more than 1 physical port (RJ45) to be the WAN. Plug 1 WAN into cable modem and the other WAN into CentosOS machine.

Yeah, I have DD-WRT v.24 running but I don't understand what you mean.

Do you want me to connect two machines (router and centos) in the same time to the cable modem ?

Plug 1 WAN into cable modem and the other WAN into CentosOS machine.

cable modem to centos and router to what ?

0

Share this post


Link to post
Share on other sites

I did this a while back like so: Ethernet coming in from the wall connected to NIC 1 of my Linux PC, NIC 2 went out as a crossover cable to my 486DX2 running OpenBSD. Later on, NIC 2 went out to a 4-port hub which I plugged the OpenBSD box and lots of other stuff into. Linux was configured to forward traffic with iptables. I think I got most of the configuration from the TLDP Iptables-HOWTO. It was ghetto, but it worked. I've attached a picture of what it ended up looking like. The yellow CAT5 cable hanging down was coming from NIC 2. The gray cable cable in the background to the right went behind the desk into NIC 1.

post-1851-1199877843_thumb.jpg

0

Share this post


Link to post
Share on other sites
5). If your Router supports alternate firmwares (ie. OpenWRT) you can configure more than 1 physical port (RJ45) to be the WAN. Plug 1 WAN into cable modem and the other WAN into CentosOS machine.

Yeah, I have DD-WRT v.24 running but I don't understand what you mean.

Do you want me to connect two machines (router and centos) in the same time to the cable modem ?

There is nothing special (different) about the ports on the back of my router (a WRT54GL), it is purely by convention that one is for the WAN the others are for the LAN. The hardware contained within the router is simply a multi-port switch with VLAN capability.

See:

http://wiki.openwrt.org/OpenWrtDocs/Networ...c2e2ebff56fb784

With OpenWRT you can assign which ports on the switch are connected to which VLAN, so effectively you can convert it into a 3 port LAN switch and a 2 port (+1 internal connection) WAN switch.

Once reconfigured for VLAN1 on ports 0 & 1, for the WAN side you can plug in the cable modem to port 0 and a PC into port 1 (which could request an IP via DHCP from your cable provider). Any packets flying around in VLAN0 will be routed to the appropriate place by the switch.

This obviously this requires that your provider will allow/allocate 2 different IP's.

[side note: Shaw.ca where nice to allocate 2 IP's for my routers, however stupid enough to allocate them on different net blocks....]

Get out clause... don't know whether this is possible via the DD-WRT gui, however it looks like you can edit the config files to achieve the same thing.

http://www.dd-wrt.com/wiki/index.php/Speci...=vlan&go=Go

Have fun re-purposing your router,

Munge.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now