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