OpenWrt Forum Archive

Topic: setting IP Address

The content of this topic has been archived on 30 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi
I have a problem with simple ip address setting.
I did as below.

     
root@OpenWrt:/# set ipaddr 192.168.1.3
root@OpenWrt:/# cat /etc/init.d/network  restart
#!/bin/sh /etc/rc.common

START=20
STOP=90

USE_PROCD=1

init_switch() {
        setup_switch() { return 0; }

        include /lib/network
        setup_switch
}

start_service() {
        init_switch

        procd_open_instance
        procd_set_param command /sbin/netifd
        procd_set_param respawn
        [ -e /proc/sys/kernel/core_pattern ] && {
                procd_set_param limits core="unlimited"
                echo '/tmp/%e.%p.%s.%t.core' > /proc/sys/kernel/core_pattern
        }
        procd_close_instance
}

reload_service() {
        init_switch
        ubus call network reload
        /sbin/wifi reload_legacy
}

stop_service() {
        /sbin/wifi down
}

service_running() {
        sleep 5
        /sbin/wifi reload_legacy
}

validate_atm_bridge_section()
{
        uci_validate_section network "atm-bridge" "${1}" \
                'unit:uinteger:0' \
                'vci:range(32, 65535):35' \
                'vpi:range(0, 255):8' \
                'atmdev:uinteger:0' \
                'encaps:or("llc", "vc"):llc' \
                'payload:or("bridged", "routed"):bridged'

        return $?
}

validate_route_section()
{
        uci_validate_section network route "${1}" \
                'interface:string' \
                'target:cidr4' \
                'netmask:netmask4' \
                'gateway:ip4addr' \
                'metric:uinteger' \
                'mtu:uinteger' \
                'table:or(range(0,65535),string)'

        return $?
}

validate_route6_section()
{
        uci_validate_section network route6 "${1}" \
                'interface:string' \
                'target:cidr6' \
                'gateway:ip6addr' \
                'metric:uinteger' \
                'mtu:uinteger' \
                'table:or(range(0,65535),string)'

        return $?
}

validate_rule_section()
{
        uci_validate_section network rule "${1}" \
                'in:string' \
                'out:string' \
                'src:cidr4' \
                'dest:cidr4' \
                'tos:range(0,31)' \
                'mark:string' \
                'invert:bool' \
                'lookup:or(range(0,65535),string)' \
                'goto:range(0,65535)' \
                'action:or("prohibit", "unreachable", "blackhole", "throw")'

        return $?
}

validate_rule6_section()
{
        uci_validate_section network rule6 "${1}" \
                'in:string' \
                'out:string' \
                'src:cidr6' \
                'dest:cidr6' \
                'tos:range(0,31)' \
                'mark:string' \
                'invert:bool' \
                'lookup:or(range(0,65535),string)' \
                'goto:range(0,65535)' \
                'action:or("prohibit", "unreachable", "blackhole", "throw")'

        return $?
}

validate_switch_section()
{
        uci_validate_section network switch "${1}" \
                'name:string' \
                'enable:bool' \
                'enable_vlan:bool' \
                'reset:bool'

        return $?
}

validate_switch_vlan()
{
        uci_validate_section network switch_vlan "${1}" \
                'device:string' \
                'vlan:uinteger' \
                'ports:list(ports)'

        return $?
}

service_triggers()
{
        procd_open_trigger
        procd_add_config_trigger "config.change" "network" /etc/init.d/network reload
        procd_add_config_trigger "config.change" "wireless" /etc/init.d/network reload
        procd_close_trigger

        procd_open_validate
        validate_atm_bridge_section
        validate_route_section
        validate_route6_section
        validate_rule_section
        validate_rule6_section
        validate_switch_section
        validate_switch_vlan
        procd_close_validate
}

restart() {
        ifdown -a
        sleep 1
        trap '' TERM
        stop "$@"
        start "$@"
}

shutdown() {
        ifdown -a
        stop
}
cat: can't open 'restart': No such file or directory
root@OpenWrt:/#

  

It did not work.
'cat /etc/init.d/network reload' also did not work.
I think I did not use proper command. Can anybody teach me how to do it?

Well, you should start with "uci show". that will show all available options you could set. As you want to set your ip-adress, you should do "uci show network" next, and it should appear.
Since you probably want to use dhcp to get your network configuration, "uci set network.wan.proto=dhcp" should do. This way, you can set other options as mentioned in http://wiki.openwrt.org/doc/uci/network#protocol.dhcp if necessary.
After that, issue "/etc/init.d/network restart".

Thanks MBS for valuable response.
I get it done as per your advice.
Thanks very much.
I can update opkg and install ser2net.
But I have another problem arise. I cannot configure ser2net
I use vi /etc/ser2net.config 1234:raw:0:/dev/ttyACM0:9600 but it is not successful, saying the file is not in the directory.
I configer others like 2003:raw:5:/dev/ttyS2:9600, result is same. Not successful.

And I try to install opkg install kmod-usb-acm , it cannot be installed. See the log sheet.

root@OpenWrt:/# opkg files ser2net
Package ser2net (2.9.1-1) is installed on root and has the following files:
/etc/ser2net.conf
/usr/sbin/ser2net
root@OpenWrt:/# opkg update
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/Packages.gz.
Updated list of available packages in /var/opkg-lists/barrier_breaker.
root@OpenWrt:/# opkg install kmod-usb-acm
Installing kmod-usb-acm (3.10.36-1) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-usb-acm_3.10.36-1_ar71xx.ipk.
Multiple packages (kmod-usb-core and kmod-usb-core) providing same name marked HOLD or PREFER. Using latest.
Collected errors:
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-usb-acm:
 *      kernel (= 3.10.36-1-0839f991138461479a364e867bb72685) *
 * opkg_install_cmd: Cannot install package kmod-usb-acm.
root@OpenWrt:/#
  

Any suggestion?

vi /etc/ser2net.conf

Regarding the problem to install kmod-usb-acm: the buildbot seems to have built a newer round of firmware images and packages. Especially kernel modules are very sensitive to be from the same build. So, the clean way is to get a new firmware image and install all over again.

The discussion might have continued from here.