1. 程式人生 > >Linux配置靜態IP

Linux配置靜態IP

網絡服務 -a bootp res serve fatal 0.0.0.0 ipad autoconf

1.進入/etc/sysconfig/network-scripts,修改網卡配置文件ifcfg-eno16777736
2.修改網絡配置
修改前
TYPE="Ethernet"
BOOTPROTO="dhcp"
DEFROUTE="yes"
PEERDNS="yes"
PEERROUTES="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_FAILURE_FATAL="no"
NAME="eno16777736"
UUID="6b7fc8a3-2b38-45e3-a64d-485a89380d48"
DEVICE="eno16777736"
ONBOOT="yes"
修改後
TYPE="Ethernet"
BOOTPROTO="static"----dhcp(自動獲取ip)改為static(靜態ip)
DEFROUTE="yes"
PEERDNS="yes"
PEERROUTES="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_FAILURE_FATAL="no"
NAME="eno16777736"
UUID="ea3e99ab-fb3e-4724-8a6b-e072a058bdcd"
DEVICE="eno16777736"
ONBOOT="yes"
BROADCAST=192.168.159.255---局域網廣播地址
IPADDR=192.168.159.131---靜態IP
NETMASK=255.255.255.0----子網掩碼
GATEWAY=192.168.159.2----網關或者路由地址
DNS1=192.168.159.2---DNS
3、檢查路由
route -n-----若無通過route add default gw 192.168.159.2添加
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.159.2 0.0.0.0 UG 100 0 0 eno16777736
192.168.159.0 0.0.0.0 255.255.255.0 U 100 0 0 eno16777736
4.檢查dns
cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.159.2
5.成功前網絡服務
/etc/init.d/network restart

Linux配置靜態IP