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

linux如何通过ip配地址(在linux中如何配ip)

  • linux
  • 2024-03-16 06:56:19
  • 3849
通过 IP 为 Linux 配地址
若要通过 IP 为 Linux 配地址,需要指定以下要素:

1. IP 地址:为设备分配的唯一网络地址。


2. 子网掩码:确定子网中 IP 地址的网络部分和主机部分。


3. 网关:连接设备到其他网络的设备的 IP 地址。


举例说明:
配置 IP 地址:
ifconfig eth0 192.168.1.100/24
其中:
- eth0 是网络接口名称
- 192.168.1.100 是 IP 地址
- /24 是子网掩码
配置子网掩码:
ifconfig eth0 netmask 255.255.255.0
配置网关:
route add default gw 192.168.1.1
其中:
- default gw 指定默认网关
- 192.168.1.1 是网关的 IP 地址