美文网首页
Deepin 15.11 命令行配置静态IP

Deepin 15.11 命令行配置静态IP

作者: amor_2018 | 来源:发表于2019-12-25 22:04 被阅读0次

1. 获取网卡名称

在终端中输入:

$ ifconfig -a
enp4s0f0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 20:6a:8a:54:0e:73  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 19  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 30463  bytes 6013652 (5.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 30463  bytes 6013652 (5.7 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp3s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 20:7c:8f:75:a3:ec  txqueuelen 1000  (Ethernet)
        RX packets 421969  bytes 507325951 (483.8 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 348498  bytes 52749595 (50.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

网卡名称即为:enp4s0f0wlp3s0(无线网卡)

2. 添加IP地址

/etc/network/interfaces 中添加内容:

auto enp4s0f0
iface enp4s0f0 inet static(dhcp为动态)
address 192.168.8.100    
netmask 255.255.255.0
gateway 192.168.8.2
dns-nameserver 119.29.29.29

dns-nameserver 119.29.29.29 这句一定需要有,因为以前是DHCP解析,所以会自动分配DNS 服务器地址。
而一旦设置为静态IP后就没有自动获取到DNS服务器了,需要自己设置一个设置完重启电脑后,/etc/resolv.conf文件中会自动添加 nameserver 119.29.29.29

3. 重启网络

sudo /etc/init.d/networking restart

相关文章

网友评论

      本文标题:Deepin 15.11 命令行配置静态IP

      本文链接:https://www.haomeiwen.com/subject/dmyhoctx.html