View previous topic :: View next topic |
Author |
Message |
coolvibe n00b

Joined: 02 May 2003 Posts: 7 Location: The Netherlands
|
Posted: Tue Dec 23, 2003 3:46 am Post subject: Gentoo, static ipv6 adresses and default ipv6 gateways |
|
|
Hey folks,
Since I was setting up IPv6 in my home network, I was faced with the task of instrumenting my Gentoo box with the ability to grok static default routes. Why? Well, I could have relied on router advertising, but since that somehow entails messing with either radvd or dhcpv6, I hacked around a bit to supply that information myself. If you don't mind editing initscripts, this might be for you too.
I haven't got many machines at home, about 7 or so, all running something different (mostly BSD). If they all used those swanky mac-address based ipv6 adresses (or even worse, privacy extended and constantly changing adresses), it's a bitch to maintain a DNS server for them. What if you change a NIC in a machine? You'd have to change the DNS too... Yuck.
So I gave most of my machines static adresses.
In BSD it's easy to assign a machine a static IPv6 number and a default route through either /etc/hostname.* files or in the rc.conf. In Gentoo, I hacked up /etc/init.d/net.eth0 to include a new directive called 'gateway6'. The patch is included at the end (and I'll put it on the web somewhere).
First, let's demonstrate how my setup works:
I have one machine which is a ipv6 router. It has a ipv6 tunnel connection to somewhere, and has ipv6 packet forwarding on. That's very nice. All the other machines have static ipv6 numbers (I have a whole /64 to choose from, yay) and have their ipv6 default route set to the ipv6 router. So far so good. Simple to accomplish on most machines, except my Gentoo box.
Examine my /etc/conf.d/net:
Code: |
# This looks familliar, no?
face_eth0="dhcp"
# Static IPv6 assignment (fingered to protect my box)
inet6_eth0="1234:5678:9012:345::67/64"
# The 'new' directive
gateway6="eth0/1234:5678:9012:345::1"
|
When reloading your network, you might see something like this:
Code: |
* Bringing eth0 up...
* Adding inet6 adresses...
* eth0 inet6 add 1234:5678:9012:345::67/64...
* Setting default ipv6 gateway...
|
Voila! It works. Try ping6-ing out there somewhere.
Oh, lest I forget, the patch to /etc/init.d/net.eth0 (which is also available at my website:
Code: |
--- net.eth0.dist 2003-12-23 02:59:43.861169696 +0100
+++ net.eth0 2003-12-23 03:07:09.366442600 +0100
@@ -121,7 +121,21 @@
/sbin/route del default dev ${gateway%/*} &>/dev/null
/sbin/route add default gw ${gateway#*/} dev ${gateway%/*} \
netmask 0.0.0.0 metric 1 >/dev/null || {
-
+ local error=$?
+ ifconfig ${IFACE} down &>/dev/null
+ eend ${error} "Failed to bring ${IFACE} up"
+ stop
+ return ${error}
+ }
+ eend 0
+ fi
+
+ if [ -n "${gateway6}" ] && [ "${gateway6%/*}" = "${IFACE}" ]
+ then
+ ebegin " Setting default ipv6 gateway"
+ # First delete any existing routes if it was setup by kernel ..
+ /sbin/route add -A inet6 default gw ${gateway6#*/} >/dev/null\
+ || {
local error=$?
ifconfig ${IFACE} down &>/dev/null
eend ${error} "Failed to bring ${IFACE} up"
|
I hope this is of use to anyone. I know it's a bit of a hack, but it works for me.
Cheers,
Emiel _________________ dash dash space |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|