INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

setting up 2 network interfaces on linux laptop to share internet conn

setting up 2 network interfaces on linux laptop to share internet conn

setting up 2 network interfaces on linux laptop to share internet conn

(OP)
Hi!

I read for 4 days various articles on it, but being a networking and Linux Noob, could not make it work.  I  am out of ideas with no hope of making it on my own, so please, HELP!

I am trying to set up a laptop with linux server as a gteway/router.  Laptop needs Public IP because some app does not work behind NAT.  DMZ did not work, so I am setting it up to connect directly to modem and pass through internet connection to WiFi router

Laptop connects to Internet modem with USB (eth2) port, and to WiFi Router with LAN (eth0) port.  In this setup, eth2 connects to internet, but eth0 is not connecting to WiFi router - Ping returns "Destination Host Unreachable."

 There is no bridge and no DHCP on laptop.

When connected to LAN as Computer 3 (192.168.0.202) (eth0) it is working fine.

eth0 and eth2 are as follows
Eth0
address 192.168.0.202
netmask 255.255.255.0
network 192.168.0.0
gateway 192.168.0.1  - WiFi Routeer

Eth2
Address    68.37.253.151
netmask 255.255.252.0
Gateway 68.37.136.1


My current LAN setup:
Internet Modem -> WiFi Router (192.168.0.1)
IP Address :      68.37.253.151
Subnet Mask :      255.255.252.0
Default Gateway :68.37.136.1
DNS :      4.2.2.2 8.8.8.8  
-> -> ->Computer 1 (192.168.0.100), Computer 2 (192.168.0.101), VoIP Phone (192.168.0.102)

I am trying to set up:

Internet Modem -> Linux (Ubuntu 8.04 LTE) server ->
-> WiFi Router (192.168.0.1) -> -> -> Computer 1 (192.168.0.100), Computer 2 (192.168.0.101), VoIP Phone (192.168.0.102)

Kernel IP routing table behind router reads

Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.0.0  0.0.0.0       255.255.255.0   U  0 0       0 eth0
0.0.0.0      192.168.0.1   0.0.0.0         UG 0 0       0 eth0

When eth2 is on, (ahead of router) it reads
192.168.0.0  0.0.0.0      255.255.255.0   U   0 0       0 eth0
0.0.0.0      192.168.0.1  0.0.0.0         UG  0 0       0 eth0
67.37.252.0  0.0.0.0      255.255.254.0   U   0 0       0 eth2

I edited file /etc/init.d/firewall.sh

iptables --table nat --append POSTROUTING --out-interface eth2 -j MASQUERADE
iptables --append FORWARD --in-interface eth0 -j ACCEPT

Edited      /etc/sysctl.conf
to enable   net.ipv4.ip_forward=1

Thank you for reading.




 

RE: setting up 2 network interfaces on linux laptop to share internet conn

I'd install Webmin, setup the two interfaces as you have, then allow routing between interfaces.  (All in Webmin under "Networking")

Make sure there is a route where the default gateway is 68.37.136.1

Finally, make the default gateway in your wireless router (which won't be routing anything but will act as the DHCP server) 192.168.0.202 with the 2 DNS servers you mentioned.

Don't plug anything into the WAN port of your wireless router - everything should be plugged into the LAN side.

-----------------------------------
Telephone & computer wiring/Cat 5E/Cat 6/Fibre Optic cabling in Calgary, AB

RE: setting up 2 network interfaces on linux laptop to share internet conn

To share an internet connection in Linux there are two things that are required.
1 - enable IPV4 Forwarding.  This is set in a /proc file, which is defaulted as not persistent across reboots.  You will need to account for this in your configuration.

2 - Use IPTables to perform the NAT between the interfaces.  The easiest way to do this is with the MASQUERADE directive.

This article seems to explain the steps clearly: http://www.revsys.com/writings/quicktips/nat.html

Also, beware that you only have ONE default gateway.  Typically this will be on your Internet access interface and the other interfaces will simply route the local subnet.
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close