网络配置


1.网卡配置

  vim /etc/sysconfig/network-scripts/ifcfg-eth0 

  1DEVICE=eth0
2 HWADDR=00:0C:29:93:41:2B
3 TYPE=Ethernet
4 UUID=d775c95a-a13d-4859-8460-0ff336f1f406
5 ONBOOT=yes        #开机自启
6 NM_CONTROLLED=yes
7 BOOTPROTO=static     #手动获取ip地址,如果自动改为BOOTPROTO=dhcp
8 GATEWAY=192.168.0.1
9 IPADDR=192.168.0.101
10 NETMASK=255.255.255.0
11 DNS1=192.168.1.1      #可添加多个DNS备用地址

2.DNS更改的配置文件

vim /etc/reslov.conf

  1 # Generated by NetworkManager
2 nameserver 192.168.1.1

3.重启网络

service network restart
正在关闭接口 eth0: 设备状态:3 (断开连接)
[确定]
关闭环回接口: [确定]
弹出环回接口: [确定]
弹出界面 eth0: 活跃连接状态:激活中
活跃连接路径:/org/freedesktop/NetworkManager/ActiveConnection/1
状态:激活的
连接被激活
[确定

4.清除iptable

iptables -F       #清空iptable

 /etc/init.d/iptables save    #保存

iptables:将防火墙规则保存到 /etc/sysconfig/iptables:     [确定]

5.关闭selinux

vim /etc/selinux/config

  1
2 # This file controls the state of SELinux on the system.
3 # SELINUX= can take one of these three values:
4 # enforcing - SELinux security policy is enforced.
5 # permissive - SELinux prints warnings instead of enforcing.
6 # disabled - No SELinux policy is loaded.
7 SELINUX=disabled      #将selinux修改disable
8 # SELINUXTYPE= can take one of these two values:
9 # targeted - Targeted processes are protected,
10 # mls - Multi Level Security protection.
11 SELINUXTYPE=targeted

6.网络配置常用命令

1)查看网卡与网线的连接情况

     mii-tool命令  http://www.cnblogs.com/Spiro-K/p/6384793.html

2)单网卡启动

ifconfig eth0 down

ifconfig eth0 up

3)单网卡多IP配置

ifconfig eth0 : IP地址/掩码

ifconfig eth0 : IP地址/掩码

4)主机名

查看
  hostname 临时更改
  hostname name 写入配置文件
  vim /etc/sysconfig/network

5)DNS配置

DNS简易配置文件
vim /etc/hosts DNS配置文件
vim /etc/resolv.conf

6)查看路由表

route -n

Kernel IP routing table
Destination Gateway Genmask Flags      Metric Ref Use Iface
192.168.0.0 0.0.0.0 255.255.255.0 U #直连     1 0 0 eth0
0.0.0.0 192.168.0.1 0.0.0.0 UG #网关     0 0 0 eth0

7)查看开启端口

netstat -antp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1444/master
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 1571/sshd
tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN 1960/sshd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1365/sshd
tcp 0 0 192.168.0.101:22 192.168.0.100:55989 ESTABLISHED 1960/sshd
tcp 0 0 192.168.0.101:22 192.168.0.100:52818 ESTABLISHED 1571/sshd
tcp 0 0 ::1:25 :::* LISTEN 1444/master
tcp 0 0 ::1:6010 :::* LISTEN 1571/sshd
tcp 0 0 ::1:6011 :::* LISTEN 1960/sshd
tcp 0 0 :::22 :::* LISTEN 1365/sshd

最新文章

  1. java中的锁
  2. SecureCRT和SecureFx设置中文乱码
  3. dotNet使用HttpWebRequest模拟浏览器
  4. gulp前端自动化构建工具入门篇
  5. python手记(32)
  6. 20个最强的基于浏览器的在线代码编辑器 - OPEN资讯
  7. 为Android增加硬件抽象层(HAL)模块访问Linux内核驱动程序
  8. django Forbidden
  9. 洛谷P1512伊甸园的日历游戏题解
  10. SQL反模式学习笔记18 减少SQL查询数据,避免使用一条SQL语句解决复杂问题
  11. 页面中直接显示FTP中的图片
  12. php实现下载模板与上传模板解析
  13. 迈向高阶:优秀Android程序员必知必会的网络基础
  14. ES6(promise)_解决回调嵌套简单应用
  15. yii主题
  16. python中enumerate、变量类型转换
  17. 【Linux 线程】线程同步《三》
  18. php 类与对象 面向对象编程 简单例子
  19. vue框架(二)_vue环境搭建及创建项目
  20. NGUI在5.3打包失败问题

热门文章

  1. 20145302张薇《Java程序设计》第六周学习总结
  2. 20145313张雪纯 《Java程序设计》8周学习总结
  3. MySQL中变量的用法——LeetCode 178. Rank Scores
  4. Spring事务管理之几种方式实现事务
  5. 采用OpenReplicator解析MySQL binlog
  6. [小问题笔记(十)] SQL Server 里 float 转 varchar等字符类型 不使用科学计数法
  7. spring boot2.1读取 apollo 配置中心2
  8. 解决Eclipse Maven插件的最佳方案
  9. cygwin下安装软件
  10. 前端打印功能实现及css设置