免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2712 | 回复: 6

[网络管理] 限制进程访问网络 [复制链接]

论坛徽章:
0
发表于 2017-03-01 14:08 |显示全部楼层
各位:

使用iptables可以禁止IP,端口或者某个协议访问网络,
如果我想禁止某个进程使用网络该如何配置呢?

论坛徽章:
3
水瓶座
日期:2013-08-19 19:03:1715-16赛季CBA联赛之八一
日期:2016-02-25 18:02:4715-16赛季CBA联赛之佛山
日期:2017-03-27 14:08:12
发表于 2017-03-02 15:51 |显示全部楼层
如果你编译内核的时候选择了 CONFIG_IP_NF_MATCH_OWNER 那可以用iptables 指定拒绝(允许)某一命令访问网络。
比如要阻止firefox命令那可以用下面的命令
iptables -A OUTPUT -m owner --cmd-owner firefox -j DROP

论坛徽章:
0
发表于 2017-03-03 09:20 |显示全部楼层
回复 2# 2008ohmygod

内核里没看到这个选型啊
CONFIG_IP_NF_MATCH_OWNER

论坛徽章:
3
水瓶座
日期:2013-08-19 19:03:1715-16赛季CBA联赛之八一
日期:2016-02-25 18:02:4715-16赛季CBA联赛之佛山
日期:2017-03-27 14:08:12
发表于 2017-03-17 13:45 |显示全部楼层
回复 3# whpu000625

iptables -m owner --help


什么提示?

论坛徽章:
154
2022北京冬奥会纪念版徽章
日期:2015-08-07 17:10:5720周年集字徽章-年
日期:2022-10-26 16:44:2015-16赛季CBA联赛之深圳
日期:2022-11-02 14:02:4515-16赛季CBA联赛之八一
日期:2022-11-28 12:07:4820周年集字徽章-20	
日期:2023-07-19 08:49:4515-16赛季CBA联赛之八一
日期:2023-11-04 19:23:5115-16赛季CBA联赛之广夏
日期:2023-12-13 18:09:34
发表于 2017-03-20 15:34 来自手机 |显示全部楼层
肯定有,对版本有要求么

论坛徽章:
0
发表于 2017-04-09 11:23 |显示全部楼层
回复 4# 2008ohmygod

  1. Usage: iptables -[ACD] chain rule-specification [options]
  2.        iptables -I chain [rulenum] rule-specification [options]
  3.        iptables -R chain rulenum rule-specification [options]
  4.        iptables -D chain rulenum [options]
  5.        iptables -[LS] [chain [rulenum]] [options]
  6.        iptables -[FZ] [chain] [options]
  7.        iptables -[NX] chain
  8.        iptables -E old-chain-name new-chain-name
  9.        iptables -P chain target [options]
  10.        iptables -h (print this help information)

  11. Commands:
  12. Either long or short options are allowed.
  13.   --append  -A chain            Append to chain
  14.   --check   -C chain            Check for the existence of a rule
  15.   --delete  -D chain            Delete matching rule from chain
  16.   --delete  -D chain rulenum
  17.                                 Delete rule rulenum (1 = first) from chain
  18.   --insert  -I chain [rulenum]
  19.                                 Insert in chain as rulenum (default 1=first)
  20.   --replace -R chain rulenum
  21.                                 Replace rule rulenum (1 = first) in chain
  22.   --list    -L [chain [rulenum]]
  23.                                 List the rules in a chain or all chains
  24.   --list-rules -S [chain [rulenum]]
  25.                                 Print the rules in a chain or all chains
  26.   --flush   -F [chain]          Delete all rules in  chain or all chains
  27.   --zero    -Z [chain [rulenum]]
  28.                                 Zero counters in chain or all chains
  29.   --new     -N chain            Create a new user-defined chain
  30.   --delete-chain
  31.             -X [chain]          Delete a user-defined chain
  32.   --policy  -P chain target
  33.                                 Change policy on chain to target
  34.   --rename-chain
  35.             -E old-chain new-chain
  36.                                 Change chain name, (moving any references)
  37. Options:
  38.     --ipv4      -4              Nothing (line is ignored by ip6tables-restore)
  39.     --ipv6      -6              Error (line is ignored by iptables-restore)
  40. [!] --protocol  -p proto        protocol: by number or name, eg. `tcp'
  41. [!] --source    -s address[/mask][...]
  42.                                 source specification
  43. [!] --destination -d address[/mask][...]
  44.                                 destination specification
  45. [!] --in-interface -i input name[+]
  46.                                 network interface name ([+] for wildcard)
  47. --jump -j target
  48.                                 target for rule (may load target extension)
  49.   --goto      -g chain
  50.                               jump to chain with no return
  51.   --match       -m match
  52.                                 extended match (may load extension)
  53.   --numeric     -n              numeric output of addresses and ports
  54. [!] --out-interface -o output name[+]
  55.                                 network interface name ([+] for wildcard)
  56.   --table       -t table        table to manipulate (default: `filter')
  57.   --verbose     -v              verbose mode
  58.   --wait        -w [seconds]    wait for the xtables lock
  59.   --line-numbers                print line numbers when listing
  60.   --exact       -x              expand numbers (display exact values)
  61. [!] --fragment  -f              match second or further fragments only
  62.   --modprobe=<command>          try to insert modules using this command
  63.   --set-counters PKTS BYTES     set the counter during insert/append
  64. [!] --version   -V              print package version.

  65. owner match options:
  66. [!] --uid-owner userid[-userid]      Match local UID
  67. [!] --gid-owner groupid[-groupid]    Match local GID
  68. [!] --socket-exists                  Match if socket exists
复制代码

论坛徽章:
0
发表于 2017-04-09 11:23 |显示全部楼层
  1. Usage: iptables -[ACD] chain rule-specification [options]
  2.        iptables -I chain [rulenum] rule-specification [options]
  3.        iptables -R chain rulenum rule-specification [options]
  4.        iptables -D chain rulenum [options]
  5.        iptables -[LS] [chain [rulenum]] [options]
  6.        iptables -[FZ] [chain] [options]
  7.        iptables -[NX] chain
  8.        iptables -E old-chain-name new-chain-name
  9.        iptables -P chain target [options]
  10.        iptables -h (print this help information)

  11. Commands:
  12. Either long or short options are allowed.
  13.   --append  -A chain            Append to chain
  14.   --check   -C chain            Check for the existence of a rule
  15.   --delete  -D chain            Delete matching rule from chain
  16.   --delete  -D chain rulenum
  17.                                 Delete rule rulenum (1 = first) from chain
  18.   --insert  -I chain [rulenum]
  19.                                 Insert in chain as rulenum (default 1=first)
  20.   --replace -R chain rulenum
  21.                                 Replace rule rulenum (1 = first) in chain
  22.   --list    -L [chain [rulenum]]
  23.                                 List the rules in a chain or all chains
  24.   --list-rules -S [chain [rulenum]]
  25.                                 Print the rules in a chain or all chains
  26.   --flush   -F [chain]          Delete all rules in  chain or all chains
  27.   --zero    -Z [chain [rulenum]]
  28.                                 Zero counters in chain or all chains
  29.   --new     -N chain            Create a new user-defined chain
  30.   --delete-chain
  31.             -X [chain]          Delete a user-defined chain
  32.   --policy  -P chain target
  33.                                 Change policy on chain to target
  34.   --rename-chain
  35.             -E old-chain new-chain
  36.                                 Change chain name, (moving any references)
  37. Options:
  38.     --ipv4      -4              Nothing (line is ignored by ip6tables-restore)
  39.     --ipv6      -6              Error (line is ignored by iptables-restore)
  40. [!] --protocol  -p proto        protocol: by number or name, eg. `tcp'
  41. [!] --source    -s address[/mask][...]
  42.                                 source specification
  43. [!] --destination -d address[/mask][...]
  44.                                 destination specification
  45. [!] --in-interface -i input name[+]
  46.                                 network interface name ([+] for wildcard)
  47. --jump -j target
  48.                                 target for rule (may load target extension)
  49.   --goto      -g chain
  50.                               jump to chain with no return
  51.   --match       -m match
  52.                                 extended match (may load extension)
  53.   --numeric     -n              numeric output of addresses and ports
  54. [!] --out-interface -o output name[+]
  55.                                 network interface name ([+] for wildcard)
  56.   --table       -t table        table to manipulate (default: `filter')
  57.   --verbose     -v              verbose mode
  58.   --wait        -w [seconds]    wait for the xtables lock
  59.   --line-numbers                print line numbers when listing
  60.   --exact       -x              expand numbers (display exact values)
  61. [!] --fragment  -f              match second or further fragments only
  62.   --modprobe=<command>          try to insert modules using this command
  63.   --set-counters PKTS BYTES     set the counter during insert/append
  64. [!] --version   -V              print package version.

  65. owner match options:
  66. [!] --uid-owner userid[-userid]      Match local UID
  67. [!] --gid-owner groupid[-groupid]    Match local GID
  68. [!] --socket-exists                  Match if socket exists
复制代码

回复 4# 2008ohmygod


您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP