[关闭]
@zwh8800 2017-08-23T10:20:12.000000Z 字数 1307 阅读 191005

几条命令

blog 归档 运维 Linux 备忘


关于 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

具体见这里

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注