Difference between revisions of "IPv6 Kernel: Bagaimana mengakses /proc-filesystem"

From OnnoWiki
Jump to navigation Jump to search
(New page: 11.1. How to access the /proc-filesystem 11.1.1. Using “cat” and “echo” Using “cat” and “echo” is the simplest way to access the /proc filesystem, but some requirements ar...)
 
Line 2: Line 2:
 
11.1.1. Using “cat” and “echo”
 
11.1.1. Using “cat” and “echo”
  
Using “cat” and “echo” is the simplest way to access the /proc filesystem, but some requirements are needed for that
+
Menggunakan “cat” dan “echo” adalah cara yang paling sederhana untuk mengakses filesistem /proc, akan tetapi beberapa pra-syarat dibutuhkan agar itu bisa dilakukan,
  
    The /proc-filesystem had to be enabled in kernel, means on compiling following switch has to be set
+
* Filesistem /proc harus di enable di kernel, oleh karenanya waktu compile harus di set agar
  
CONFIG_PROC_FS=y
+
CONFIG_PROC_FS=y
  
    The /proc-filesystem was mounted before, which can be tested using
+
* Filesistem /proc harus di mount sebelumnya, dapat di test menggunakan
  
# mount | grep "type proc"
+
# mount | grep "type proc"
none on /proc type proc (rw)
+
proc on /proc type proc (rw,noexec,nosuid,nodev)
 +
 
 +
* Kita perlu ijin untuk read, dan kadang-kadang write (biasanya hanya root) ke filesistem /proc
 +
 
 +
Biasanya, hanya /proc/sys/* yang bisa di write, sementara lainnya biasanya readonly dan hanya bisa di baca informasinya saja.
  
    You need read and sometimes also write access (normally root only) to the /proc-filesystem
 
  
Normally, only entries in /proc/sys/* are writable, the others are readonly and for information retrieving only.
 
 
11.1.1.1. Retrieving a value
 
11.1.1.1. Retrieving a value
  
 
The value of an entry can be retrieved using “cat”:
 
The value of an entry can be retrieved using “cat”:
  
# cat /proc/sys/net/ipv6/conf/all/forwarding
+
# cat /proc/sys/net/ipv6/conf/all/forwarding
0
+
0
  
 
11.1.1.2. Setting a value
 
11.1.1.2. Setting a value
Line 27: Line 29:
 
A new value can be set (if entry is writable) using “echo”:
 
A new value can be set (if entry is writable) using “echo”:
  
# echo "1" >/proc/sys/net/ipv6/conf/all/forwarding
+
# echo "1" >/proc/sys/net/ipv6/conf/all/forwarding
  
 
11.1.2. Using “sysctl”
 
11.1.2. Using “sysctl”
Line 37: Line 39:
 
     The sysctl-interface had to be enabled in kernel, means on compiling following switch has to be set
 
     The sysctl-interface had to be enabled in kernel, means on compiling following switch has to be set
  
CONFIG_SYSCTL=y
+
CONFIG_SYSCTL=y
  
 
11.1.2.1. Retrieving a value
 
11.1.2.1. Retrieving a value
Line 43: Line 45:
 
The value of an entry can be retrieved now:
 
The value of an entry can be retrieved now:
  
# sysctl net.ipv6.conf.all.forwarding
+
# sysctl net.ipv6.conf.all.forwarding
net.ipv6.conf.all.forwarding = 0
+
net.ipv6.conf.all.forwarding = 0
  
 
11.1.2.2. Setting a value
 
11.1.2.2. Setting a value
Line 50: Line 52:
 
A new value can be set (if entry is writable):
 
A new value can be set (if entry is writable):
  
# sysctl -w net.ipv6.conf.all.forwarding=1
+
# sysctl -w net.ipv6.conf.all.forwarding=1
net.ipv6.conf.all.forwarding = 1
+
net.ipv6.conf.all.forwarding = 1
  
 
Note: Don't use spaces around the “=” on setting values. Also on multiple values per line, quote them like e.g.
 
Note: Don't use spaces around the “=” on setting values. Also on multiple values per line, quote them like e.g.
  
# sysctl -w net.ipv4.ip_local_port_range="32768 61000"
+
# sysctl -w net.ipv4.ip_local_port_range="32768 61000"
net.ipv4.ip_local_port_range = 32768 61000
+
net.ipv4.ip_local_port_range = 32768 61000
  
 
11.1.2.3. Additionals
 
11.1.2.3. Additionals

Revision as of 11:18, 27 May 2013

11.1. How to access the /proc-filesystem 11.1.1. Using “cat” and “echo”

Menggunakan “cat” dan “echo” adalah cara yang paling sederhana untuk mengakses filesistem /proc, akan tetapi beberapa pra-syarat dibutuhkan agar itu bisa dilakukan,

  • Filesistem /proc harus di enable di kernel, oleh karenanya waktu compile harus di set agar
CONFIG_PROC_FS=y
  • Filesistem /proc harus di mount sebelumnya, dapat di test menggunakan
# mount | grep "type proc"
proc on /proc type proc (rw,noexec,nosuid,nodev)
  • Kita perlu ijin untuk read, dan kadang-kadang write (biasanya hanya root) ke filesistem /proc

Biasanya, hanya /proc/sys/* yang bisa di write, sementara lainnya biasanya readonly dan hanya bisa di baca informasinya saja.


11.1.1.1. Retrieving a value

The value of an entry can be retrieved using “cat”:

# cat /proc/sys/net/ipv6/conf/all/forwarding
0

11.1.1.2. Setting a value

A new value can be set (if entry is writable) using “echo”:

# echo "1" >/proc/sys/net/ipv6/conf/all/forwarding

11.1.2. Using “sysctl”

Using the “sysctl” program to access the kernel switches is a modern method today. You can use it also, if the /proc-filesystem isn't mounted. But you have only access to /proc/sys/*!

The program “sysctl” is included in package “procps” (on Red Hat Linux systems).

   The sysctl-interface had to be enabled in kernel, means on compiling following switch has to be set
CONFIG_SYSCTL=y

11.1.2.1. Retrieving a value

The value of an entry can be retrieved now:

# sysctl net.ipv6.conf.all.forwarding
net.ipv6.conf.all.forwarding = 0

11.1.2.2. Setting a value

A new value can be set (if entry is writable):

# sysctl -w net.ipv6.conf.all.forwarding=1
net.ipv6.conf.all.forwarding = 1

Note: Don't use spaces around the “=” on setting values. Also on multiple values per line, quote them like e.g.

# sysctl -w net.ipv4.ip_local_port_range="32768 61000"
net.ipv4.ip_local_port_range = 32768 61000

11.1.2.3. Additionals

Note: There are sysctl versions in the wild which displaying “/” instead of the “.”

For more details take a look into sysctl's manpage.

Hint: for digging fast into the settings, use the option “-a” (display all entries) in conjunction with “grep”. 11.1.3. Values found in /proc-filesystems

There are several formats seen in /proc-filesystem:

   BOOLEAN: simple a “0” (false) or a “1” (true)
   INTEGER: an integer value, can be unsigned, too
   more sophisticated lines with several values: sometimes a header line is displayed also, if not, have a look into the kernel source to retrieve information about the meaning of each value...