linux 启动网络配置

1,ifconfig命令:

#ifconfig 网络端口 IP 地址 hw<HW> ether MAC 地址 netmask 掩码地址 broadcast 广播地址 [up|down]

2,配置网卡eth0 的IP地址:

需要保证和电脑在同一网关上

ifconfig eth0 192.168.2.104

3,动态 IP 地址,可用 udhcpc 命令

root@EasyARM-iMX28x /etc/rc.d/init.d# udhcpc

4,改变MAC地址:

root@EasyARM-iMX28x ~#  ifconfig eth0 hw ether 00:11:22:33:44:55

5,设置子网掩码:

ifconfig eth0 netmask 255.255.255.0

6,设置广播地址:

ifconfig eth0 broadcast 192.168.2.100

7,关闭/重启网络:

ifconfig eth0 up/down

8,设置默认网关:

添加 :route add default gw 192.168.2.1

删除:route del default gw 192.168.28.1

查看当前网关:route –n

9,设置DNS:

打开“ /etc/resolv.conf” 文件后在其中添加 DNS 配置, 可以添加多行, 若首选 DNS 及
备用 DNS 分别为 192.168.2.1 和 192.168.2.2,则其示例配置如下所示:

# nameserver ip address
nameserver 192.168.2.1
nameserver 192.168.2.2

10. 开机自动设置网络参数

保证开机和上次有同样的IP

在/etc/rc.d/init.d/start_userapp 文件增加网络配置命令:
#you can add your app start_command here
ifconfig eth0 192.168.2.104
route add default gw 192.168.28.1
#start qt command,you can delete it

 

posted @ 2016-09-22 15:58  求隐  阅读(593)  评论(0编辑  收藏  举报