欢迎您访问我爱IT技术网,今天小编为你分享的电脑教程是网络协议方面的经验知识教程:底层网络设置,下面是详细的分享!
底层网络设置
底层网络设置
GNU/Linux 上传统的底层网络设置工具是 ifconfig 和 route,它们在 net-tools 这个软件包中。目前这些工具被软将包 iproute 中的 ip 代替。ip 可以在 Linux 2.2 或更新的内核上运行,有着比老的工具更好的兼容性。然而,这些传统的设置工具还是能用的而且大家也更加熟悉。
底层网络设置 – ifconfig 和 route
下面演示如何把网络接口 eth0 的 IP 地址从 192.168.0.3 改为 192.168.0.111;设置 eth0 的路由,通过 192.168.0.1 访问 10.0.0.0 这个网络。 执行 ifconfig 和 route 时不带网络接口参数,则显示所有网络接口和路由的现状。
# ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:46:7A:02:B0
inet addr:192.168.0.3 Bcast:192.168.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:23363 errors:0 dropped:0 overruns:0 frame:0
TX packets:21798 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:13479541 (12.8 MiB) TX bytes:20262643 (19.3 MiB)
Interrupt:9
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:230172 errors:0 dropped:0 overruns:0 frame:0
TX packets:230172 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:22685256 (21.6 MiB) TX bytes:22685256 (21.6 MiB)
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 * 255.255.0.0 U 0 0 0 eth0
default 192.168.0.1 255.255.255.255 UG 0 0 0 eth0
首先我们关闭网络接口。
# ifconfig eth0 inet down
# ifconfig
lo Link encap:Local Loopback
... (没有 eth0 这个条目了)
# route
... (没有路由表了)
接下来我们启动 eth0 并给予其新的 IP 地址和路由。
# ifconfig eth0 inet up 192.168.0.111 \
netmask 255.255.255.0 broadcast 192.168.0.255
# route add -net 10.0.0.0 netmask 255.0.0.0 gw 192.168.0.1 dev eth0
结果是:
# ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:46:7A:02:B0
inet addr:192.168.0.111 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
...
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
...
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
*****0.0.0 192.168.0.1 255.0.0.0 UG 0 0 0 eth0
以上就是关于底层网络设置的网络协议知识分享,更多电脑教程请移步到>>电脑教程。
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
