LinuxQuestions.org
Visit Jeremy's Blog.
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 11-18-2013, 07:58 PM   #1
jenia
LQ Newbie
 
Registered: Nov 2013
Posts: 1

Rep: Reputation: Disabled
DHCP server, gateway problems


Hello everyone.

I want to create a gateway out of my laptop and connect it to a Beaglebone Black. The goal is to ssh into the Beagle and also to connect the Beagle to the net.

Laptop:
What i did is create a DHCP server on the network 192.168.0.0/24 using the interface card eth0
On wlan0 i have my wifi connection to the LAN router at 192.168.1.1

Now i tried to write a routing script, on my laptop, to route the packets from eth0 to wlan0 but it didnt work: "bad argument eth0".
# Always accept loopback traffic
iptables -A INPUT -i lo -j ACCEPT


# Allow established connections, and those not coming from the outside
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -m state --state NEW -i ! eth0 -j ACCEPT
iptables -A FORWARD -i eth0 -o wlan0 -m state --state ESTABLISHED,RELATED -j ACCEPT

# Allow outgoing connections from the LAN side.
iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT

# Masquerade.
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

# Don't forward from the outside to the inside.
iptables -A FORWARD -i eth0 -o wlan0 -j REJECT

I also set the kernel to forward the packets like this
emacs /etc/sysctl.conf
net.ipv4.ip_forward=1 //i uncommented this line in the sample file

Can anyone tell me what am i doing wrong?
Why can is the iptables giving me this error and also am I going about this in a correct way?

Thanks in advance.
Jenia
 
Old 11-19-2013, 02:29 PM   #2
baldur_1
Member
 
Registered: Sep 2010
Posts: 277

Rep: Reputation: 28
Well, one thing i noticed is you have an errant exclamation point in your commands.

iptables -A INPUT -m state --state NEW -i ! eth0 -j ACCEPT

i am not sure if that is just a typo but i dont think the exclamation point should be there and that probably would cause the error you were experiencing.

i also think you have the same line twice.

# Allow outgoing connections from the LAN side.
iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT

# Don't forward from the outside to the inside.
iptables -A FORWARD -i eth0 -o wlan0 -j REJECT

that would not cause an error but is conflicting code.

also, one last thing, if you are using this as a script for the firewall controls, it would be a good idea with starting by flushing all rules prioir to yours. it might not cause a problem and usually doesnt but it is usually a good idea.

one thing i would suggest is switching to shorewall for your firewall. once you sit down and look at it, it is A LOT easier to configure and is just a secure.
 
Old 11-20-2013, 05:52 AM   #3
sharanksd
LQ Newbie
 
Registered: Oct 2012
Posts: 3

Rep: Reputation: Disabled
Smile DHCP server, gateway problems

Accept all traffic from eth0.
i.e iptables -I INPUT -i eth0 -j ACCEPT

Thanks
Sharan
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
configuration of DHCP server in windows server 2003 with GateWay danyee22 Linux - Newbie 5 03-04-2009 06:17 PM
DHCP, gateway and name server information linux_money Linux - Wireless Networking 0 08-08-2006 04:14 PM
Help in setting up Gateway, DHCP and DNS Server depam Linux - Software 1 10-06-2005 12:52 PM
DHCP, Gateway and DNS server depam Linux - Networking 3 10-05-2005 08:33 PM
Setting up a gateway/dhcp server. chaosego Linux - Wireless Networking 33 09-26-2004 08:50 AM

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

All times are GMT -5. The time now is 10:23 PM.

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