Link to home
Start Free TrialLog in
Avatar of re-searcher
re-searcherFlag for United States of America

asked on

how to edit files Linux (Ubuntu Distr.)

Hello,
In my Linux Server some file not editable or when i edit them after reboot it's back to it previous version.

for example for /etc/ufw/ufw.conf I edit "enable=no" to "enable=yes" and saved it, but after reboot when I print ufw.conf's contents it's back to previous version.
I found a way for this, i change file permission to 755 and edit with root permission and it's not back to previous version.

after it new problem occur for me. I want to edit "/proc/sys/net/ipv4/ip_forward" but it's back to previous version after each reboot. i trying to set permission and receive following error:
root@testserver:/proc/sys/net/ipv4# chmod 755 ip_forward
chmod: changing permissions of `ip_forward': Operation not permitted

Open in new window


using chattr but it's not work and i received following error:
root@testserver:/proc/sys/net/ipv4# chattr +a ip_forward
chattr: Inappropriate ioctl for device while reading flags on ip_forward

Open in new window


Whould you mind help me?!
Avatar of kerimit
kerimit

you must run command as administrator user. example in linux ubuntu "sudo chmod 755 ip_forward". That will run as administrator user can modify system.

I Hope solved your problem
I'm glad Ubuntu prevents you from doing those things :)

Edit /etc/sysctl.conf, and add the following
net.ipv4.ip_forward = 0

Open in new window

then
sudo sysctl -p

Open in new window


If you want to enable forwarding, change the value to 1.
Doing so will make the change persistent across reboots.
To clarify on my answer,

Edit sysctl.conf to make sysctl changes persistent.
'sysctl -p' reads in /etc/sysctl.conf and makes your edit live on the system before a reboot.

If there is already a value present for the token you want to change, edit that instead of creating a new entry.
Avatar of re-searcher

ASKER

# kerimit
I run those commands with root privillage, first i run "sudo bash" and then run command you can see root username before @

# Papertrip
Thank, but i don't want to set ip_forwarding from /etc/sysctl.conf
I know this way, I just wanna know how it's possible we edit "/proc/sys/net/ipv4/ip_forward" in one of war games i saw it.

and my next question is  I run "ufw enable" command and enable UFW for run at boot, but after reboot i checked "ufw status" and received "inactive" why?
I know this way, I just wanna know how it's possible we edit "/proc/sys/net/ipv4/ip_forward" in one of war games i saw it.
[root@broken tmp]# cat /proc/sys/net/ipv4/ip_forward
0
[root@broken tmp]# echo "1" > /proc/sys/net/ipv4/ip_forward
[root@broken tmp]# cat /proc/sys/net/ipv4/ip_forward
1

Open in new window


# Papertrip

I do it before, but as I said in my question, after reboot ip_forward's content back to previous version (from 1 to 0)
I do it before, but as I said in my question, after reboot ip_forward's content back to previous version (from 1 to 0)
As I said in my previous answers, edit sysctl.conf to make it persistent across reboots.
and my next question is  I run "ufw enable" command and enable UFW for run at boot, but after reboot i checked "ufw status" and received "inactive" why?
Is iptables running?
# Papertrip
Is iptables running?

I read in Ubuntu which ufw is back-end of iptables and will make iptables management easier.

currently my problem is I create PPTP Server and everythings ok, i could connect to server and i can ping myself (192.168.1.2) from server and server( 192.168.1.1) from client.
but i can browser internet after connection established.
I don't think ufw is supposed to be "started" at boot... it's not a service, it's just a frontend tool to configure iptables.  When you need to use ufw, just enable it first and go about your business.
currently my problem is I create PPTP Server and everythings ok, i could connect to server and i can ping myself (192.168.1.2) from server and server( 192.168.1.1) from client.
but i can browser internet after connection established.

Ok well that is quite a different issue than your original question :)
My Server is Ubuntu which I install eBox Zentyal on That.

I do as you said on post #37074819
but after i reboot server sysctl -p return ipforwarding = 1 and /proc/sys/net/ipv4/ip_forwarding is zero 0
Ok well that is quite a different issue than your original question :)

I will Open new post after my ipv4_forwarding proble solved.
Would you mind help me on pptp routing?
but after i reboot server sysctl -p return ipforwarding = 1 and /proc/sys/net/ipv4/ip_forwarding is zero 0
Paste the output of the following command:
grep ip_forward /etc/sysctl.conf

Open in new window

I will Open new post after my ipv4_forwarding proble solved.
Sounds good.

Would you mind help me on pptp routing?
I'm I'm still awake :p
I'm I'm still awake :p

Err that should be "If I'm still awake" ... can you tell I'm already half asleep?
Paste the output of the following command:
root@testserver:~# grep ip_forward /etc/sysctl.conf
net.ipv4.ip_forward=1

Open in new window

Something isn't right here...

Paste the following as well please to make sure we are on the same page.
cat /proc/sys/net/ipv4/ip_forward
sysctl net.ipv4.ip_forward
cat /etc/network/options
grep forward /etc/rc.local

Open in new window

root@testserver:/etc# cd /proc/sys/net/ipv4/
root@testserver:/proc/sys/net/ipv4# sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 0
root@testserver:/proc/sys/net/ipv4# cat /etc/network/options
cat: /etc/network/options: No such file or directory
root@testserver:/proc/sys/net/ipv4# grep forward /etc/rc.local
root@testserver:/proc/sys/net/ipv4# 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Papertrip
Papertrip
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
#Papertrip

Thanks, I do like this and reboot server and /proc/sys/net/ipv4/ip_forwarding is set to 1


for other values i should do like this?


would you mind explain what sysctl -w do?
That is weird that it didn't work before.

-w takes a sysctl setting and changes the value to what you specify.

       sysctl [-n] [-e] [-q] -w variable=value ...
       -w     Use this option when you want to change a sysctl setting.

Open in new window


So the change works now across reboots?  Are you all set?
for other values i should do like this?

Whatever you did to make it work this time, do it for your future changes :)
#/proc/sys/net/ipv4/ip_forward
0

Open in new window


sorry Papertrip it's return back to 0 again.
but i read some where else /proc/* will return back on each reboot

https://www.experts-exchange.com/questions/27429200/routing-traffic-through-linux-PPTP-server.html?anchorAnswerId=37075092#a37075092