几条命令

归档 运维 Linux 备忘

2013-11-07 00:00 AM

关于 netstat 和 iptables 的用法


  1. sudo netstat -tnlpu | grep pptpd

显示程序名和端口号

-t :显示tcp

-u :显示udp

-n :不反向解析ip

-l :显示监听套接字

-p :显示程序名(需root)

完整用法:

usage: netstat [-vWeenNcCF] [] -r netstat {-V|–version|-h|–help}
netstat [-vWnNcaeol] [ …] netstat { [-vWeenNac] -i | [-cWnNe]
-M | -s }

-r, –route display routing table
-i, –interfaces display interface table
-g, –groups display multicast group memberships
-s, –statistics display networking statistics (like SNMP)
-M, –masquerade display masqueraded connections

-v, –verbose be verbose
-W, –wide don’t truncate IP addresses
-n, –numeric don’t resolve names –numeric-hosts don’t resolve host names –numeric-ports don’t resolve port names –numeric-users don’t
resolve user names
-N, –symbolic resolve hardware names
-e, –extend display other/more information
-p, –programs display PID/Program name for sockets
-c, –continuous continuous listing

-l, –listening display listening server sockets
-a, –all, –listening display all sockets (default: connected)
-o, –timers display timers
-F, –fib display Forwarding Information Base (default)
-C, –cache display routing cache instead of FIB

={-t|–tcp} {-u|–udp} {-w|–raw} {-x|–unix} –ax25 –ipx –netrom
=Use ‘-6|-4’ or ‘-A ’ or ‘–’; default: inet List of
possible address families (which support routing): inet (DARPA
Internet) inet6 (IPv6) ax25 (AMPR AX.25) netrom (AMPR NET/ROM) ipx
(Novell IPX) ddp (Appletalk DDP) x25 (CCITT X.25)

  1. sudo iptables -t nat -A POSTROUTING -s 192.168.0.1/24 -o eth0 -j MASQUERADE

开启nat

具体见这里


发表于 2013-11-07 00:00 AM,最后更新于 2018-11-20 09:29:34 AM。

本文使用 署名 - 非商业性使用 - 相同方式共享 4.0 国际 协议


评论加载中...

首页