linux 板子修改ip地址

1. 查看ip地址  ,

root@Widora:~# ifconfig
br-lan    Link encap:Ethernet  HWaddr 0C:EF:AF:D1:14:8F  
          inet addr:192.168.8.1  Bcast:192.168.8.255  Mask:255.255.255.0
          inet6 addr: fddb:4a04:d1ab::1/60 Scope:Global
          inet6 addr: fe80::eef:afff:fed1:148f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:159 errors:0 dropped:0 overruns:0 frame:0
          TX packets:80 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:28901 (28.2 KiB)  TX bytes:12186 (11.9 KiB)


eth0      Link encap:Ethernet  HWaddr 0C:EF:AF:D1:14:8E  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:304 errors:0 dropped:0 overruns:0 frame:0
          TX packets:104 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:71537 (69.8 KiB)  TX bytes:18036 (17.6 KiB)
          Interrupt:5 


eth0.1    Link encap:Ethernet  HWaddr 0C:EF:AF:D1:14:8E  
          inet6 addr: fe80::eef:afff:fed1:148e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:26 errors:0 dropped:0 overruns:0 frame:0
          TX packets:29 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1672 (1.6 KiB)  TX bytes:6332 (6.1 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:65536  Metric:1
          RX packets:336 errors:0 dropped:0 overruns:0 frame:0
          TX packets:336 errors:0 dropped:0 overruns:0 carrier:0


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:65536  Metric:1
          RX packets:132 errors:0 dropped:0 overruns:0 frame:0
          TX packets:132 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:13131 (13.1 KB)  TX bytes:13131 (13.1 KB)

2.  打开 network  ,命令 vi /etc/config/network


config interface 'loopback'
        option ifname 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'


config globals 'globals'
        option ula_prefix 'fddb:4a04:d1ab::/48'


config interface 'lan'
        option ifname 'eth0'
        option force_link '1'
        option macaddr '0c:ef:af:d1:14:8f'
        option type 'bridge'
        option proto 'static'
        option ipaddr '192.168.8.1'                //改为192.168.1.200
        option netmask '255.255.255.0'
        option ip6assign '60'


config switch
        option name 'switch0'
        option reset '1'

        option enable_vlan '0'

3.  运行命令 /etc/init.d/network reload 使修改的ip地址生效

root@Widora:/#  /etc/init.d/network reload
[ 1596.570000] rt305x-esw 10110000.esw: link changed 0x00
[ 1596.610000] br-lan: port 2(ra0) entered disabled state
[ 1596.620000] br-lan: port 1(eth0) entered disabled state
[ 1596.640000] device eth0 left promiscuous mode
[ 1596.650000] br-lan: port 1(eth0) entered disabled state
[ 1596.670000] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 1596.690000] device ra0 left promiscuous mode
[ 1596.690000] br-lan: port 2(ra0) entered disabled state
[ 1596.700000] device eth0 entered promiscuous mode
[ 1596.720000] device ra0 entered promiscuous mode
[ 1596.730000] br-lan: port 2(ra0) entered forwarding state
[ 1596.730000] br-lan: port 2(ra0) entered forwarding state
[ 1596.740000] br-lan: port 1(eth0) entered forwarding state
[ 1596.740000] br-lan: port 1(eth0) entered forwarding state
root@Widora:/# [ 1598.730000] br-lan: port 2(ra0) entered forwarding state
[ 1598.740000] br-lan: port 1(eth0) entered forwarding state
[ 1601.120000] rt305x-esw 10110000.esw: link changed 0x01

4. 重新运行ifconfig,查看ip地址

root@Widora:/# ifconfig
br-lan    Link encap:Ethernet  HWaddr 0C:EF:AF:D1:14:8F  
          inet addr:192.168.1.200  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fddb:4a04:d1ab::1/60 Scope:Global
          inet6 addr: fe80::eef:afff:fed1:148f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:176 errors:0 dropped:0 overruns:0 frame:0
          TX packets:47 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:12254 (11.9 KiB)  TX bytes:9058 (8.8 KiB)


eth0      Link encap:Ethernet  HWaddr 0C:EF:AF:D1:14:8E  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:924 errors:0 dropped:0 overruns:0 frame:0
          TX packets:205 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:171418 (167.4 KiB)  TX bytes:34038 (33.2 KiB)
          Interrupt:5 


eth0.1    Link encap:Ethernet  HWaddr 0C:EF:AF:D1:14:8E  
          inet6 addr: fe80::eef:afff:fed1:148e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:26 errors:0 dropped:0 overruns:0 frame:0
          TX packets:45 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1672 (1.6 KiB)  TX bytes:10312 (10.0 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:65536  Metric:1
          RX packets:2555 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2555 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:175055 (170.9 KiB)  TX bytes:175055 (170.9 KiB)


ra0       Link encap:Ethernet  HWaddr 0C:EF:AF:D1:14:8E  
          inet6 addr: fe80::eef:afff:fed1:148e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:6 


你可能感兴趣的:(Linux)