系统城装机大师 - 固镇县祥瑞电脑科技销售部宣传站!

当前位置:首页 > 系统教程 > Linux教程 > 详细页面

Linux /etc/network/interfaces配置接口方法

时间:2020-02-12来源:系统城作者:电脑系统城

Linux下/etc/network/interfaces文件用来配置网络接口。

初始化网口Ethernet Interface

大部分的网络接口配置都可以在/etc/network/interfaces中解决。例如为网卡配置静态IP(dhcp),设置路由信息,配置IP掩码,设置默认路由等。

PS: 如果想要在系统启动时就自动启动网口,需要添加auto一行,详见下面示例。

1. 使用动态IP地址

 


 
  1. auto eth0
  2. iface eth0 inet dhcp

2. 使用静态IP地址


 
  1. auto eth0
  2. iface eth0 inet static
  3. address 192.168.1.100
  4. netmask 255.255.255.0
  5. gateway 192.168.1.1
  6. # network 192.168.1.0
  7. # broadcast 192.168.1.255

network和broadcast一般使用默认值就行。

3. 查看路由表


 
  1. # route
  2. Kernel IP routing table
  3. Destination Gateway Genmask Flags Metric Ref Use Iface
  4. default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
  5. 192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
  6. # route -n
  7. Kernel IP routing table
  8. Destination Gateway Genmask Flags Metric Ref Use Iface
  9. 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
  10. 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0

route -n不解析名字。

以上就是我们小编给大家整理的相关内容,感谢大家的学习和支持。

分享到:

相关信息

  • linux定时关机设置教程

    当linux在运作时不能直接关闭电源容易将档案系统损毁,因此需要用shutdown以安全的方式关闭,那么这个操作该怎么实现呢?下面就为大家带来了详细教程。...

    2022-11-07

  • linux强制删除文件教程

    由于linux系统和我们常用的windows系统是不一样的,所以如果是初学者,可能会不知道linux怎么强制删除文件,其实我们只要打开终端,使用命令就可以删除了。...

    2022-11-03

系统教程栏目

栏目热门教程

人气教程排行

站长推荐

热门系统下载