LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-02-2014, 06:11 PM   #1
baronobeefdip
Senior Member
 
Registered: Jul 2009
Distribution: Debian Squeeze
Posts: 1,267

Rep: Reputation: 32
Can I use iptables to share a wireless connection


I am trying to make a router with a spare computer I have in the house. I basically want to use the spare computer to receive the wireless connection and then route it to the ethernet cable. I want to be able to connect a device to the internet from it's ethernet cable to the machine and for the machine it's connected to to receive the internet connection through it's wireless interface.

I read that this can be done with iptables, The many guides I have read give vague details and steps on how to do it but doesn't explain what the commands do. I appreciate the help.
 
Old 01-02-2014, 06:55 PM   #2
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,979
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
Well I don't know what distro of Linux you're using...but in "Red Hat Land"

Enable packet forwarding in /etc/sysctl.conf
Code:
net.ipv4.conf.default.forwarding=1
Load in sysctl settings from /etc/sysctl.conf
Code:
sysctl -p
Then set up IP tables to route the traffic...

Code:
service iptables stop
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
service iptables save
service iptables restart
Then set your client machines' default gateway address to the address of eth0 (or whatever your wired network is) of the server
 
1 members found this post helpful.
Old 01-02-2014, 07:04 PM   #3
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
this is what i do:
http://www.linuxquestions.org/questi...6/#post3804866
 
Old 01-02-2014, 07:52 PM   #4
baronobeefdip
Senior Member
 
Registered: Jul 2009
Distribution: Debian Squeeze
Posts: 1,267

Original Poster
Rep: Reputation: 32
Just to make things clear just so I know I am getting the information right. This is going to allow my machine to receive internet connection wirelessly and then route the traffic to the ethernet port on the machine I am playing with. Plus I am having some trouble with the DHCP server at the moment but that is for another thread.

by the way , I did enable forwarding in the kernel but then I ran the command that you told me to run in the post you posted and got these errors.
Code:
error: "net.bridge.bridge-nf-call-ip6tables" is an unknown key
error: "net.bridge.bridge-nf-call-iptables" is an unknown key
error: "net.bridge.bridge-nf-call-arptables" is an unknown key
And here is the configuration files for each of the interfaces.
ifcfg-eth0
Code:
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
NETWORK=10.0.0.0
NETMASK=255.255.255.0
IPADDR=10.0.0.1
ifcfg-wlan0
Code:
DEVICE=wlan0
BOOTPROTO=dhcp
ONBOOT=yes
dhcpd.conf
Code:
option domain-name "baronobeefdip.josh";
option domain-name-servers 10.0.0.1, 8.8.8.8;
subnet 10.0.0.0 netmask 255.255.255.0 {
range 10.0.0.2 10.0.0.254;
option routers 10.0.0.1;
option broadcast-address 10.0.0.255;
}

Last edited by baronobeefdip; 01-02-2014 at 07:55 PM.
 
Old 01-02-2014, 08:17 PM   #5
baronobeefdip
Senior Member
 
Registered: Jul 2009
Distribution: Debian Squeeze
Posts: 1,267

Original Poster
Rep: Reputation: 32
UPDATE:

My DHCP server it working, Now I just need to get the routing portion of everything working. I ran the commands that were inside of the code box with regards to iptables.
Code:
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
I connected to the machine through the ethernet port and DHCP caught an IP like it should but then I tried to nslookup google and it returned an error. Something still isn't working here. What do you think it is? My guess is this error
Code:
error: "net.bridge.bridge-nf-call-ip6tables" is an unknown key
error: "net.bridge.bridge-nf-call-iptables" is an unknown key
error: "net.bridge.bridge-nf-call-arptables" is an unknown key
What causes these errors. I know it's a redhat thing but I want to know if this is an issue with the routing rules in iptables.

Last edited by baronobeefdip; 01-02-2014 at 08:26 PM.
 
Old 01-02-2014, 09:11 PM   #6
baronobeefdip
Senior Member
 
Registered: Jul 2009
Distribution: Debian Squeeze
Posts: 1,267

Original Poster
Rep: Reputation: 32
I just got everything working. I went by the iptables rules at this link
http://www.yolinux.com/TUTORIALS/Lin...rkGateway.html
 
Old 01-07-2014, 07:49 PM   #7
baronobeefdip
Senior Member
 
Registered: Jul 2009
Distribution: Debian Squeeze
Posts: 1,267

Original Poster
Rep: Reputation: 32
One last thing I want to know here, Can I do this without turning the computer into a router? I know that using the rule
Code:
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
Will turn it into a router. It's creating a seperate broadcast domain which I don't want. I want to make it to where the clients connected to the ethernet interface could be a part of the same broadcast domain coming from the wireless router in the house. I don't want to turn this machine into a router because I want the entire network of clients connected to it to be part of the same broadcast domain as everyone else.
I thought about doing some experimentation with this so I made these rules
Code:
iptables -A FORWARD -i eth0 -j ACCEPT
iptables -A FORWARD -o eth0 -j ACCEPT
iptables -A FORWARD -i wlan0 -j ACCEPT
iptables -A FORWARD -o wlan0 -j ACCEPT
And when I tried to make the eth0 interface obtain an IP address from the router it did't get one. the wlan0 interface has an IP address and forwarding is enabled but I don't know how to make eth0 get an IP address from the router. Can someone help me with this one. I am understanding the relavance of the FORWARD chain and most of the chains in the nat table but the nat table seems to be creating a router and not a bridge so that the clients attached to it can join the same broadcast domain as the ones connected to the router that the machine is wirelessly connected to.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the easiest way to share wired connection with wireless in ubuntu 11.10? depam Linux - Networking 3 01-29-2012 10:40 PM
[SOLVED] dhcp-server + iptables: Can't share ppp internet connection viniciusmassuchetto Linux - Networking 3 08-22-2011 06:29 AM
Take a larger share of wireless connection the_mulletator Linux - Networking 1 06-08-2008 07:44 PM
searching samba share breaks connection to share Elomis Linux - Server 1 05-11-2007 12:28 AM
Distro to allow me to share wireless connection? Winter Knight Linux - Wireless Networking 1 06-01-2006 02:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration