当前位置:首页 > linux > 正文

linux网卡配置步骤(linux网卡设置)

  • linux
  • 2024-03-21 11:23:33
  • 4438
Linux 网卡配置步骤
1. 查看网卡信息
shell
ip link show
2. 设置网卡模式
shell
ip link set up

shell
ifconfig up
3. 分配 IP 地址
静态 IP 地址:
shell
ifconfig netmask
动态 IP 地址:(使用 DHCP)
shell
dhclient
4. 设置默认网关和 DNS 服务器
shell
route add default gw
echo "nameserver " > /etc/resolv.conf
5. 测试网络连接
shell
ping
几个要素:
:网卡名称,例如 eth0
:要分配的 IP 地址
:子网掩码
:默认网关 IP 地址
:DNS 服务器 IP 地址