You are not logged in.

#1 2013-02-10 13:44:10

markwitmer
Member
Registered: 2013-02-10
Posts: 4

[SOLVED] netcfg: Ethernet and wireless, make wireless default gateway

I have an ethernet card and a wireless usb dongle; the wireless connects to a network w/internet access and the ethernet connects to a local router that just has two computers on it. My question is, how can I set up routes with netcfg and dhcpcd so that only requests to the ethernet's subnet (192.168.2.*) are handled by the ethernet card and everything else goes through the wireless router (192.168.1.1)? Right now if I take ethernet down, the internet works fine through the wireless, but as soon as I take the ethernet up, the internet goes away.

Here are my netcfg profiles:

Local:
--------

CONNECTION='ethernet'
DESCRIPTION='A basic static ethernet connection using iproute'
INTERFACE='enp4s0'
IP='static'
ADDR='192.168.2.100'

Wireless:
------------

CONNECTION='wireless'
DESCRIPTION='A simple WPA encrypted wireless connection'
INTERFACE='enp0s2f1u5'
SECURITY='wpa'

ESSID='***'
KEY='***'

IP='dhcp'

dhcpcd.conf:
-----------------

option domain_name_servers domain_name domain_search host_name'
option classless_static_routes
option ntp_servers
option interface_mtu
require dhcp_server_identifier
nohook lookup-hostname
noipv4ll

Last edited by markwitmer (2013-02-11 00:56:40)

Offline

#2 2013-02-10 22:01:56

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: [SOLVED] netcfg: Ethernet and wireless, make wireless default gateway

I suggested this in a similar thread, but have you looked at ip-route?

man ip-route

"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#3 2013-02-10 22:37:11

debijan
Member
Registered: 2010-09-14
Posts: 37

Re: [SOLVED] netcfg: Ethernet and wireless, make wireless default gateway

i thank what skanky mean is the route setting.
you've to find a way that do not set any gateway of your ethernet.
otherwise it will set automatically a route to 0.0.0.0(called default route) via this ethernet gateway and then you.ve no internet connection.

[root@nas ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.254   0.0.0.0         UG    205    0        0 bri0
192.168.1.0     0.0.0.0         255.255.255.0   U     205    0        0 bri0
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0

Offline

#4 2013-02-10 23:22:38

markwitmer
Member
Registered: 2013-02-10
Posts: 4

Re: [SOLVED] netcfg: Ethernet and wireless, make wireless default gateway

I think I figured out how to do this. It only required a couple minor changes to my netcfg profile. First you have to use DHCP to get your IP address instead of doing it statically. Then you pass the option -G to dhcpcd, which will inhibit the creation of a new gateway route. Ths final profile config looks like this:

CONNECTION='ethernet'
DESCRIPTION='A basic ethernet connection with no gateway'
INTERFACE='enp4s0'
IP='dhcp'
DHCP_OPTIONS='-G'

Thanks for the suggestions!

Offline

#5 2013-02-10 23:39:48

markwitmer
Member
Registered: 2013-02-10
Posts: 4

Re: [SOLVED] netcfg: Ethernet and wireless, make wireless default gateway

Never mind. Sadly, that only worked the first time. When I rebooted my computer, netcfg once again set up two gateways -- my wireless one, and then one for the ethernet that took precedence over it. This is very annoying.

Offline

#6 2013-02-11 00:15:27

markwitmer
Member
Registered: 2013-02-10
Posts: 4

Re: [SOLVED] netcfg: Ethernet and wireless, make wireless default gateway

Hopefully this really did fix it... I added a line to force the deletion of any gateway route on the ethernet interface. Seems to still work after a few reboots.

CONNECTION='ethernet'
DESCRIPTION='A local ethernet connection with no gateway'
INTERFACE='enp4s0'
IP='dhcp'
IPCFG='route delete default dev enp4s0'
DHCP_OPTIONS='-G'

Offline

#7 2013-02-11 00:27:43

the sad clown
Member
From: 192.168.0.X
Registered: 2011-03-20
Posts: 837

Re: [SOLVED] netcfg: Ethernet and wireless, make wireless default gateway

Don't forget to mark the thread [Solved] if you've found your solution.


I laugh, yet the joke is on me

Offline

Board footer

Powered by FluxBB