龙空技术网

CentOS 7 网络配置详解

忆梦如风 424

前言:

今天我们对“centos71网络配置”大概比较注重,兄弟们都需要知道一些“centos71网络配置”的相关知识。那么小编也在网上汇集了一些对于“centos71网络配置””的相关资讯,希望同学们能喜欢,看官们快快来了解一下吧!

方法1

手动配置Centos7系统里的网络配置

cd /etc/sysconfig/network-scripts

ls #找到当前网络配置文件为ifcfg-ens33

sudo vim ifcfg-ens33

#修改如下网络配置

BOOTPROTO=static #以静态方式获取IP

IPADDR=192.168.1.100 #IP地址为192.168.1.100(192.168.1.0网段内)

NETMASK=255.255.255.0

GATEWAY=192.168.1.1 #网关需要与IP在一个网段内

DNS1=192.168.1.1

ONBOOT=yes #开机启动网卡

:wq #保存退出

方法2

Ip [选项] 操作对象{link|addr|route...}

# ip link show # 显示网络接口信息

# ip link set eth0 upi # 开启网卡

# ip link set eth0 down # 关闭网卡

# ip link set eth0 promisc on # 开启网卡的混合模式

# ip link set eth0 promisc offi # 关闭网卡的混个模式

# ip link set eth0 txqueuelen 1200 # 设置网卡队列长度

# ip link set eth0 mtu 1400 # 设置网卡最大传输单元

# ip addr show # 显示网卡IP信息

# ip addr add 192.168.0.1/24 dev eth0 # 设置eth0网卡IP地址192.168.0.1

# ip addr del 192.168.0.1/24 dev eth0 # 删除eth0网卡IP地址

# ip route list # 查看路由信息

# ip route add 192.168.4.0/24 via 192.168.0.254 dev eth0 # 设置192.168.4.0网段的网关为192.168.0.254,数据走eth0接口

# ip route add default via 192.168.0.254 dev eth0 # 设置默认网关为192.168.0.254

# ip route del 192.168.4.0/24 # 删除192.168.4.0网段的网关

# ip route del default # 删除默认路由

重启网卡检查配置

sudo systemctl restart network #重启网卡

sudo systemctl enable network #开机启动网卡

ifconfig #查看网卡信息

ping #能PING通就是联网成功

关注点赞不迷路[灵光一闪]

标签: #centos71网络配置 #centos7 双网卡配置路由 #centos删除默认路由 #如何配置centos7