0

I need to lease multiple IP addresses from DHCP server and concurrently use all of them on single computer.

It should be connected as follows: computer with 5 local IP addresses: 192.168.1.2-6 connected by lan port to openwrt router which has leased 5 IP addresses with 5 virtual WAN ports each with different MAC address.

I managed to get the second part working with kmod-macvlan package. My setup is following: /etc/rc.local:

ip link add link eth0.2 eth1 type macvlan
ifconfig eth1 hw ether 54:E6:FC:B7:00:00

ip link add link eth0.2 eth2 type macvlan
ifconfig eth2 hw ether 54:E6:FC:B7:00:01

ip link add link eth0.2 eth3 type macvlan
ifconfig eth3 hw ether 54:E6:FC:B7:00:02

ip link add link eth0.2 eth4 type macvlan
ifconfig eth4 hw ether 54:E6:FC:B7:00:03

ip link add link eth0.2 eth5 type macvlan
ifconfig eth5 hw ether 54:E6:FC:B7:00:04

ifup -a

/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 'interface' 'lan'
    option 'ifname' 'eth0.1'
    option 'type' 'bridge'
    option 'proto' 'static'
    option 'ipaddr' '192.168.1.1'
    option 'netmask' '255.255.255.0'

config 'interface' 'wan'
    option 'ifname' 'eth0.2'
    option 'proto' 'dhcp'

config 'switch'
    option 'name' 'rtl8366rb'
    option 'reset' '1'
    option 'enable_vlan' '1'

config 'switch_vlan'
    option 'device' 'rtl8366rb'
    option 'vlan' '1'
    option 'ports' '1 2 3 4 5t'

config 'switch_vlan'
    option 'device' 'rtl8366rb'
    option 'vlan' '2'
    option 'ports' '0 5t'

config 'interface' 'wan1'
    option 'ifname' 'eth1'
    option 'proto' 'dhcp'
    option 'defaultroute' '0'
    option 'peerdns' '0'
    option 'gateway' '0.0.0.0'

config 'interface' 'wan2'
    option 'ifname' 'eth2'
    option 'proto' 'dhcp'
    option 'defaultroute' '0'
    option 'peerdns' '0'
    option 'gateway' '0.0.0.0'

config 'interface' 'wan3'
    option 'ifname' 'eth3'
    option 'proto' 'dhcp'
    option 'defaultroute' '0'
    option 'peerdns' '0'
    option 'gateway' '0.0.0.0'

config 'interface' 'wan4'
    option 'ifname' 'eth4'
    option 'proto' 'dhcp'
    option 'defaultroute' '0'
    option 'peerdns' '0'
    option 'gateway' '0.0.0.0'

config 'interface' 'wan5'
    option 'ifname' 'eth5'
    option 'proto' 'dhcp'
    option 'defaultroute' '0'
    option 'peerdns' '0'
    option 'gateway' '0.0.0.0'

ifconfig:

br-lan    Link encap:Ethernet  HWaddr 54:E6:FC:B7:**:**
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:168 errors:0 dropped:0 overruns:0 frame:0
          TX packets:164 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:17038 (16.6 KiB)  TX bytes:33230 (32.4 KiB)

eth0      Link encap:Ethernet  HWaddr 54:E6:FC:B7:**:**
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:719 errors:0 dropped:0 overruns:94459 frame:0
          TX packets:286 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:128743 (125.7 KiB)  TX bytes:57352 (56.0 KiB)
          Interrupt:4

eth0.1    Link encap:Ethernet  HWaddr 54:E6:FC:B7:**:**
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:219 errors:0 dropped:0 overruns:0 frame:0
          TX packets:206 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:24692 (24.1 KiB)  TX bytes:40289 (39.3 KiB)

eth0.2    Link encap:Ethernet  HWaddr 54:E6:FC:B7:**:**
          inet addr:192.168.99.8  Bcast:192.168.99.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:180 errors:0 dropped:0 overruns:0 frame:0
          TX packets:70 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:31280 (30.5 KiB)  TX bytes:15492 (15.1 KiB)

eth1      Link encap:Ethernet  HWaddr 54:E6:FC:B7:00:00
          inet addr:192.168.99.101  Bcast:192.168.99.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:89 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:17942 (17.5 KiB)  TX bytes:2476 (2.4 KiB)

eth2      Link encap:Ethernet  HWaddr 54:E6:FC:B7:00:01
          inet addr:192.168.99.102  Bcast:192.168.99.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:83 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:16826 (16.4 KiB)  TX bytes:2065 (2.0 KiB)

eth3      Link encap:Ethernet  HWaddr 54:E6:FC:B7:00:02
          inet addr:192.168.99.103  Bcast:192.168.99.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:76 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:1 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:15640 (15.2 KiB)  TX bytes:1259 (1.2 KiB)

eth4      Link encap:Ethernet  HWaddr 54:E6:FC:B7:00:03
          inet addr:192.168.99.104  Bcast:192.168.99.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:69 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:15220 (14.8 KiB)  TX bytes:1259 (1.2 KiB)

eth5      Link encap:Ethernet  HWaddr 54:E6:FC:B7:00:04
          inet addr:192.168.99.105  Bcast:192.168.99.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:81 errors:0 dropped:0 overruns:0 frame:0
          TX packets:17 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:16868 (16.4 KiB)  TX bytes:2293 (2.2 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:51 errors:0 dropped:0 overruns:0 frame:0
          TX packets:51 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:4065 (3.9 KiB)  TX bytes:4065 (3.9 KiB)

Now how do I tell router to pair following static lan ip addresses to virtual WAN ports:

192.168.1.2 - eth1

192.168.1.3 - eth2

192.168.1.4 - eth3

192.168.1.5 - eth4

192.168.1.6 - eth6

Network becomes unreachable for 192.168.1.2 after entering

ip route add 192.168.1.2 dev eth1
  • Let's start with a different question: Why do you think you need five different addresses, and if you do need them, why do you want to get them from the DHCP server? – RalfFriedl Sep 16 '18 at 14:29
  • Because my ISP's DHCP server leases one public IP address to each MAC address. – LukAss741 Sep 16 '18 at 14:35
  • Your ISP won't like that you trick it into giving you five IP addresses. – RalfFriedl Sep 16 '18 at 15:40
  • @RalfFriedl that is not point of this question. Anyway it was ISP's support who advised me this. Also, if they don't like it then they wouldn't set their network to allow this. – LukAss741 Sep 16 '18 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.