看所有网卡(包括未启动的) ifconfig -a 或者 ip link 查看当前网卡配置,打开配置文件/etc/network/interfaces 设置静态IP(dhcp 为动态获取,static 为静态获取) sudo vim /etc/network/interfaces 修改成如下内容: auto enp0s3 iface ens33 inet static #设置静态IP,动态的是将static修改为dhcp,如果设置为动态IP无法设置虚拟网卡 address 172.16.2.95
参考文档: https://www.jb51.net/os/Ubuntu/418951.html https://blog.csdn.net/ying1989920/article/details/48385427 添加临时ip地址(设备重启后不生效) sudo ip addr add 192.168.1.104/24 dev enp0s3 //给设备 enp0s3 添加 ip 地址 sudo ip address show enp0s3 //查看配置是否生效 sudo ip addr del