]> git.proxmox.com Git - mirror_iproute2.git/blame - man/man8/ip-netns.8
update kernel headers based on net-next 3.21
[mirror_iproute2.git] / man / man8 / ip-netns.8
CommitLineData
1e9014a7 1.TH IP\-NETNS 8 "16 Jan 2013" "iproute2" "Linux"
2a9721f1 2.SH NAME
aab2702d 3ip-netns \- process network namespace management
2a9721f1
SH
4.SH SYNOPSIS
5.sp
6.ad l
7.in +8
8.ti -8
9.B ip
10.RI "[ " OPTIONS " ]"
11.B netns
12.RI " { " COMMAND " | "
13.BR help " }"
14.sp
15.ti -8
16.BR "ip netns" " { " list " } "
17
18.ti -8
19.BR "ip netns" " { " add " | " delete " } "
20.I NETNSNAME
21
9a7b3d91
EB
22.ti -8
23.BR "ip netns identify"
0948adc0 24.RI "[ " PID " ]"
9a7b3d91
EB
25
26.ti -8
27.BR "ip netns pids"
28.I NETNSNAME
29
2a9721f1
SH
30.ti -8
31.BR "ip netns exec "
32.I NETNSNAME command ...
33
1e9014a7
EB
34.ti -8
35.BR "ip netns monitor"
36
2a9721f1
SH
37.SH DESCRIPTION
38A network namespace is logically another copy of the network stack,
cc574302 39with its own routes, firewall rules, and network devices.
2a9721f1
SH
40
41By convention a named network namespace is an object at
42.BR "/var/run/netns/" NAME
43that can be opened. The file descriptor resulting from opening
44.BR "/var/run/netns/" NAME
45refers to the specified network namespace. Holding that file
46descriptor open keeps the network namespace alive. The file
47descriptor can be used with the
48.B setns(2)
49system call to change the network namespace associated with a task.
50
49572501
KR
51For applications that are aware of network namespaces, the convention
52is to look for global network configuration files first in
2a9721f1
SH
53.BR "/etc/netns/" NAME "/"
54then in
55.BR "/etc/".
56For example, if you want a different version of
57.BR /etc/resolv.conf
58for a network namespace used to isolate your vpn you would name it
59.BR /etc/netns/myvpn/resolv.conf.
60
61.B ip netns exec
62automates handling of this configuration, file convention for network
63namespace unaware applications, by creating a mount namespace and
64bind mounting all of the per network namespace configure files into
65their traditional location in /etc.
66
61f541fe 67.TP
68.B ip netns list - show all of the named network namespaces
69.sp
1e9014a7
EB
70This command displays all of the network namespaces in /var/run/netns
71
61f541fe 72.TP
73.B ip netns add NAME - create a new named network namespace
74.sp
1e9014a7
EB
75If NAME is available in /var/run/netns/ this command creates a new
76network namespace and assigns NAME.
77
61f541fe 78.TP
79.B ip netns delete NAME - delete the name of a network namespace
80.sp
1e9014a7
EB
81If NAME is present in /var/run/netns it is umounted and the mount
82point is removed. If this is the last user of the network namespace the
83network namespace will be freed, otherwise the network namespace
84persists until it has no more users. ip netns delete may fail if
85the mount point is in use in another mount namespace.
86
61f541fe 87.TP
0948adc0 88.B ip netns identify [PID] - Report network namespaces names for process
61f541fe 89.sp
9a7b3d91 90This command walks through /var/run/netns and finds all the network
0948adc0 91namespace names for network namespace of the specified process, if PID is
92not specified then the current process will be used.
9a7b3d91 93
61f541fe 94.TP
95.B ip netns pids NAME - Report processes in the named network namespace
96.sp
9a7b3d91
EB
97This command walks through proc and finds all of the process who have
98the named network namespace as their primary network namespace.
99
61f541fe 100.TP
101.B ip netns exec NAME cmd ... - Run cmd in the named network namespace
102.sp
1e9014a7
EB
103This command allows applications that are network namespace unaware
104to be run in something other than the default network namespace with
105all of the configuration for the specified network namespace appearing
106in the customary global locations. A network namespace and bind mounts
107are used to move files from their network namespace specific location
108to their default locations without affecting other processes.
109
61f541fe 110.TP
111.B ip netns monitor - Report as network namespace names are added and deleted
112.sp
1e9014a7
EB
113This command watches network namespace name addition and deletion events
114and prints a line for each event it sees.
115
2a9721f1 116.SH EXAMPLES
1e9014a7
EB
117.PP
118ip netns list
119.RS
120Shows the list of current named network namespaces
121.RE
122.PP
123ip netns add vpn
124.RS
125Creates a network namespace and names it vpn
126.RE
127.PP
128ip netns exec vpn ip link set lo up
129.RS
130Bring up the loopback interface in the vpn network namespace.
131.RE
2a9721f1
SH
132
133.SH SEE ALSO
134.br
135.BR ip (8)
136
137.SH AUTHOR
138Original Manpage by Eric W. Biederman