使用dhclient 自动获取IP地址
[[email protected] ~]# dhclient -r
[[email protected] ~]# dhclient
vi /etc/
[[email protected] ~]# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:93:47:04 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.16/24 brd 192.168.1.255 scope global dynamic ens33
valid_lft 84782sec preferred_lft 84782sec
inet6 fe80::bbca:2655:139:aa19/64 scope link noprefixroute
valid_lft forever preferred_lft forever
查看网络路由网关是否正确
[[email protected] ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 ens33
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 ens33
192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33
vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
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=ens33
UUID=4aa87787-3b5c-4985-9b43-24f247fc71c1
DEVICE=ens33
ONBOOT=yes #原始为no 改为yes
重启网络服务
systemclt restart network.service
原文地址:http://blog.51cto.com/14053646/2312002
时间: 2024-11-09 04:57:33