debian设置静态ip
#vim /etc/network/interfaces
auto eth0 iface eth0 inet static address 219.230.144.244 netmask 255.255.255.192 gateway 219.230.144.254 dns-nameservers 8.8.8.8
- 重启网络服务
/etc/init.d/networking restart
ubuntu 20.04
cat /etc/netplan/00-installer-config.yaml # This is the network config written by 'subiquity' network: ethernets: enp4s0: dhcp4: false addresses: - 192.168.1.66/24 gateway4: 192.168.1.1 nameservers: addresses: [192.168.1.1, 223.5.5.5] version: 2
netplan apply
centos设置静态ip
#vim /etc/sysconfig/network-scripts/ifcfg-eth0 有时会是ifcfg-em1
DEVICE="eth0" BOOTPROTO="static" HWADDR="00:A5:D1:EA:23:A4" IPV6INIT="yes" MTU="1500" NM_CONTROLLED="yes" ONBOOT="yes" TYPE="Ethernet" UUID="95fd6b2b-ecfd-4cdf-9833-e3056f22d4e8" IPADDR=192.168.8.126 NETMASK=255.255.255.0 GATEWAY=192.168.8.1
-
配置dns解析
echo "nameserver 211.98.1.28">> /etc/resolv.conf
弄完后,记得重启网络服务
/etc/init.d/network restart
查看网络ip
ifconfig
查看网关
netstat -rn
查看nameserver
cat /etc/resolv.conf
Leave a Reply