临时配置

 步骤

实现此案例需要按照如下步骤进行。
步骤一:网络接口控制

查看网卡eth0的配置信息、禁用网卡eth0,命令操作如下所示:

root@localhost 桌面]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:0C:29:0D:06:9A  
          inet addr:192.168.30.124  Bcast:192.168.30.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe0d:69a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:174884 errors:0 dropped:0 overruns:0 frame:0
          TX packets:920 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:12269223 (11.7 MiB)  TX bytes:91973 (89.8 KiB)

[root@localhost 桌面]# ifconfig eth0 down
[root@localhost 桌面]# ifconfig
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:105 errors:0 dropped:0 overruns:0 frame:0
          TX packets:105 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:8792 (8.5 KiB)  TX bytes:8792 (8.5 KiB)

列出所有网络接口,确认启用状态,命令操作如下所示:

[root@localhost 桌面]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:0C:29:0D:06:9A  
          inet addr:192.168.30.124  Bcast:192.168.30.255  Mask:255.255.255.0
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:175179 errors:0 dropped:0 overruns:0 frame:0
          TX packets:920 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:12289943 (11.7 MiB)  TX bytes:91973 (89.8 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:105 errors:0 dropped:0 overruns:0 frame:0
          TX packets:105 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:8792 (8.5 KiB)  TX bytes:8792 (8.5 KiB)

[root@localhost 桌面]#

激活网卡eth0,将地址设置为192.168.4.5/24,命令操作如下所示:

[root@localhost 桌面]# ifconfig 
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:105 errors:0 dropped:0 overruns:0 frame:0
          TX packets:105 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:8792 (8.5 KiB)  TX bytes:8792 (8.5 KiB)

[root@localhost 桌面]# ifconfig eth0 up
[root@localhost 桌面]# ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:0C:29:0D:06:9A  
          inet addr:192.168.30.124  Bcast:192.168.30.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe0d:69a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:175553 errors:0 dropped:0 overruns:0 frame:0
          TX packets:927 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:12315815 (11.7 MiB)  TX bytes:92551 (90.3 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:105 errors:0 dropped:0 overruns:0 frame:0
          TX packets:105 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:8792 (8.5 KiB)  TX bytes:8792 (8.5 KiB)

[root@localhost 桌面]# ifconfig eth0 192.168.4.5/24
[root@localhost 桌面]# ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:0C:29:0D:06:9A  
          inet addr:192.168.4.5  Bcast:192.168.4.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe0d:69a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:177266 errors:0 dropped:0 overruns:0 frame:0
          TX packets:927 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:12438744 (11.8 MiB)  TX bytes:92551 (90.3 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:105 errors:0 dropped:0 overruns:0 frame:0
          TX packets:105 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:8792 (8.5 KiB)  TX bytes:8792 (8.5 KiB)

[root@localhost 桌面]#

步骤二:为网卡eth0添加一个IP地址 192.168.8.5/24

命令操作如下所示:

[root@localhost 桌面]# ifconfig eth0 192.168.8.5/24
[root@localhost 桌面]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:0C:29:0D:06:9A  
          inet addr:192.168.8.5  Bcast:192.168.8.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe0d:69a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:182405 errors:0 dropped:0 overruns:0 frame:0
          TX packets:927 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:12804365 (12.2 MiB)  TX bytes:92551 (90.3 KiB)

[root@localhost 桌面]#

步骤三:为本机设置静态路由记录

访问网段200.0.0.0/24可经192.168.8.100抵达。
添加一条静态路由route add -net 200.0.0.0/24 gw 192.168.8.100 ,相关说明如下所示:
route add:添加一条路由条目;
-net:目标网络ID和子网掩码;
gw:下一跳地址。
命令操作及输出结果如下所示:

[root@localhost 桌面]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.8.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
[root@localhost 桌面]# route add -net 200.0.0.0/24 gw 192.168.8.100
[root@localhost 桌面]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
200.0.0.0       192.168.8.100   255.255.255.0   UG    0      0        0 eth0
192.168.8.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0

默认网关的IP地址为 192.168.8.254。
分析:为PC机配置网关,而对PC机而言数据只要是跨网通信都必须交给网关处理,这很像路由中的默认路由的概念。所以在Linux中为PC机配置网关,其实就是配置一条默认路由。
命令操作如下所示:

[root@localhost 桌面]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
200.0.0.0       192.168.8.100   255.255.255.0   UG    0      0        0 eth0
192.168.8.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
[root@localhost 桌面]# route add default gw 192.168.8.254
[root@localhost 桌面]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
200.0.0.0       192.168.8.100   255.255.255.0   UG    0      0        0 eth0
192.168.8.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
0.0.0.0         192.168.8.254   0.0.0.0         UG    0      0        0 eth0
[root@localhost 桌面]#

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用 JavaScript 编写的记忆游戏(附源代码)   项目:JavaScript 记忆游戏(附源代码) 记忆检查游戏是一个使用 HTML5、CSS 和 JavaScript 开发的简单项目。这个游戏是关于测试你的短期 记忆技能。玩这个游戏 时,一系列图像会出现在一个盒子形状的区域中 。玩家必须找到两个相同的图像并单击它们以使它们消失。 如何运行游戏? 记忆游戏项目仅包含 HTML、CSS 和 JavaScript。谈到此游戏的功能,用户必须单击两个相同的图像才能使它们消失。 点击卡片或按下键盘键,通过 2 乘 2 旋转来重建鸟儿对,并发现隐藏在下面的图像! 如果翻开的牌面相同(一对),您就赢了,并且该对牌将从游戏中消失! 否则,卡片会自动翻面朝下,您需要重新尝试! 该游戏包含大量的 javascript 以确保游戏正常运行。 如何运行该项目? 要运行此游戏,您不需要任何类型的本地服务器,但需要浏览器。我们建议您使用现代浏览器,如 Google Chrome 和 Mozilla Firefox, 以获得更好、更优化的游戏体验。要玩游戏,首先,通过单击 memorygame-index.html 文件在浏览器中打开游戏。 演示: 该项目为国外大神项目,可以作为毕业设计的项目,也可以作为大作业项目,不用担心代码重复,设计重复等,如果需要对项目进行修改,需要具备一定基础知识。 注意:如果装有360等杀毒软件,可能会出现误报的情况,源码本身并无病毒,使用源码时可以关闭360,或者添加信任。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值