Linux:网络配置
2024-08-24 05:01:53
网络配置
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
最新文章
- java中的锁
- SecureCRT和SecureFx设置中文乱码
- dotNet使用HttpWebRequest模拟浏览器
- gulp前端自动化构建工具入门篇
- python手记(32)
- 20个最强的基于浏览器的在线代码编辑器 - OPEN资讯
- 为Android增加硬件抽象层(HAL)模块访问Linux内核驱动程序
- django Forbidden
- 洛谷P1512伊甸园的日历游戏题解
- SQL反模式学习笔记18 减少SQL查询数据,避免使用一条SQL语句解决复杂问题
- 页面中直接显示FTP中的图片
- php实现下载模板与上传模板解析
- 迈向高阶:优秀Android程序员必知必会的网络基础
- ES6(promise)_解决回调嵌套简单应用
- yii主题
- python中enumerate、变量类型转换
- 【Linux 线程】线程同步《三》
- php 类与对象 面向对象编程 简单例子
- vue框架(二)_vue环境搭建及创建项目
- NGUI在5.3打包失败问题
热门文章
- 20145302张薇《Java程序设计》第六周学习总结
- 20145313张雪纯 《Java程序设计》8周学习总结
- MySQL中变量的用法——LeetCode 178. Rank Scores
- Spring事务管理之几种方式实现事务
- 采用OpenReplicator解析MySQL binlog
- [小问题笔记(十)] SQL Server 里 float 转 varchar等字符类型 不使用科学计数法
- spring boot2.1读取 apollo 配置中心2
- 解决Eclipse Maven插件的最佳方案
- cygwin下安装软件
- 前端打印功能实现及css设置