smithy1155
Posts: 15
Joined: Wed Mar 23, 2016 12:42 pm

Raspberry Pi Access Point Problem

Tue Nov 29, 2016 3:42 pm

Hi,

It's the first time I've tried doing this and all has gone well so far I've been using this https://learn.adafruit.com/setting-up-a ... l-software as a walkthrough guide and it's gone well.

However the problem I have is trying to get an internet connection from the Ethernet port to the WiFi, after doing this code

Code: Select all

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
Which established a connection with no problem at all, but after running this code it then tells you to run:

Code: Select all

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
So you don't have to keep entering the other commands after boot up, but when I enter the above command it's not saving the IP Tables and I have to keep entering the other commands each time to get a connection.

I'm just wondering if anyone has any solutions or had any problems like this?

Many Thanks

User avatar
slashedzero
Posts: 9
Joined: Tue Sep 06, 2016 4:17 am
Location: Sacramento, CA

Re: Raspberry Pi Access Point Problem

Tue Nov 29, 2016 5:07 pm

Are you certain that you actually installed the utility iptables-save ? You can find out by running

Code: Select all

which iptables-save


Additionally, make sure that that file /etc/iptables.ipv4.nat is actually there and has the correct contents for iptables.

smithy1155
Posts: 15
Joined: Wed Mar 23, 2016 12:42 pm

Re: Raspberry Pi Access Point Problem

Tue Nov 29, 2016 8:34 pm

You was right it wasn't in

Code: Select all

/etc/iptables.ipv4.nat
I did the code which you suggested and came back with the response of

Code: Select all

/sbin/iptables-save
I've had a look in the folder and seems everything is in there, so I should be correct in saying the code should actually be now

Code: Select all

sudo sh -c "iptables-save > /sbin/iptables.ipv4.nat"

hortimech
Posts: 419
Joined: Wed Apr 08, 2015 5:52 pm

Re: Raspberry Pi Access Point Problem

Tue Nov 29, 2016 10:10 pm

I don't understand this, you are running this in a terminal on the rpi and you are invoking a shell to run a program and redirecting its output to a file. Why not just run the program directly i.e. sudo iptables-save > /etc/iptables.ipv4.nat

User avatar
DougieLawson
Posts: 38882
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Raspberry Pi Access Point Problem

Tue Nov 29, 2016 10:40 pm

hortimech wrote:I don't understand this, you are running this in a terminal on the rpi and you are invoking a shell to run a program and redirecting its output to a file. Why not just run the program directly i.e. sudo iptables-save > /etc/iptables.ipv4.nat
Because you need to be root to write to /etc. So spawning a root shell makes it all work better.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

hortimech
Posts: 419
Joined: Wed Apr 08, 2015 5:52 pm

Re: Raspberry Pi Access Point Problem

Wed Nov 30, 2016 11:44 am

You still don't need the shell: iptables-save | sudo tee /etc/iptables.ipv4.nat

Rowland

Return to “Networking and servers”