Ethernet settings by command line

Moderators: mdrjr, odroid

Ethernet settings by command line

Unread postby cioralut » Tue Jan 31, 2017 11:02 pm

I need to configure ethernet connection (DHCP enable/disable, IP Address, subnet mask, default gateway, domain name) by linux command line or directly to file.
I managed to set the IP (ifconfig eth0 192.168.1.10) and subnet mask (ifconfig eth0 netmask 255.255.255.0) but I don't know how to set Gateway, Dns and enable/disable DHCP.
Is there a file with eth0 settings? In linux there is /etc/networking/interfaces file but in ODROID-C2 I haven't find it :?
Can you help me? Thanks

Best regards

Daniele
cioralut
 
Posts: 71
Joined: Sat Oct 03, 2015 10:54 pm
Location: Italy
languages_spoken: english
ODROIDs: ODROID C1+ and ODROID C2

Re: Ethernet settings by command line

Unread postby rpcameron » Tue Jan 31, 2017 11:20 pm

Try man ip at the command line.ip is the interface to the iproute2 package; you can use that to manage your interfaces.

(Edit: just realized this was the Android subforum, so not sure if that's going to work. ...)
rpcameron
 
Posts: 259
Joined: Sat Apr 30, 2016 7:24 am
languages_spoken: english
ODROIDs: C2

Re: Ethernet settings by command line

Unread postby cioralut » Tue Jan 31, 2017 11:40 pm

Infact. The command man ip on "Android" linux shell doesn't work ....
cioralut
 
Posts: 71
Joined: Sat Oct 03, 2015 10:54 pm
Location: Italy
languages_spoken: english
ODROIDs: ODROID C1+ and ODROID C2

Re: Ethernet settings by command line

Unread postby codewalker » Wed Feb 01, 2017 9:30 am

$ su
# getprop | grep eth
# ifconfig eth0 xxx.xxx.xxx.xxx up
# route add default gw xxx.xxx.xxx.xxx dev eth0
# setprop net.dns1 xxx.xxx.xxx.xxx
User avatar
codewalker
 
Posts: 457
Joined: Mon Feb 25, 2013 11:03 am
languages_spoken: english
ODROIDs: all

Re: Ethernet settings by command line

Unread postby cioralut » Wed Feb 01, 2017 8:25 pm

Thanks for your help but this command didn't return errors but unfortunately didn't change any parameters (IP, DNS and GATEWAY remain the same as before)
cioralut
 
Posts: 71
Joined: Sat Oct 03, 2015 10:54 pm
Location: Italy
languages_spoken: english
ODROIDs: ODROID C1+ and ODROID C2

Re: Ethernet settings by command line

Unread postby codewalker » Mon Feb 13, 2017 1:36 pm

- dhcp diasable
# ifconfig eth0 down
# stop dhcpcd_eth0

- dhcp enable
ifconfig eth0 up

dns/subnet mast/gateway
getprop | grep dns[subnet|gateway]
setprop xxx xxx.xxx.xxx.xxx
User avatar
codewalker
 
Posts: 457
Joined: Mon Feb 25, 2013 11:03 am
languages_spoken: english
ODROIDs: all

Re: Ethernet settings by command line

Unread postby cioralut » Mon Feb 13, 2017 5:03 pm

Hi codewalker.
I know the commands to disable/enable eth0...
The other commands "getprop, setprop ..." don't work. Do you work with ODROID-C2? If yes please write me the commands for:

- ENABLE IP FROM DHCP SERVER
- ENABLE IP STATIC (ifconfig eth0 192.168.1.10 doesn't work. After a reboot the IP is set again to the previous value: 192.168.1.64)
- SET SUBNETMASK (ifconfig eth0 netmask 255.255.0.0 doesn't work. After a reboot the SUBNETMASK is set again to the previous value: 255.255.255.0 )
- SET GATEWAY (example 192.168.1.1)
- SET PRIMARY DNS (example 192.168.1.1)

Thanks
cioralut
 
Posts: 71
Joined: Sat Oct 03, 2015 10:54 pm
Location: Italy
languages_spoken: english
ODROIDs: ODROID C1+ and ODROID C2

Re: Ethernet settings by command line

Unread postby odroid » Mon Feb 13, 2017 5:12 pm

Does it work if you don't reboot?
User avatar
odroid
Site Admin
 
Posts: 25670
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Ethernet settings by command line

Unread postby cioralut » Mon Feb 13, 2017 7:38 pm

Excuse but why do not you try? :)

Code: Select all
shell@odroidc2:/ $ su
[  183.743361@1] ttyS0 use xtal 24000000 change 115200 to 115200
root@odroidc2:/ # ifconfig eth0
eth0: ip 192.168.5.10 mask 255.255.0.0 flags [up broadcast running multicast]
root@odroidc2:/ # ifconfig eth0 192.168.5.12 up
root@odroidc2:/ # ifconfig eth0
eth0: ip 192.168.5.12 mask 255.255.255.0 flags [up broadcast running multicast]
root@odroidc2:/ #
130|root@odroidc2:/ # ifconfig eth0 netmask 255.255.0.0
root@odroidc2:/ # ifconfig eth0
eth0: ip 192.168.5.12 mask 255.255.0.0 flags [up broadcast running multicast]
root@odroidc2:/ #
130|root@odroidc2:/ # ifconfig eth0 down
root@odroidc2:/ # ifconfig eth0 up
[  377.933773@2] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
root@odroidc2:/ # [  381.920538@2] libphy: stmmac-0:00 - Link is Up - 1000/Full
[  381.921297@2] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

root@odroidc2:/ # ifconfig eth0
eth0: ip 192.168.5.10 mask 255.255.0.0 flags [up broadcast running multicast]
root@odroidc2:/ #


It seems that the command
Code: Select all
ifconfig eth0 192.168.5.12 up
has been successful but it really is not so.
At PING command (ping 192.168.5.12) the devices not responde.
If I try to DOWN - UP eth0 (or reboot device) the IP is remained 192.168.5.10.
cioralut
 
Posts: 71
Joined: Sat Oct 03, 2015 10:54 pm
Location: Italy
languages_spoken: english
ODROIDs: ODROID C1+ and ODROID C2

Re: Ethernet settings by command line

Unread postby odroid » Mon Feb 13, 2017 8:43 pm

Did you stop the DHCP daemon first?
User avatar
odroid
Site Admin
 
Posts: 25670
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Ethernet settings by command line

Unread postby cioralut » Tue Feb 14, 2017 12:01 am

yes
cioralut
 
Posts: 71
Joined: Sat Oct 03, 2015 10:54 pm
Location: Italy
languages_spoken: english
ODROIDs: ODROID C1+ and ODROID C2

Re: Ethernet settings by command line

Unread postby codewalker » Tue Feb 14, 2017 9:58 am

Screenshot_20170214-005820.png

It is impossible to use linux command line.
Try settings -> Wireless & networks -> More -> Ethernet -> Static IP Settings.
User avatar
codewalker
 
Posts: 457
Joined: Mon Feb 25, 2013 11:03 am
languages_spoken: english
ODROIDs: all

Re: Ethernet settings by command line

Unread postby cioralut » Tue Feb 14, 2017 4:49 pm

So with ODROID-C2 the ONLY WAY to settings ethernet is to use android settings interface? :shock:
cioralut
 
Posts: 71
Joined: Sat Oct 03, 2015 10:54 pm
Location: Italy
languages_spoken: english
ODROIDs: ODROID C1+ and ODROID C2

Re: Ethernet settings by command line

Unread postby odroid » Tue Feb 14, 2017 7:40 pm

Yes, probably.
We could set the Ethernet configuration on the command line on Android 4.4 or old version with other platforms.
But we just found that Android 5.1 or newer version network settings are tightly coupled with internal network framework.
So it seems to be very hard use the command line.
User avatar
odroid
Site Admin
 
Posts: 25670
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Ethernet settings by command line

Unread postby rooted » Wed Feb 15, 2017 10:58 am

Using ndc is the proper way to set in Android, at least I think it is.

Code: Select all
ndc resolver setnetdns netId domains dns1 dns2
User avatar
rooted
 
Posts: 3703
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english
ODROIDs: C1
C1+
C2
XU3 Lite
XU4
VU7+
HiFi Shield 2
Smart Power (original)

Re: Ethernet settings by command line

Unread postby cioralut » Thu Feb 16, 2017 6:15 pm

Hi rotted. Sorry but i don't know this command.
Could you write me some examples?

1) ENABLE IP FROM DHCP SERVER
2) ENABLE IP STATIC (set 192.168.1.10)
3) SET SUBNETMASK (set 255.255.0.0)
4) SET GATEWAY (set 192.168.1.1)
5) SET PRIMARY DNS (set 192.168.1.1)

Thanks
Daniele
cioralut
 
Posts: 71
Joined: Sat Oct 03, 2015 10:54 pm
Location: Italy
languages_spoken: english
ODROIDs: ODROID C1+ and ODROID C2


Return to Android

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest