Adding static ip address to vlan

I cannot get my head around connman.

I have configured a VLAN eth0.xxxx and would like to set static IP to that interface. I managed to do that with startup script:
#!/bin/sh
modprobe 8021q
vconfig add eth0 xxxx
ifconfig eth0.3999 xxx.xxx.xxx.xxx netmask 255.255.255.0 up

It works until it stops working :smile:
During the day, ifconfig loses IP address for eth0.xxxx (maybe lease time?), and I have to manually run script again.

OK, let me stop babbling and provide you with a question. How can I set static IP just for interface eth0.xxxx?

Thank you.

Put the script in /etc/if-up.d and then it will run every time the interface goes up

I’ll try that.

BTW, great work. Can’t wait for osmc finaL for rpi2. It will be awesome.

Hello again,

after I put script into if-up.d, It adds IF on network up, The problem is that it probably runs dhcp discovery in that IF and doesn’t keep IP setting, so there is not ip:

eth0.xxxx Link encap:Ethernet HWaddr xxxxxxxxxxxx
inet6 addr: fe80::ba27:ebff:feeb:fb6b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:859 errors:0 dropped:0 overruns:0 frame:0
TX packets:117 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:39514 (38.5 KiB) TX bytes:31720 (30.9 KiB)

I would like to add, that scripts don’t run neither from /etc/if-up.d nor from /etc/network/if-up.d

It should be in /etc/network/if-up.d not /etc/ifup.d. Did you ensure the execute bit (chmod +x) was set on the script?

Sam

I think, everything is “by the rules”:

Script executes, when I run it.

Then I tried installing ifupdown and it started working…

Is it possible that scripts from if-up.d won’t run with connman?

Hello, dear sirs :smile:

New version, same issue. If-up.d script isn’t working. What am I missing.:

sioltv:

#!/bin/sh
modprobe 8021q
vconfig add eth0 3999
ifconfig eth0.3999 10.72.xx.xx netmask 255.255.255.0 up

Running script manually works just fine:

eth0 Link encap:Ethernet HWaddr b8:27:eb:eb:fb:6b
inet addr:192.168.1.223 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::ba27:ebff:feeb:fb6b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST DYNAMIC MTU:1500 Metric:1
RX packets:22183 errors:0 dropped:0 overruns:0 frame:0
TX packets:19556 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9424473 (8.9 MiB) TX bytes:2955470 (2.8 MiB)

eth0.3999 Link encap:Ethernet HWaddr b8:27:eb:eb:fb:6b
inet addr:10.72.xx.xx Bcast:10.72.xx.xxx Mask:255.255.255.0
inet6 addr: fe80::ba27:ebff:feeb:fb6b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST DYNAMIC MTU:1500 Metric:1
RX packets:870 errors:0 dropped:0 overruns:0 frame:0
TX packets:107 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:40020 (39.0 KiB) TX bytes:24127 (23.5 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:358 errors:0 dropped:0 overruns:0 frame:0
TX packets:358 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:31625 (30.8 KiB) TX bytes:31625 (30.8 KiB)

However, rebooting osmc doesn’t work:

[osmc@osmc:~$]ifconfig
eth0 Link encap:Ethernet HWaddr b8:27:eb:eb:fb:6b
inet addr:192.168.1.223 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::ba27:ebff:feeb:fb6b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST DYNAMIC MTU:1500 Metric:1
RX packets:4412 errors:0 dropped:0 overruns:0 frame:0
TX packets:3694 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3534812 (3.3 MiB) TX bytes:815359 (796.2 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:274 errors:0 dropped:0 overruns:0 frame:0
TX packets:274 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:25058 (24.4 KiB) TX bytes:25058 (24.4 KiB)


After installing network-manager, scripts in if-up.d folder started working

a good idea is also to add this line, so it you are using a trunk port. Default vlan for net and 3999 watching tv

ip route add 232.0.0.0/8 dev eth0.3999