📄 sockd.conf.5
字号:
.TH SOCKD.CONF 5 "February 9, 1994".SH NAMEsockd.conf \- SOCKS server configuration file.SH SYNOPSIS\fB/etc/sockd.conf\fP.SH DESCRIPTIONThe file \fB/etc/sockd.conf\fP is used to control accessto SOCKS proxy server \fIsockd\fR and its services. (See \fIsockd\fP(8).)Permission and denial of a servicerequest can be decided based on various combinations of the requestinghost, the destination host, the type of service (destination port number),as well as the requesting user. A line in \fB/etc/sockd.conf\fP can beup to 1023 characters long. Each line may contain the following fieldsin the indicated order:.in +1\fIaction [\fB?=\fIuse_identd] [\fB*=\fIuserlist] src_addr src_mask [dst_addr dst_mask] [op dst_port] [ : shell_cmd ]\fR.in -1Spaces and tabs separate the fields. Fields enclosed in square bracketsare optional. Blanklines are allowed. Except for lines that start with \fB#NO_IDENTD:\fP or\fB#BAD_ID:\fP, everything from the first appearance of \fB#\fP tothe end of the line is considered comment and thus ignored by \fIsockd\fPduring normal validation.The \fIaction\fR fieldmust be either \fBpermit\fP or \fBdeny\fPand indicates the action to be taken if a request matches the conditionsspecified in that line. The \fIuse_identd\fR field, when present, must be \fBI\fP, \fBi\fP, or\fBn\fP, and is used to specify whether \fIidentd\fR verification should beemployed for the current line. \fB?=I\fP demands the use of\fIidentd\fR for verifying the user's identity, denying access if connection to client's \fIidentd\fR fails or if the result does not match the user-idreported by the client program. \fB?=i\fP also specifies the use of\fIidentd\fR, but denies access only if client's \fIidentd\fR reports a user-iddifferent from what the client program claims. \fB?=n\fP turns off theuse of \fIidentd\fP. For the line in which these fields are used, theyoverride the global \fIidentd\fR setting, which is determined by options\fB-I\fP and \fB-i\fP on the \fIsockd\fR command line.The \fIuserlist\fR field, when present, consists ofone or more user-ids or filenames, with comma as separator. No spacesor tabs are allowed in the list. The user-ids should be ids of users on therequesting host, not those on the destination host or the SOCKS server host.The filenames must be full pathnames with the leading \fB/\fP. Insidethe specified files, user-ids may be listed one or several per line,with any combination of blanks, tabs, and commas as separators. Theappearance of \fB#\fP marks the remainder of the line as comment. Eachline in the files may be up to 1023 characters long.If the \fB*=\fIuserlist\fR field is omitted, the line applies to all user-ids.The \fIsrc_addr\fR and \fIdst_addr\fR fields specify IP addressesof hosts, networks, or subnets in the usual dotted form, e.g.,\fB129.201.4.0\fP. The \fIsrc_mask\fR and \fIdst_mask\fR fieldsare masks for the corresponding IP addresses. Bits in these masks that are set to 0 indicate the bit positionsto be ignored during comparisons of IP addresses.So, specifying 255.255.255.255 in the mask demands an exact match with thespecified IP address field, whereas 0.0.0.0 in the maskcauses a match no matter what IP address is specified. (NOTE: This is thesame way netmasks are usually interpreted, and is the opposite of theinterpretation in previous versions of \fIsockd\fP.) If the\fIdst_addr dst_mask\fP pair is omitted, the line applies to alldestination hosts.The \fIop\fR field must be\fBeq\fP, \fBneq\fP, \fBlt\fP, \fBgt\fP, \fBle\fP, or \fBge\fP,for the condition of equal, not equal, less than, greater than,less than or equal, and greater than or equal, respectively.The \fIdst_port\fR field can be either a port number, e.g., 23,or the equivalent service name as specified in the file /etc/services,e.g., \fBtelnet\fP for port number 23. If this pair is omitted, theline applies to all services, i.e., all destination port numbers.For example, consider the line.in +1permit *=root,clivep 128.103.4.10 255.255.255.255 179.200.20.0 255.255.255.0 le 1023.in -1To match the conditions indicated in this line, a request must comefrom a user named 'root' or 'clivep' on the host whose IP address is128.103.4.10 exactly, the destination host must have 179.200.20 in thefirst three bytes of its IP address (the last bytedoesn't matter), and the service must use a port numberless than or equal to 1023 on the destination host. Since the \fIaction\fRfield is \fBpermit\fP, such requests will be granted.When a request is received by \fIsockd\fR, it checks against the linesin file \fB/etc/sockd.conf\fP, one line at a time. Once it finds a linewith conditions that are matched by the request, the request is eithergranted or denied based on the \fIaction\fR field of that line. Theremaining lines of file \fB/etc/sockd.conf\fP are skipped. If no matchingline is found in the entire file, the request is denied.Be very careful how you order the lines in file \fB/etc/sockd.conf\fP.The following two lines in the indicated order.nf.in +1deny *=abxyz 128.140.13.24 0.0.0.0permit 128.140.13.24 0.0.0.0.fi.in -1disallow all requests by user 'abxyz' from host 128.140.13.24, butallow all requests by other users from the same host. Switch the orderof the two lines and even requests by user 'abxyz' are granted.The \fIshell_cmd\fR field specifies a command string that is executedwhen the conditions on that line are satisfied. The following substitutionsoccur before the string is presented to the Borne shell for execution:.nf.in +1%A -- replaced by the client host's domainname if known, by its IP address otherwise%a -- replaced by the client host's IP address%c -- replaced by "connect" or "bind", the command \fIsockd\fP is asked to execute%p -- replaced by the process id of \fIsockd\fP%S -- replaced by the service name (e.g., ftp) if known, by the destination port number otherwise%s -- replaced by the destination port number%U -- replaced by the user-id reported by \fIidentd\fP%u -- replaced by the user-id reported by the client program%Z -- replaced by the destination host's domainname if known, by its IP address otherwise%z -- replaced by the destination host's IP address%% -- replaced by a single %.fi.in -1Several shell commands can be strung together in the usual way. For example,.nf.in +1/usr/ucb/finger @%A | /usr/ucb/mail -s 'SOCKS: rejected %u@%A to %Z (%S)' root root@%A.in -1.fiwill \fIfinger\fP the client host and pipe the result into an email messagefor superusers at the server host and the client host with an appropriateSubject line. Most often this feature is used with a \fBdeny\fP line, butit can be used with \fBpermit\fP also.Although there is an implied 'deny all' at the end of the configuration file,you may supply one explicitly so as to take some specific action when requestsare so rejected, e.g., (in one continuous line),.nf.in +1deny 0.0.0.0 0.0.0.0 : /usr/ucb/finger @%A | /usr/ucb/mail -s 'SOCKS: rejected %u@%A to %Z (%S)' root root@%A.fi.in -1You may also specify in \fB/etc/sockd.conf\fP commands to be executed when\fIsockd\fP cannot connect to client's \fIidentd\fP or when the user-idsreported by the client programs and the client's \fIidentd\fP do not match.These special entries must have \fB#NO_IDENTD:\fP and \fB#BAD_ID:\fP at the verybeginning of the line, followed by the shell commands to be executed. Forexample:.nf.in +1#NO_IDENTD: /usr/ucb/mail -s 'Please run identd on host %A' root@%A#BAD_ID: finger @%A | /usr/ucb/mail -s '%U pretends to be %u on %A' root root@%A.fi.in -1A program called \fItest_sockd_conf\fP is provided for you to checkyour \fIsockd\fR configuration file. Be sure to use it every time afteryou modify the configuration file. See \fItest_sockd_conf\fP(8).Strictly speaking, \fIsockd\fP has no concept of inside/outside, itdoes know which is the requesting host and which the destinationand that is the basis of its access control. Therefore it can be usedto facilitateaccess from outside world into your internal networks as well. Needless tosay, you have to take extreme caution if you choose to do so. If youdon't need that kind of access, it is recommended that you specificallydeny such connections in \fBsockd.conf\fR. For example, if the Class Bnetwork 129.1 is your internal network, use.nf.in +1deny 0.0.0.0 0.0.0.0 129.1.0.0 255.255.0.0.fi.in -1as the first line of your \fBsockd.conf\fP to protect your inside hostsfrom all attempts of access from the outside world through SOCKS..SH SEE ALSO\fIsockd\fP(8), \fIsockd.route\fP(5), \fItest_sockd_conf\fP(8),\fIsocks.conf\fP(5), \fIsocks_clients\fP(1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -