linux下的lan、网口、Ethernet通信
1、首先我们关闭网络接口。
# ifconfig eth0 inet down
# ifconfig
lo Link encap:Local Loopback
... (没有 eth0 这个条目了)
# route ... (没有路由表了)
2、接下来我们启动 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
3、结果是:
# 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
10.0.0.0 192.168.0.1 255.0.0.0 UG 0 0 0 eth0