Linux修改IP Address

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

  以前都是使用自动IP动态分配获取IP的,虽然每次获得的ip都是相同的,但我还是决定自己设置一个IP.输入命令:

  [root@localhost ~]# ifconfig eth0 219.246.177.160 netmask 255.255.255.0 up

  ping 以下177网段的ip是可以ping通的,但是ping别的网段无法ping通

  [root@localhost ~]# ping 219.246.183.1

  connect: Network is unreachable

  Java代码

  [root@localhost ~]# route

  Kernel IP routing table

  Destination Gateway Genmask Flags Metric Ref Use Iface

  219.246.177.0 * 255.255.255.0 U 0 0 0 eth0

  Java代码

  [root@localhost ~]# route

  Kernel IP routing table

  Destination Gateway Genmask Flags Metric Ref Use Iface

  219.246.177.0 * 255.255.255.0 U 0 0 0 eth0

  没有设置默认网关。设置网关

  [root@localhost ~]# route add default gw 219.246.177.1

  route add default gw 61.144.47.225

  再查看路由表:

  Java代码

  [root@localhost ~]# route

  Kernel IP routing table

  Destination Gateway Genmask Flags Metric Ref Use Iface

  219.246.177.0 * 255.255.255.0 U 0 0 0 eth0

  default 219.246.177.1 0.0.0.0 UG 0 0 0 eth0

  Java代码

  [root@localhost ~]# route

  Kernel IP routing table

  Destination Gateway Genmask Flags Metric Ref Use Iface

  219.246.177.0 * 255.255.255.0 U 0 0 0 eth0

  default 219.246.177.1 0.0.0.0 UG 0 0 0 eth0

  添加上了默认网关。此时,再ping一下别的网段就可以ping通了。

[1][2]

不论你在什么时候开始,重要的是开始之后就不要停止

Linux修改IP Address

相关文章:

你感兴趣的文章:

标签云: