LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-27-2014, 02:27 PM   #1
charlweed
Member
 
Registered: Jan 2005
Posts: 46

Rep: Reputation: 15
How to set default route when gateway has dynamic IP?


I am making an edge-router server from Fedora 20. Now I am stuck on the last step, where I need to forward all non-local packets out to the WAN.
I have four NICS and a bridge on this server. All are defined in /etc/sysconfig/network-scripts/ifcfg-*. Only lan0 and wan0 use NetworkManager.

wan0 -> internet. Defined in ifcfg-wan0. Gets ip via dhcp
lan0 -> Local network. Defined in ifcfg-lan0. No IP, bridged to br0.
br0-> Local network. Defined in ifcfg-br0. Static IP (192.168.0.xxx).
wifi0-> Local network. Defined in ifcfg-wifi0. Managed via hostapd. Bridged to br0
wifi1-> Local network. Defined in ifcfg-wifi1. Managed via hostapd. Bridges to br0

For testing, I defined a gateway in /etc/sysconfig/network, as is recommended by RedHat. But this machine will BE the gateway, and the external IP is dynamic. I therefore removed it, but should it be GATEWAY=127.0.0.1?
After boot I can manually execute

ip route change default via XXX.XXX.XXX.XXX dev wan0

But I obviously need this to be set automatically. How do I do that?
Thanks!
PS. This machine uses iptables and NAT to direct the traffic of other hosts on my network to the WAN. The bridge is for hostapd WIFI.
 
Old 05-27-2014, 02:45 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,146

Rep: Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264
The dhcp server should push the gateway definition along with the IP and netmask. You want to let your dhcp client set the gateway.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Having trouble with default route/gateway x2r3x Linux - Networking 4 07-28-2011 05:32 PM
/etc/sysconfig/route-interface default gateway serge Linux - Networking 2 01-29-2009 10:05 PM
How programatically in C do I get/set the default route or gateway address of eth0 jroberts5477 Linux - Networking 2 09-15-2006 01:11 PM
dhclient not setting default gateway - no WAN route kadissie Linux - Networking 2 03-10-2005 04:55 AM
default route without a gateway scylla Linux - Networking 1 10-21-2004 01:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration