设备使用的是中嵌科技的网关设备,现在有两个网口,其中网口1用于和我的电脑建立ssh通信,网口2准备接路由器上网。
先看看系统版本:
root@EC2022v:~# cat /proc/version
Linux version 3.6.9-rt21-Emfuture (root@imx) (gcc version 4.8.3 (OpenWrt/Linaro GCC 4.8-2014.04 r44365) ) #130 PREEMPT Sun Mar 4 16:39:28 CST 2018
原来的配置文件内容如下:
root@EC2022v:/etc/config# cat network
#lo port seting
config interface loopback
option ifname lo
option proto static
option ipaddr 127.0.0.1
option netmask 255.0.0.0
#lan port seting
config interface lan
option ifname eth0
option type null
option proto static
option ipaddr 192.168.0.249
option netmask 255.255.255.0
config interface lan1
option ifname eth1
option type null
option proto static
option ipaddr 192.168.1.249
option netmask 255.255.255.0
修改后的配置文件如下:
root@EC2022v:/etc/config# vi network
root@EC2022v:/etc/config# cat network
#lo port seting
config interface loopback
option ifname lo
option proto static
option ipaddr 127.0.0.1
option netmask 255.0.0.0
#lan port seting
config interface lan
option ifname eth0
option type null
option proto static
option ipaddr 192.168.0.249
option netmask 255.255.255.0
config interface lan1
option ifname eth1
option type null
option proto dhcp
最后就可以欢快的上网了:
root@EC2022v:~#ping www.baidu.com
PING www.baidu.com (180.97.33.107): 56 data bytes
64 bytes from 180.97.33.107: seq=0 ttl=50 time=54.223 ms
64 bytes from 180.97.33.107: seq=1 ttl=50 time=52.394 ms
64 bytes from 180.97.33.107: seq=2 ttl=50 time=52.507 ms
64 bytes from 180.97.33.107: seq=3 ttl=50 time=52.619 ms
64 bytes from 180.97.33.107: seq=4 ttl=50 time=52.472 ms
64 bytes from 180.97.33.107: seq=5 ttl=50 time=52.367 ms
64 bytes from 180.97.33.107: seq=6 ttl=50 time=52.577 ms
64 bytes from 180.97.33.107: seq=7 ttl=50 time=52.509 ms
64 bytes from 180.97.33.107: seq=8 ttl=50 time=52.482 ms
64 bytes from 180.97.33.107: seq=9 ttl=50 time=52.531 ms