linux deb系 rpm系 配置永久IP
rpm:
1.IP a 查看网卡名 ens256
2.uuidgen ens256 生成UUID
3./etc/sysconfig/network-scripts add ifcfg-ens256
4.sudo vim ifcfg -ens256
TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=static DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens256#NAME UUID=4e3c8350-6e7f-47e2-8b9d-b64ba0531d79#UUID DEVICE=ens256#deviceName ONBOOT=yes IPADDR=8.47.221.183 NETMASK=255.255.224.0 #GATEWAY=8.47.192.1 #DNS1=8.47.192.1 8.47.0.0/19 via 8.47.192.1#onboot route
4.重启网络服务:systemctl restart network.service
deb:
1.sudo vim /etc/network/interfaces
2.add
alfred@vm:~$ cat /etc/network/interfaces # interfaces(5) file used by ifup(8) and ifdown(8) auto lo iface lo inet loopback auto ens160 iface ens160 inet static address 10.150.56.62 gateway 10.150.56.1 netmask 255.255.254.0 dns-nameservers 10.129.0.220 up route add -net 10.0.0.0 netmask 255.255.0.0 gw 10.150.56.1 auto ens192 iface ens192 inet static address 8.46.221.73 #gateway 8.46.192.1 #can not add two gateway other network use route netmask 255.255.224.0 up route add -net 8.46.0.0 netmask 255.255.0.0 gw 8.46.192.1 auto ens224 iface ens224 inet static address 8.47.221.73 netmask 255.255.224.0 up route add -net 8.47.0.0 netmask 255.255.0.0 gw 8.47.192.1
3.重启网络服务:systemctl restart network.service
RHEL:
十分原始
1.路径同rpm 内容:
重点是这几个配置 TYPE=Ethernet BOOTPROTO=static NAME=enp0s3 ONBOOT=yes IPADDR=地址 NETMASK=掩码 GATEWAY=网关 DNS1=你的DNS
#临时ip ifconfig eth0 x.x.x.x netmask 255.255.x.0 up
使用ethtool检查端口是否up