Linux下配置网络:RHEL、CentOS、Ubuntu、Kali

1、使用配置文件配置网络

RHEL和CentOS下使用配置文件配置网络:

vim /etc/sysconfig/network-scripts/ifcfg-ens33
	NAME=ens33
	DEVICE=ens33
	BOOTPROTO=dchp/static
	ONBOOT=yes
	IPADDR=192.168.49.2
	NETMASK=255.255.255.0
	GATEWAY=192.168.49.254
	DNS1=8.8.8.8

Kali下使用配置文件配置网络:

vim  /etc/network/interfaces
	auto 设备名
	iface 设备名 inet 动静态
	gateway 网关
	netmask 子网掩码
	address IP地址
	dnsserver dns地址
	waddress ether 物理地址

Ubuntu下使用配置文件配置网络:

vim /etc/network/interfaces
	auto eth0			#设置自动启动eth0接口
	iface eth0 inet static		#配置静态
	IPaddress 192.168.49.2		#IP地址
	netmask 255.255.255.0		#子网掩码
	gateway 192.168.49.254		#默认网关
	dns-nameservers 114.114.114.114		#域名解析

2、重启网络,是配置生效

RHEL和CentOS下:

systemctl restart NetworkManager
systemctl restart network
ifdown eth0;ifup eth0
nmcli connection down eth0
nmcli connection up eth0

Kali和Ubuntu下:

/etc/init.d/networking restart
service network restart
ifdown eth0;ifup eth0

还可以使用其他命令进行网络配置

nmcli connection add type ethernet ifname eth0 con-name * ipv4.address * ipv4.gateway * ipv4.method manual
ifconfig 等等
nm-connection-editor
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值