Openwrt сменить ip роутера

OpenWrt as router device

If your device has some ports labeled LAN and at least a port labeled WAN and you want it to operate as a router (a connection between two different networks). Depending on actual hardware support, it may be possible to create a WAN port on a device with only LAN ports, see your device’s page for more info about this. The default IP of the LAN ports of a OpenWrt device is 192.168.1.1, if the addresses of the devices in the network you connect to the WAN port are 192.168.1.X (X=any number), you need to change the IP address of the LAN interface on your OpenWrt router to 192.168.2.1 (or to something that isn’t 192.168.1.X, anyway), or change the addressing of the other network you are connecting to. The LAN and WAN interfaces MUST have at least different subnets for routing to work.

you can customize the router address and the address of the subnet that OpenWrt manages, but you don’t have to (you preferably want to do this, if the addresses 192.168.1.* are already in use on the WAN side)

you can change the WAN side IP address to no longer obtain a dynamic address: if your ISP wants you to set a fixed address then set it to a fixed address instead

If you are confused now or don’t know, simply start by leaving both config parts in its default configuration. If you experience problems with these defaults, then adapt them accordingly later.

Web interface instructions

Click on NetworkInterfaces, then click on the Edit button of the LAN Network.

In General Setup tab, in IPv4 address type in the desired static IP address for the LAN interface of your OpenWrt Router, if your main router’s address is 192.168.1.1 (most common), set the IP address of your OpenWrt router LAN interface to 192.168.2.1 (or to something that isn’t 192.168.1.X, anyway). Once you have chosen and written the IP address, write it down in the same sticker with the user/password above, it will be used to connect to your device in the future.

By default the WAN interface/port is set as DHCP client, this will allow it to work with networks where there is another router giving addresses without further configuration. If you need to set static address please see the instructions for Client device, and change the WAN interface settings accordingly.

Command-line instructions

Configure the LAN interface statically with the new IP address 192.168.2.1 .

uci set network.lan.ipaddr="192.168.2.1" uci commit network /etc/init.d/network restart

Note that changing the IP address causes the SSH session to hang/disconnect.

Читайте также:  Как настроить upvel роутер вай фай

Follow OpenWrt as client device to configure the WAN interface if necessary.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website. OK More information about cookies

Self-registration in the wiki has been disabled.
If you want to contribute to the OpenWrt wiki, please post HERE in the forum or ask on IRC for access.

Except where otherwise noted, content on this wiki is licensed under the following license:
CC Attribution-Share Alike 4.0 International

Источник

Change LAN IP in LuCI (to an IP on a different subnet)

Issue: Can’t change LAN IP in LuCI. After applying the changes, it fails and comes up with some dialogue box.

Root cause: This happens if the new IP is on a different subnet. It’is known and in fact deliberately designed to prevent the user from accidentally locking themselves out.

Solution: If you are confident that the new IP is correct, you have a few options:

Choose Apply Unchecked in the dialogue box*/. This will apply the settings without checking if you can access the new IP or not, so double check the IP .

If you prefer to not to bypass the check then you can do one of the following immediately (within 30 seconds) after changing the IP and applying the settings:

Make your PC get a new IP (for example by disconnecting and reconnecting the cable or the WiFi, or via the terminal), then quickly edit the router IP in the browser Window to the new IP .

Have prepared two static IPs for your PC LAN interface (one on the old IP range and the other in the new IP range), then after applying the settings in LuCI you quickly edit the router IP in the browser Window to the new IP .

Connect with SSH and issue the commands: uci set network.lan.ipaddr=’10.0.0.1′ ; uci commit network ; service network restart

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website. OK More information about cookies

Self-registration in the wiki has been disabled.
If you want to contribute to the OpenWrt wiki, please post HERE in the forum or ask on IRC for access.

Except where otherwise noted, content on this wiki is licensed under the following license:
CC Attribution-Share Alike 4.0 International

Источник

IPv4 configuration

Due to obvious reasons, IPv4 is fully supported in default firmware.

Upstream configuration for WAN-Interfaces

The following sections describe the configuration of IPv4 connections to your ISP or an upstream router.

For an uplink with native IPv4 connectivity you can just use the default configuration.

# uci show network . network.wan=interface network.wan.device='eth0.2' network.wan.proto='dhcp' .
# cat /etc/config/network . config interface 'wan' option device 'eth0.2' option proto 'dhcp' .

Protocol «static», IPv4

Name Type Required Default Description
ipaddr ip address yes, if no ip6addr is set. (none) IP address. [openwrt 12.09] It could be a list of ipaddr , that is: several ipaddresses will be assigned to the interface. If, instead of a list, several ipaddr are specified as options, only the last is applied.
netmask netmask yes, if no ip6addr is set (none) Netmask
gateway ip address no (none) Default gateway
broadcast ip address no (none) Broadcast address (autogenerated if not set)
dns list of ip addresses no (none) DNS server(s)
dns_metric integer no 0 DNS metric
dns_search list of domain names no (none) Search list for host-name lookup
metric integer no 0 Specifies the default route metric to use
Читайте также:  Роутер хаб умный дом

Protocol «dhcp»

Name Type Required Default Description
gateway string no (none) Suppresses DHCP -assigned default gateway if set to 0.0.0.0
(deprecated)
broadcast boolean no 0 Enable the broadcast flag in DHCP requests, required for certain ISPs, e.g. Charter with DOCSIS 3
ipaddr IP address no (none) IP address to request from the DHCP server
hostname string no (none) Hostname to include in DHCP requests
clientid string no system default Override client identifier in DHCP requests
vendorid string no system default Override the vendor class in DHCP requests
dns list of ip addresses no (none) Supplement DHCP -assigned DNS server(s), or use only these if peerdns is 0
peerdns boolean no 1 Use DHCP -provided DNS server(s)
defaultroute boolean no 1 Whether to create a default route via the received gateway
customroutes string no (none) Space-separated list of additional routes to insert via the received gateway
metric integer no 0 Specifies the route metric to use for both default route and custom routes
classlessroute boolean no 1 Whether to request the “classless route” option ( DHCP option 121) — available since LEDE r2001
reqopts string no (none) Space-separated list of additional DHCP options to request from the server
sendopts string no (none) Space-separated list of additional DHCP options to send to the server. Syntax: option:value where option is either an integer code or a symbolic name such as hostname .
norelease boolean no 0 If set DO NOT release DHCP address on interface shutdown
zone firewall zone no (none) Firewall zone to which this interface should be added

These parameters are handled partially by netifd (in interface.c ) and partially by a shell script in lib/netifd/proto/dhcp.sh . Note prior to commit 3cee6f3f24 the norelease option was known as release and had the opposite sense.

Outdated information, please proofread and test it:

If an interface is configured as dhcp client, the default route received by dhcp will be the only one listed and will remove other default route/metrics defined for other interfaces if those interfaces comes “before” the interface with dhcp in terms of “device” values. For example:

config interface 'wan' option device 'eth0' option proto 'static' . config interface 'wan2' option device 'eth1' option proto 'dhcp' .

The interface with dhcp comes after (because eth1 comes after eth0 in a lexicografical order) and will overwrite the default routes set up by the interface “wan”. While is not true the contrary. If we have:

config interface 'wan' option device 'eth0' option proto 'dhcp' . config interface 'wan2' option device 'eth1' option proto 'static' .

Both default routes set up by wan and wan2 will appear in the routing table.

Читайте также:  Связка роутер и коммутатор

Downstream configuration for LAN-Interfaces

For a downlink with IPv4 connectivity you can just use the default configuration, DHCP server is enabled by default, please see DHCP configuration for more details on that.

# uci show network network.lan=interface network.lan.device='br-lan' network.lan.proto='static' network.lan.netmask='255.255.255.0' network.lan.ip6assign='60' network.lan.ipaddr='192.168.1.1' .
# /etc/config/network config interface 'lan' option device 'br-lan' option proto 'static' option netmask '255.255.255.0' option ip6assign '60' option ipaddr '192.168.1.1' config device 'lan_dev' option name 'br-lan' option type 'bridge' list ports 'lan3' list ports 'lan4' .

Examples

Below are a few examples for special, non-standard interface configurations.

Bridge without IP

config interface 'example' option proto 'none' option device 'br-lan' option auto '1' config device 'example_dev' option name 'br-lan' option type 'bridge' list ports 'eth0' list ports 'eth1'

DHCP without default gateway

config interface 'example' option proto 'dhcp' option device 'eth0' option defaultroute' '0'

DHCP and IPv6

config interface 'example' option proto 'dhcp' option device 'eth0' config alias option interface 'example' option proto 'static' option ip6addr '2001:0DB8:100:F00:BA3::1'

Static IP configuration with multiple DNS servers

config interface 'example' option proto 'static' option device 'eth0' option ipaddr '192.168.1.200' option netmask '255.255.255.0' list dns '192.168.1.1' list dns '192.168.10.1'

The last DNS listed will be the first one to be chosen for the name resolution.

Restart the service to apply the new DNS configuration: service dnsmasq restart

Static IP configuration and default gateway with non-zero metric

config interface 'example' option proto 'static' option device 'eth0' option ipaddr '192.168.1.200' option netmask '255.255.255.0' option dns '192.168.1.1' config route option interface 'example' option target '0.0.0.0' option netmask '0.0.0.0' option gateway '192.168.1.1' option metric '100'

Multiple IP addresses

Assigning multiple IP addresses to the same interface:

config interface 'foo' option device 'eth1' list ipaddr '10.8.0.1/24' list ipaddr '10.9.0.1/24' list ip6addr 'fdca:abcd::1/64' list ip6addr 'fdca:cdef::1/64'

Specifying multiple interfaces sharing the same device:

config interface 'foo' option device 'eth1' option ipaddr '10.8.0.1' option netmask '255.255.255.0' option ip6addr 'fdca:abcd::1/64' config interface 'foo2' option device 'eth1' option ipaddr '10.9.0.1' option netmask '255.255.255.0' option ip6addr 'fdca:cdef::1/64'

Custom MAC address

config device option name 'eth0' option macaddr '00:11:22:33:44:55'

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website. OK More information about cookies

Self-registration in the wiki has been disabled.
If you want to contribute to the OpenWrt wiki, please post HERE in the forum or ask on IRC for access.

Except where otherwise noted, content on this wiki is licensed under the following license:
CC Attribution-Share Alike 4.0 International

Источник

Оцените статью
Adblock
detector