【ubuntu】ubuntu Linux设置ip为dhcp自动获取
1. //查看网卡名称,如enp5s0、enp3s0等
ifconfig
2. 配置固定或自动获取ip
sudo vi /etc/network/interfaces
- interfaces文件内容如下:
- 注释或启用
auto ip或fixed ip下的配置
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
# auto ip
auto enp5s0
iface enp5s0 inet dhcp
# fixed ip
#auto enp5s0
#iface enp5s0 inet static
#address 192.168.1.23
#netmask 255.255.255.0
3. 重启网卡,测试是否成功
/etc/init.d/networking restart
或者:
/etc/init.d/network restart
service network restart