---
title: "centos7查看端口命令"
author: "falchion"
date: "2018-01-24T20:25:53Z"
tags: []
categories: ["操作系统"]
slug: "centos7"
draft: false
lastmod: "2018-01-24T20:25:53Z"
id: 2408969
url: "https://falchion.iteye.com/blog/2408969"
---

```
查看Centos端口命令： 
# netstat -lntp #查看监听(Listen)的端口
# netstat -antp #查看所有建立的TCP连接
其他关于查看服务器网络信息命令：
1、查看Linux系统主机名：
    # hostname
    localhost.localdomain
2、查看服务器IP地址：
    # ifconfig|grep 'inet addr:'|grep -v '127.0.0.1'|cut -d: -f2|awk '{ print $1}'
    192.168.17.238
    192.168.1.9
3、查看linux网关：
    # route |grep default
    default 192.168.1.1 0.0.0.0 UG 0 0 0 em1
4、查看linux打开服务：
    # chkconfig --list|grep 启用 #查看开启的服务
    sshd 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
    httpd 0:关闭 1:关闭 2:关闭 3:启用 4:关闭 5:关闭 6:关闭
5、查看服务器DNS配置：
    # cat /etc/resolv.conf
    nameserver 192.168.0.66
    nameserver 202.106.0.20
6、其他网络信息：
    # iptables -L #查看防火墙规则
    # route -n #查看路由表
    # netstat -s #查看网络统计信息



```