LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   nat not working, cannot change /proc/sys/net/ipv4/ip_forward (https://www.linuxquestions.org/questions/linux-networking-3/nat-not-working-cannot-change-proc-sys-net-ipv4-ip_forward-453236/)

70k51k 06-09-2006 03:04 PM

nat not working, cannot change /proc/sys/net/ipv4/ip_forward
 
I am using ubuntu server v5.10. I have followed their instructions at http://help.ubuntu.com/6.06/ubuntu/s...iguration.html without luck, I also tried the instructions at http://www.gentoo.org/doc/en/home-router-howto.xml. This website mentioned that I need to change /proc/sys/net/ipv4/ip_forward from a 0 to a 1 so the kernel knows forwarding is ok. I am unable to do this, if I try their little echo code, it tells me I do not have permission, and if I straight up try to "sudo vi" the document and change it myself, it says that the document has changed since I opened it up and gives me an fsync error. Anyone have any ideas? do I need to disable one of the interfaces before I try to make this change?

gilead 06-09-2006 03:52 PM

Have you tried sudo echo 1 > /proc/sys/net/ipv4/ip_forward - that should allow you to turn IP forwarding on. Make sure that no editors are open with /etc/sysctl.conf in them before running sudo vi /etc/sysctl.conf then you should be able to add the line net.ipv4.ip_forward = 1 (and any others).

70k51k 06-09-2006 04:08 PM

I tried that, it ends up like this:

ben@ubuntu:~$ sudo echo 1 > /proc/sys/net/ipv4/ip_forward
-bash: /proc/sys/net/ipv4/ip_forward: Permission denied

I thought that by using sudo, I wouldn't be denied access to anything, so I am thinking that maybe there is a program open that is using that document. When I type in ps -d, I get the following output.

PID TTY TIME CMD
1 ? 00:00:01 init
2 ? 00:00:00 ksoftirqd/0
3 ? 00:00:00 events/0
4 ? 00:00:00 khelper
5 ? 00:00:00 kthread
7 ? 00:00:00 kacpid
54 ? 00:00:00 kblockd/0
78 ? 00:00:00 pdflush
79 ? 00:00:00 pdflush
81 ? 00:00:00 aio/0
80 ? 00:00:00 kswapd0
666 ? 00:00:00 kseriod
1723 ? 00:00:00 khubd
2766 ? 00:00:00 kjournald
5295 tty1 00:00:00 bash
5448 ? 00:00:00 sshd
5460 pts/0 00:00:00 ps

Anything on there that looks like I need to kill? Even if I restart, before I do anything else, I am not able to edit that file.

osor 06-09-2006 04:23 PM

How about su and then echo 1 > /proc/...?

Maybe sudo isn't configured correctly.

gilead 06-10-2006 03:12 PM

Unless you already have an editor open, it sounds like osor is correct in that sudo is probably configured incorrectly. There's nothing unusual about the list of processes you have - and nothing to suggest another editor is running.

Can you let us know whether using su works?

osor 06-10-2006 07:34 PM

You might also try
Code:

(sudo) sysctl -w net.ipv4.ip_forward=1

70k51k 06-12-2006 10:37 AM

sudo was configured incorrectly. I enabled the root account, and tried the command while logged in as root, that fixed it. Thank y'all very much!

Nevro 12-04-2006 10:16 AM

Actually, in
Code:

sudo echo 1 > /proc/sys/net/ipv4/ip_forward
only "echo 1" part is run as root. "> file" is still interpreted by user's shell. One could use:
Code:

echo 1|sudo tee /proc/sys/net/ipv4/ip_forward
Or if you have access to shells from sudo:
Code:

sudo bash -c "echo 1 > /proc/sys/net/ipv4/ip_forward"


All times are GMT -5. The time now is 09:08 PM.