目录
修改配置文件
vi /etc/sysconfig/network-scripts/ifcfg-ens33
配置解释
TYPE=Ethernet #网卡类型是以太网
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none #dhcp:动态获取ip, none:手动设置固定ip地址, static:静态IP,手动设置
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=f97726ef-3a61-419a-b68d-eb5ada74ff04 #网卡的系统设备ID号, 系统中唯一
DEVICE=ens33 #设备
ONBOOT=yes #开机自启,yes:是,no:否
IPADDR=192.168.153.10 #IPv4地址
PREFIX=24 #子网掩码 <=> NETMASK=255.255.255.0
GATEWAY=192.168.153.1 #网关
DNS1=8.8.8.8 #DNS地址, 一个网卡可以绑定多个DNS
DNS2=114.114.114.114
重启网络服务
systemctl restart network
相关命令
查看路由状态 route -n
[root@localhost ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.153.1 0.0.0.0 UG 100 0 0 ens33
192.168.153.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33
查看IP地址 ip a
ip address
的简写
[root@localhost ~]# ip a
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:2f:a3:b0 brd ff:ff:ff:ff:ff:ff
inet 192.168.153.10/24 brd 192.168.153.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::2681:7978:b02b:fc20/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: virbr0: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:bc:3b:2d brd ff:ff:ff:ff:ff:ff
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:bc:3b:2d brd ff:ff:ff:ff:ff:ff
上面内容中的 state UP
表示网络接口已启用
查看网卡参数 ethtool ens33
[root@localhost ~]# ethtool ens33
Settings for ens33:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
MDI-X: off (auto)
Supports Wake-on: d
Wake-on: d
Current message level: 0x00000007 (7)
drv probe link
Link detected: yes
查看DNS解析 nslookup
[root@localhost ~]# nslookup www.baidu.com
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
www.baidu.com canonical name = www.a.shifen.com.
Name: www.a.shifen.com
Address: 182.61.200.7
Name: www.a.shifen.com
Address: 182.61.200.6
标签:00,IP地址,配置,forever,lft,link,ff,Linux,ens33
From: https://www.cnblogs.com/qode/p/17564772.html