configure static IP
desktop:
配置IP地址:
~$ sudo cat /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.3.71
netmask 255.255.255.0
gateway 192.168.3.1
配置DNS:
~$ sudo cat /etc/resolv.conf
nameserver 8.8.8.8
重启网络:
~$ sudo /etc/init.d/networking restart
查看IP是否配置成功:
以下是两种查看IP的方法
1:~$ ifconfig
2:~$ ip addr show
server:
~$ sudo vim /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
ens3: //配置的网卡名称
dhcp4: no //关闭ipv4的dhcp功能
addresses: [192.168.122.98/24] //设置IP地址及子网掩码
gateway4: 192.168.122.1 //设置网关
nameservers: //设置DNS
addresses: [8.8.8.8,114.114.114.114]
~$ sudo netplan apply //使配置生效
查看IP是否修改成功: