]>
Commit | Line | Data |
---|---|---|
1e9014a7 | 1 | .TH IP\-NETNS 8 "16 Jan 2013" "iproute2" "Linux" |
2a9721f1 | 2 | .SH NAME |
aab2702d | 3 | ip-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 |
38 | A network namespace is logically another copy of the network stack, | |
cc574302 | 39 | with its own routes, firewall rules, and network devices. |
2a9721f1 SH |
40 | |
41 | By convention a named network namespace is an object at | |
42 | .BR "/var/run/netns/" NAME | |
43 | that can be opened. The file descriptor resulting from opening | |
44 | .BR "/var/run/netns/" NAME | |
45 | refers to the specified network namespace. Holding that file | |
46 | descriptor open keeps the network namespace alive. The file | |
47 | descriptor can be used with the | |
48 | .B setns(2) | |
49 | system call to change the network namespace associated with a task. | |
50 | ||
49572501 KR |
51 | For applications that are aware of network namespaces, the convention |
52 | is to look for global network configuration files first in | |
2a9721f1 SH |
53 | .BR "/etc/netns/" NAME "/" |
54 | then in | |
55 | .BR "/etc/". | |
56 | For example, if you want a different version of | |
57 | .BR /etc/resolv.conf | |
58 | for 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 | |
62 | automates handling of this configuration, file convention for network | |
63 | namespace unaware applications, by creating a mount namespace and | |
64 | bind mounting all of the per network namespace configure files into | |
65 | their traditional location in /etc. | |
66 | ||
61f541fe | 67 | .TP |
68 | .B ip netns list - show all of the named network namespaces | |
69 | .sp | |
1e9014a7 EB |
70 | This 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 |
75 | If NAME is available in /var/run/netns/ this command creates a new |
76 | network 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 |
81 | If NAME is present in /var/run/netns it is umounted and the mount |
82 | point is removed. If this is the last user of the network namespace the | |
83 | network namespace will be freed, otherwise the network namespace | |
84 | persists until it has no more users. ip netns delete may fail if | |
85 | the 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 | 90 | This command walks through /var/run/netns and finds all the network |
0948adc0 | 91 | namespace names for network namespace of the specified process, if PID is |
92 | not 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 |
97 | This command walks through proc and finds all of the process who have |
98 | the 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 |
103 | This command allows applications that are network namespace unaware |
104 | to be run in something other than the default network namespace with | |
105 | all of the configuration for the specified network namespace appearing | |
106 | in the customary global locations. A network namespace and bind mounts | |
107 | are used to move files from their network namespace specific location | |
108 | to 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 |
113 | This command watches network namespace name addition and deletion events |
114 | and prints a line for each event it sees. | |
115 | ||
2a9721f1 | 116 | .SH EXAMPLES |
1e9014a7 EB |
117 | .PP |
118 | ip netns list | |
119 | .RS | |
120 | Shows the list of current named network namespaces | |
121 | .RE | |
122 | .PP | |
123 | ip netns add vpn | |
124 | .RS | |
125 | Creates a network namespace and names it vpn | |
126 | .RE | |
127 | .PP | |
128 | ip netns exec vpn ip link set lo up | |
129 | .RS | |
130 | Bring 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 | |
138 | Original Manpage by Eric W. Biederman |